-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (70 loc) · 3.04 KB
/
Copy pathjoss_tests.yml
File metadata and controls
82 lines (70 loc) · 3.04 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Run PICA JOSS Tests
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
# ------------------------------------------------------------------------
# PHASE 1: SETUP
# ------------------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Cache pip dependencies
id: cache-pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
# The key invalidates the cache if requirements change
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
# Use a dedicated step for installing dependencies.
# The 'if' condition prevents re-installing if the cache was restored.
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest flake8 pytest-cov
# ------------------------------------------------------------------------
# PHASE 2: READYMADE TESTS (Standard Industry Checks)
# ------------------------------------------------------------------------
- name: Run Style & Syntax Check (Flake8)
run: |
echo "STEP 1: Checking for critical syntax errors..."
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
echo "STEP 2: Checking for code style warnings..."
flake8 . --count --exit-zero --max-complexity=18 --max-line-length=127 --statistics
# ------------------------------------------------------------------------
# PHASE 3: COMBINED TESTS (Generates both coverage and test results)
# ------------------------------------------------------------------------
- name: Run All Tests and Generate Reports
run: |
echo "--------------------------------------"
echo "GOAL: Generate coverage.xml and junit.xml"
# This command runs all tests, generates XML coverage, and JUnit XML.
pytest --cov=. --cov-report=xml --junitxml=junit.xml -o junit_family=legacy tests/
# ------------------------------------------------------------------------
# PHASE 4: CODECOV UPLOADS
# ------------------------------------------------------------------------
- name: Upload Coverage Report (XML)
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true # It's good practice to fail if coverage upload fails.
- name: Upload Test Results to Codecov (JUnit)
if: always() # This ensures test results are uploaded even if previous steps fail.
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./junit.xml
# This step uploads test timing and failure data