ci: add tests workflow #70
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
name: CI | |
on: | |
push: | |
branches: [master, dev] | |
pull_request: | |
workflow_dispatch: | |
env: | |
PY_VERSION: "3.13" | |
CACHE_VERSION: 1 | |
jobs: | |
base: | |
name: Prepare dependences | |
runs-on: ubuntu-latest | |
outputs: | |
PY_PATH: ${{ steps.install_depends.outputs.PY_PATH }} | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Setup Python" | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{env.PY_VERSION}} | |
- name: "Install dependencies" | |
id: install_depends | |
run: | | |
echo "PY_PATH=${{env.pythonLocation}}" >> $GITHUB_OUTPUT | |
pip install -r requirements_test.txt | |
- name: "Cache dependencies" | |
uses: actions/[email protected] | |
with: | |
path: ${{env.pythonLocation}} | |
key: ${{ runner.os }}-pip-dependencies-${{ hashFiles('requirements.txt') }}_${{env.CACHE_VERSION}} | |
black: | |
name: Black codestyle | |
runs-on: ubuntu-latest | |
needs: base | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: Restore Python | |
uses: actions/cache/[email protected] | |
with: | |
path: ${{needs.base.outputs.PY_PATH}} | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-pip-dependencies-${{ hashFiles('requirements.txt') }}_${{env.CACHE_VERSION}} | |
- name: "Black codestyle check" | |
run: ${{needs.base.outputs.PY_PATH}}/bin/black --check --diff . | |
codespell: | |
name: "Codespell check" | |
runs-on: ubuntu-latest | |
needs: base | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: Restore Python | |
uses: actions/cache/[email protected] | |
with: | |
path: ${{needs.base.outputs.PY_PATH}} | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-pip-dependencies-${{ hashFiles('requirements.txt') }}_${{env.CACHE_VERSION}} | |
- name: "Codespell check" | |
run: ${{needs.base.outputs.PY_PATH}}/bin/codespell | |
pytest: | |
name: "Pytest" | |
runs-on: ubuntu-latest | |
needs: base | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: Restore Python | |
uses: actions/cache/[email protected] | |
with: | |
path: ${{needs.base.outputs.PY_PATH}} | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-pip-dependencies-${{ hashFiles('requirements.txt') }}_${{env.CACHE_VERSION}} | |
- name: "Pytest" | |
run: | | |
${{needs.base.outputs.PY_PATH}}/bin/pytest --cov tests/ --disable-warnings -s |