Render template ../cookiecutter-python-cli at 85aa291864 #246
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: Check | |
on: | |
pull_request: | |
push: | |
workflow_dispatch: | |
schedule: | |
# Re-test every month | |
- cron: '0 2 1 * *' | |
env: | |
# more verbosity to make it easier to understand failures | |
PYTEST_FLAGS: -v --log-level=DEBUG | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- '3.8' | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
- '3.12' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Get pip cache dir | |
id: pip-cache | |
run: | | |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: Persistent Github pip cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: pip-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml', 'setup.cfg', 'setup.py', 'Makefile') }} | |
restore-keys: | | |
pip-${{ runner.os }}-${{ matrix.python-version }}- | |
pip-${{ runner.os }}- | |
- name: Persistent Github venv cache | |
uses: actions/cache@v3 | |
with: | |
path: .venv/ | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'setup.cfg', 'setup.py', 'Makefile') }} | |
- name: Install dependencies | |
run: make venv | |
- name: flake8 | |
uses: liskin/gh-problem-matcher-wrap@v3 | |
with: | |
linters: flake8 | |
run: make lint-flake8 | |
- name: mypy | |
uses: liskin/gh-problem-matcher-wrap@v3 | |
with: | |
linters: mypy | |
run: make lint-mypy | |
- name: isort | |
uses: liskin/gh-problem-matcher-wrap@v3 | |
with: | |
linters: isort | |
run: make lint-isort | |
- name: pytest | |
uses: liskin/gh-problem-matcher-wrap@v3 | |
with: | |
linters: pytest | |
run: make test-pytest | |
- name: cram, readme | |
run: make test-cram readme | |
- name: check-wheel | |
run: make check-wheel | |
check-distro: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
image: | |
- 'debian:unstable' | |
- 'debian:testing' | |
- 'debian:stable' | |
- 'debian:oldstable' | |
- 'ubuntu:devel' | |
- 'ubuntu:rolling' | |
- 'ubuntu:latest' | |
container: ${{ matrix.image }} | |
steps: | |
- name: Install prerequisites via apt | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
set -ex | |
apt update | |
apt install -y git | |
- uses: actions/checkout@v4 | |
- name: Install dependencies via apt | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
set -ex | |
deps=$(sed -n '/^\[tool.gha-check-distro\]/,/^\[/p' pyproject.toml \ | |
| tr '\n' ' ' \ | |
| grep -o -P '\sdependencies-apt\s*=\s*\K\[.*?\]' \ | |
| grep -o -P '".*?"' \ | |
| tr -d '"') | |
apt-cache --generate pkgnames \ | |
| grep --line-regexp --fixed-strings "$deps" \ | |
| xargs apt install -y | |
- name: Workaround for https://github.com/actions/checkout/pull/762 not persisting | |
run: git config --global --add safe.directory "$PWD" | |
- name: Install remaining dependencies | |
run: make venv-system-site-packages | |
- name: flake8 | |
uses: liskin/gh-problem-matcher-wrap@v3 | |
with: | |
linters: flake8 | |
run: make lint-flake8 | |
- name: mypy | |
uses: liskin/gh-problem-matcher-wrap@v3 | |
with: | |
linters: mypy | |
run: make lint-mypy | |
- name: isort | |
uses: liskin/gh-problem-matcher-wrap@v3 | |
with: | |
linters: isort | |
run: make lint-isort | |
- name: pytest | |
uses: liskin/gh-problem-matcher-wrap@v3 | |
with: | |
linters: pytest | |
run: make test-pytest | |
- name: cram, readme | |
run: make readme | |
- name: check-wheel | |
run: make check-wheel | |
workflow-keepalive: | |
if: github.event_name == 'schedule' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Re-enable workflow | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh api -X PUT repos/${{ github.repository }}/actions/workflows/check.yaml/enable |