Blog Prep (#5) #19
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: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
- develop | |
- 'feature/*' | |
- 'hotfix/*' | |
- 'release/*' | |
- 'fixes/*' | |
push: | |
branches: | |
- main | |
- develop | |
jobs: | |
pre-commit: | |
name: Pre-commit CI | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [ "3.10" ] | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Run Pre-commit | |
uses: pre-commit/[email protected] | |
ci-tests: | |
name: Pytest CI | |
runs-on: ubuntu-latest | |
needs: pre-commit | |
strategy: | |
matrix: | |
python-version: [ "3.10", "3.11", "3.12" ] | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
id: setup-python | |
with: | |
python-version: ${{ matrix.python-version }} | |
# The key configuration value here is `virtualenvs-in-project: true`: this creates the | |
# venv as a `.venv` in your testing directory, which allows the next step to easily | |
# cache it. | |
- uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
# Install dependencies if cache does not exist | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install | |
- name: Run the full test suite | |
run: poetry run python -m pytest |