Add custom variable files #105
Workflow file for this run
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: Test & Linting | |
env: | |
DEFAULT_PYTHON: "3.11" | |
PRE_COMMIT_CACHE: ~/.cache/pre-commit | |
KEY_PREFIX: base-venv | |
CACHE_VERSION: 1 | |
# yamllint disable-line rule:truthy | |
on: | |
push: | |
pull_request: | |
types: [opened, synchronize] | |
branches: main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
prepare-base: | |
name: Prepare base dependencies | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
outputs: | |
python-key: ${{ steps.generate-python-key.outputs.key }} | |
pre-commit-key: ${{ steps.generate-pre-commit-key.outputs.key }} | |
steps: | |
- name: Check out code from GitHub | |
uses: actions/[email protected] | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
id: python | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
check-latest: true | |
- name: Generate partial Python venv restore key | |
id: generate-python-key | |
run: >- | |
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}" >> | |
$GITHUB_OUTPUT | |
- name: Restore Python virtual environment | |
id: cache-venv | |
uses: actions/[email protected] | |
with: | |
path: venv | |
key: >- | |
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | |
steps.generate-python-key.outputs.key }} | |
- name: Create Python virtual environment | |
if: steps.cache-venv.outputs.cache-hit != 'true' | |
run: | | |
python -m venv venv | |
. venv/bin/activate | |
python -m pip install -U pip setuptools wheel | |
pip install -U ".[dev]" | |
- name: Generate pre-commit restore key | |
id: generate-pre-commit-key | |
run: >- | |
echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{ | |
hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT | |
- name: Restore pre-commit environment | |
id: cache-precommit | |
uses: actions/[email protected] | |
with: | |
path: ${{ env.PRE_COMMIT_CACHE }} | |
key: >- | |
${{ runner.os }}-${{ steps.generate-pre-commit-key.outputs.key }} | |
- name: Install pre-commit dependencies | |
if: steps.cache-precommit.outputs.cache-hit != 'true' | |
run: | | |
. venv/bin/activate | |
pre-commit install --install-hooks | |
lint-ruff: | |
name: ruff | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: prepare-base | |
steps: | |
- name: Check out code from GitHub | |
uses: actions/[email protected] | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
id: python | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
check-latest: true | |
- name: Restore Python virtual environment | |
id: cache-venv | |
uses: actions/[email protected] | |
with: | |
path: venv | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | |
needs.prepare-base.outputs.python-key }} | |
- name: Restore pre-commit environment | |
id: cache-precommit | |
uses: actions/[email protected] | |
with: | |
path: ${{ env.PRE_COMMIT_CACHE }} | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} | |
- name: Register ruff problem matcher | |
run: | | |
echo "::add-matcher::.github/workflows/matchers/ruff.json" | |
- name: Run ruff | |
run: | | |
. venv/bin/activate | |
pre-commit run --hook-stage manual ruff --all-files --show-diff-on-failure | |
lint-black: | |
name: black | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: prepare-base | |
steps: | |
- name: Check out code from GitHub | |
uses: actions/[email protected] | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
id: python | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
check-latest: true | |
- name: Restore Python virtual environment | |
id: cache-venv | |
uses: actions/[email protected] | |
with: | |
path: venv | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | |
needs.prepare-base.outputs.python-key }} | |
- name: Restore pre-commit environment | |
id: cache-precommit | |
uses: actions/[email protected] | |
with: | |
path: ${{ env.PRE_COMMIT_CACHE }} | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} | |
- name: Run black checks | |
run: | | |
. venv/bin/activate | |
pre-commit run --hook-stage manual black --all-files --show-diff-on-failure | |
pylint: | |
name: Check pylint | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: prepare-base | |
steps: | |
- name: Check out code from GitHub | |
uses: actions/[email protected] | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
id: python | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
check-latest: true | |
- name: Restore Python virtual environment | |
id: cache-venv | |
uses: actions/[email protected] | |
with: | |
path: venv | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | |
needs.prepare-base.outputs.python-key }} | |
- name: Restore pre-commit environment | |
id: cache-precommit | |
uses: actions/[email protected] | |
with: | |
path: ${{ env.PRE_COMMIT_CACHE }} | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} | |
- name: Register pylint problem matcher | |
run: | | |
echo "::add-matcher::.github/workflows/matchers/pylint.json" | |
- name: Run pylint checks | |
run: | | |
. venv/bin/activate | |
pip install -U . | |
pre-commit run --hook-stage manual pylint --all-files | |
mypy: | |
name: Check mypy | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: prepare-base | |
steps: | |
- name: Check out code from GitHub | |
uses: actions/[email protected] | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
id: python | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
check-latest: true | |
- name: Restore Python virtual environment | |
id: cache-venv | |
uses: actions/[email protected] | |
with: | |
path: venv | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | |
needs.prepare-base.outputs.python-key }} | |
- name: Restore pre-commit environment | |
id: cache-precommit | |
uses: actions/[email protected] | |
with: | |
path: ${{ env.PRE_COMMIT_CACHE }} | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} | |
- name: Register mypy problem matcher | |
run: | | |
echo "::add-matcher::.github/workflows/matchers/mypy.json" | |
- name: Run mypy checks | |
run: | | |
. venv/bin/activate | |
pip install -U . | |
pre-commit run mypy --all-files | |
lint-other: | |
name: Run other linters | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: prepare-base | |
steps: | |
- name: Check out code from GitHub | |
uses: actions/[email protected] | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
id: python | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
check-latest: true | |
- name: Restore Python virtual environment | |
id: cache-venv | |
uses: actions/[email protected] | |
with: | |
path: venv | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | |
needs.prepare-base.outputs.python-key }} | |
- name: Restore pre-commit environment | |
id: cache-precommit | |
uses: actions/[email protected] | |
with: | |
path: ${{ env.PRE_COMMIT_CACHE }} | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} | |
- name: Register yamllint problem matcher | |
run: | | |
echo "::add-matcher::.github/workflows/matchers/yamllint.json" | |
- name: Run yamllint | |
run: | | |
. venv/bin/activate | |
pre-commit run --hook-stage manual yamllint --all-files --show-diff-on-failure | |
- name: Register check-json problem matcher | |
run: | | |
echo "::add-matcher::.github/workflows/matchers/check-json5.json" | |
- name: Run check-json5 | |
run: | | |
. venv/bin/activate | |
pre-commit run --hook-stage manual check-json5 --all-files | |
- name: Register check executables problem matcher | |
run: | | |
echo "::add-matcher::.github/workflows/matchers/check-executables-have-shebangs.json" | |
- name: Run executables check | |
run: | | |
. venv/bin/activate | |
pre-commit run --hook-stage manual check-executables-have-shebangs --all-files | |
- name: Register codespell problem matcher | |
run: | | |
echo "::add-matcher::.github/workflows/matchers/codespell.json" | |
- name: Run codespell | |
run: | | |
. venv/bin/activate | |
pre-commit run --show-diff-on-failure --hook-stage manual codespell --all-files | |
- name: Run prettier | |
run: | | |
. venv/bin/activate | |
pre-commit run --hook-stage manual prettier --all-files | |
- name: Run bandit (fully) | |
run: | | |
. venv/bin/activate | |
pre-commit run --hook-stage manual bandit --all-files --show-diff-on-failure | |
test: | |
name: test | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: prepare-base | |
steps: | |
- name: Check out code from GitHub | |
uses: actions/[email protected] | |
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | |
id: python | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
check-latest: true | |
- name: Restore Python virtual environment | |
id: cache-venv | |
uses: actions/[email protected] | |
with: | |
path: venv | |
fail-on-cache-miss: true | |
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | |
needs.prepare-base.outputs.python-key }} | |
- name: Run tests | |
env: | |
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }} | |
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} | |
run: | | |
. venv/bin/activate | |
pip install -U . | |
python -m pytest --cov="opentaskpy" --cov-report=xml | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
changelog: | |
name: Check Changelog | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Changelog check | |
uses: Zomzog/[email protected] | |
with: | |
fileName: CHANGELOG.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |