-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (49 loc) · 1.44 KB
/
classroom.yml
File metadata and controls
56 lines (49 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Autograding Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
repository_dispatch:
permissions:
contents: write
jobs:
run-autograding-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
# to validate: check that we can import functions from calculator.py
- name: Check calculator module setup
id: validate_code
run: |
echo "Testing if calculator.py is valid..."
python3 - <<'EOF'
try:
from calculator import multiply, add, subtract, divide, square, cube
except ImportError as e:
print("ERROR: calculator.py is missing required functions or has syntax errors.")
print(e)
exit(1)
except Exception as e:
print("ERROR: calculator.py has runtime issues.")
print(e)
exit(1)
else:
print("calculator.py is valid.")
EOF
- name: Run function tests and capture results
id: pytest-calculator
run: |
pytest test_calculator.py --tb=short --no-header --junitxml=results.xml