actions: use isort --check-only #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |