Skip to content

Commit 1c2fe52

Browse files
committed
GitHub Action, Pytest
1 parent e350fe5 commit 1c2fe52

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/pytest.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Workflow for running tests on server code
2+
name: Test Server
3+
4+
on:
5+
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
- reopened
10+
paths:
11+
- 'src/server/**'
12+
- 'src/sandbox/**'
13+
14+
# Allows running this workflow manually
15+
workflow_dispatch:
16+
17+
jobs:
18+
check:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.11"
25+
26+
- name: Install dependencies
27+
run: |
28+
cd src/
29+
python -m pip install --upgrade pip wheel setuptools
30+
pip install -r requirements.txt
31+
pip install pytest docker
32+
33+
- name: Determine changed files
34+
id: changes
35+
run: |
36+
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
37+
echo "Changed files: $CHANGED_FILES"
38+
39+
if echo "$CHANGED_FILES" | grep -q '^src/sandbox/'; then
40+
echo "client=true" >> $GITHUB_ENV
41+
fi
42+
43+
if echo "$CHANGED_FILES" | grep -q '^src/server/'; then
44+
echo "server=true" >> $GITHUB_ENV
45+
fi
46+
47+
- name: Run client tests
48+
if: env.client == 'true' && env.server != 'true'
49+
run: |
50+
cd src/
51+
pytest sandbox
52+
53+
- name: Run server tests
54+
if: env.server == 'true' && env.client != 'true'
55+
run: |
56+
cd src/
57+
pytest server
58+
59+
- name: Run all tests
60+
if: env.client == 'true' && env.server == 'true'
61+
run: |
62+
cd src/
63+
pytest
64+
65+
# Block merging if the job fails
66+
permissions:
67+
pull-requests: write

0 commit comments

Comments
 (0)