Pytests #2
Workflow file for this run
This file contains hidden or 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
# Workflow for running tests on server code | |
name: Run Tests | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
paths: | |
- "src/server/**" | |
- "src/sandbox/**" | |
# Allows running this workflow manually | |
workflow_dispatch: | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
cd src/ | |
python -m pip install --upgrade pip wheel setuptools | |
pip install -r requirements.txt | |
pip install pytest docker | |
- name: Determine changed files | |
id: changes | |
run: | | |
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) | |
echo "Changed files: $CHANGED_FILES" | |
if echo "$CHANGED_FILES" | grep -q '^src/sandbox/'; then | |
echo "client=true" >> $GITHUB_ENV | |
fi | |
if echo "$CHANGED_FILES" | grep -q '^src/server/'; then | |
echo "server=true" >> $GITHUB_ENV | |
fi | |
- name: Run Server Tests | |
if: env.server == 'true' | |
run: | | |
cd src/ | |
pytest server | |
- name: Run Client Tests | |
if: env.client == 'true' | |
run: | | |
cd src/ | |
pytest sandbox | |
# Block merging if the job fails | |
permissions: | |
pull-requests: write |