CI (tests, flake8, mypy) #250
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 (tests, flake8, mypy) | |
on: | |
push: | |
paths-ignore: | |
- 'changelog.rst' | |
pull_request: | |
schedule: | |
- cron: '0 11 * * 4' | |
jobs: | |
skip_duplicate: | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@master | |
with: | |
github_token: ${{ github.token }} | |
analyse: | |
name: Analyse | |
needs: skip_duplicate | |
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Initializes the CodeQL tools for scanning. | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v3 | |
# Override language selection | |
with: | |
languages: python | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 | |
test-pip: | |
needs: skip_duplicate | |
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }} | |
strategy: | |
matrix: | |
python-version: [ 3.9, "3.10", "3.11", "3.12", "pypy3.9" , "pypy3.10" ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade -r requirements_ci.txt | |
- name: Lint all python files with flake8 | |
run: | | |
# stop the build if there are flake8 errors | |
flake8 src tests --count --show-source --statistics | |
- name: Type check package source with mypy | |
run: | | |
mypy src/nographs | |
- name: Check source code formatting with Black | |
run: | | |
black src/nographs tests --check --verbose --diff | |
- name: Install from source (required for the pre-commit tests) | |
run: python -m pip install . | |
- name: Run all tests (including doc tests) | |
run: python ./tests/test_nographs.py | |
- name: Upload coverage | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
- name: Build package | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade build | |
python -m build | |
python -m pip install dist/*.tar.gz | |
echo "Install went OK" | |
# publish: | |
# name: Publish to PyPI | |
# needs: build | |
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout source | |
# uses: actions/checkout@v4 | |
# - name: Set up Python 3.9 | |
# uses: actions/setup-python@v5 | |
# with: | |
# python-version: 3.9 | |
# - name: Build package | |
# run: | | |
# pip install wheel | |
# python setup.py sdist bdist_wheel | |
# - name: Publish | |
# uses: pypa/[email protected] | |
# with: | |
# user: __token__ | |
# password: ${{ secrets.PYPI_API_TOKEN }} |