-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (124 loc) · 4.2 KB
/
code_check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# This is a template for a CI/CD workflow for your own Python package.
#
# Copy this template in to your repository and adapt it according to
# the TODOs. All relevant parts are marked with a `TODO` in the following.
name: code_check
env:
# TODO for the user of this template: adapt the following variables to the names in your project.
#
# The template is designed for developing a Python package in the form:
# project_template/
# ├── package_src/
# │ └── __init__.py
# ├── tests/
# │ └── __init__.py
# The template can't know the name of the `package_src` and `tests` directories.
# So, you have to add them here:
# set the name of your Python package directory
PY_PACKAGE_DIR: package_src
# set the name of your unit test directory
PY_UNIT_TEST_DIR: tests
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
pylint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# note that pylint needs your project's dependencies to be installed
pip install -r requirements.txt
pip install pylint
- name: Analysing the code with pylint
run: |
pylint -d C0301,R0913,W1202 $(git ls-files '*.py') --ignored-modules "rdkit"
pydocstyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pydocstyle
- name: Analysing the code with pydocstyle
run: |
pydocstyle .
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black[jupyter]
- name: Analysing the code with black
run: |
black --check .
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install isort
- name: Analysing the code with isort
run: |
isort --profile black --check-only .
test_basis:
needs:
- pylint
- pydocstyle
- black
- isort
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python -m pip install --upgrade pip
pip install coverage
pip install .
- name: Run unit-tests
run: |
# TODO for the user of this template:
# You might have to adapt the call running the test coverage to fit your test backend.
# The default unittest framework is `unittest` from Python's standard library.
# For example, if you use `pytest` you need to comment/uncomment the lines below.
# For other backends and details see https://coverage.readthedocs.io/en/latest/index.html
# Run test suite in the tests directory.
coverage run --source=$PY_PACKAGE_DIR,$PY_UNIT_TEST_DIR -m unittest discover $PY_UNIT_TEST_DIR
# uncomment if you use pytest as test backend
#coverage run --source=$PY_PACKAGE_DIR,$PY_UNIT_TEST_DIR -m pytest discover $PY_UNIT_TEST_DIR
# Create a coverage report. Fail if the coverage is below 80%.
coverage report --fail-under=80