Skip to content

Commit

Permalink
Setup pytest CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
shalomb committed Oct 5, 2024
1 parent 0ae3cf8 commit dd55d38
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---

name: Pytest tests

on:
- pull_request
- push

# permission can be added at job level or workflow level
permissions:
id-token: write # This is required for requesting the JWT
contents: write # This is required for actions/checkout
pull-requests: write

env:
VERBOSITY: 4

jobs:
pytest:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
steps:
- uses: actions/checkout@master

- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: make
version: 1.0

- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip

- name: Restore cached virtualenv
uses: actions/cache/restore@v4
with:
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
path: venv

- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
make requirements
make dev
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
- name: Run tests
run: |
make test
- name: Saved cached virtualenv
uses: actions/cache/save@v4
with:
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
path: venv

# https://adamj.eu/tech/2023/11/02/github-actions-faster-python-virtual-environments/

0 comments on commit dd55d38

Please sign in to comment.