Skip to content

Commit

Permalink
add automated pytest running on Github
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Clerkx committed Aug 26, 2024
1 parent cbcc2aa commit 4e38ffe
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/backend_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Backend CI
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# When this action will be executed
on:
# Automatically trigger it when detected changes in repo
push:
branches:
- main
paths:
- "api/**"
- ".github/workflows/backend_ci.yml"
pull_request:
branches:
- main
paths:
- "api/**"
- ".github/workflows/backend_ci.yml"

# Allow manual trigger
workflow_dispatch:

permissions:
contents: read
issues: read
checks: write
pull-requests: write

jobs:
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Switch directory
run: cd api

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install poetry
uses: abatilo/actions-poetry@v2

- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- name: Define a cache for the virtual environment based on the dependencies lock file
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}

- name: Install the project dependencies
run: poetry install --with=dev

- name: Run the automated tests (for example)
run: poetry run pytest tests/ --junit-xml=test-results.xml

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
test-results.xml

0 comments on commit 4e38ffe

Please sign in to comment.