Lint and test #359
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 workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Lint and test | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 8 * * 6' # every saturday at 8:00 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: | | |
requirements.txt | |
async-requirements.txt | |
dev-requirements.txt | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip wheel | |
pip install -r requirements.txt | |
pip install -r async-requirements.txt | |
pip install -r dev-requirements.txt | |
pip install pytest-github-actions-annotate-failures | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 codingame tests examples --count --select=E9,F63,F7,F82 --show-source --statistics \ | |
--format='::error file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s' | |
# exit-zero treats all errors as warnings | |
flake8 codingame tests examples --count --exit-zero --statistics \ | |
--format='::warning file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s' | |
- name: Check formatting with black | |
run: | | |
black codingame tests examples --check --line-length 80 | |
- name: Check import ordering with isort | |
run: | | |
isort codingame tests examples --check-only | |
- name: Lint the docs with doc8 | |
run: | | |
doc8 docs --quiet | |
- name: Check package build | |
run: | | |
python setup.py --quiet sdist | |
twine check dist/* | |
- name: Test the mocked API endpoints with pytest | |
run: | | |
pytest --only-mocked --overwrite-environ -v | |
- name: Test with pytest without mocking API enpoints | |
env: | |
TEST_LOGIN_REMEMBER_ME_COOKIE: ${{ secrets.TEST_LOGIN_REMEMBER_ME_COOKIE }} | |
TEST_CODINGAMER_ID: ${{ secrets.TEST_CODINGAMER_ID }} | |
TEST_CODINGAMER_PSEUDO: ${{ secrets.TEST_CODINGAMER_PSEUDO }} | |
TEST_CODINGAMER_PUBLIC_HANDLE: ${{ secrets.TEST_CODINGAMER_PUBLIC_HANDLE }} | |
TEST_CLASHOFCODE_PUBLIC_HANDLE: ${{ secrets.TEST_CLASHOFCODE_PUBLIC_HANDLE }} | |
run: | | |
pytest --no-mocking --cov-append -v | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v1 | |
with: | |
fail_ci_if_error: true |