1- name : Run PICA JOSS Tests
2-
3- on :
4- push :
5- branches : [ "main", "master" ]
6- pull_request :
7- branches : [ "main", "master" ]
8-
9- jobs :
10- test :
11- name : automated test
12- runs-on : ubuntu-latest
13-
14- steps :
15- # ------------------------------------------------------------------------
16- # PHASE 1: SETUP
17- # ------------------------------------------------------------------------
18- - name : Checkout repository
19- uses : actions/checkout@v4
20-
21- - name : Set up Python 3.10
22- uses : actions/setup-python@v5
23- with :
24- python-version : " 3.10"
25-
26- - name : Cache pip dependencies
27- id : cache-pip
28- uses : actions/cache@v4
29- with :
30- path : ~/.cache/pip
31- # The key invalidates the cache if requirements change
32- key : ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
33- restore-keys : |
34- ${{ runner.os }}-pip-
35-
36- - name : Install Dependencies
37- # Use a dedicated step for installing dependencies.
38- run : |
39- python -m pip install --upgrade pip
40- pip install -e .
41- pip install pytest flake8 pytest-cov
42-
43- # ------------------------------------------------------------------------
44- # PHASE 2: READYMADE TESTS (Standard Industry Checks)
45- # ------------------------------------------------------------------------
46- - name : Run Style & Syntax Check (Flake8)
47- run : |
48- echo "STEP 1: Checking for critical syntax errors..."
49- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
50-
51- echo "STEP 2: Checking for code style warnings..."
52- flake8 . --count --exit-zero --max-complexity=18 --max-line-length=127 --statistics
53-
54- # ------------------------------------------------------------------------
55- # PHASE 3: COMBINED TESTS (Generates both coverage and test results)
56- # ------------------------------------------------------------------------
57- - name : Run All Tests and Generate Reports
58- run : |
59- echo "--------------------------------------"
60- echo "GOAL: Generate coverage.xml and junit.xml"
61-
62- # This command runs all tests, generates XML coverage, and JUnit XML.
63- pytest --cov=. --cov-report=xml --junitxml=junit.xml -o junit_family=legacy tests/
64-
65- # ------------------------------------------------------------------------
66- # PHASE 4: CODECOV UPLOADS
67- # ------------------------------------------------------------------------
68- - name : Upload Coverage Report (XML)
69- uses : codecov/codecov-action@v4
70- with :
71- token : ${{ secrets.CODECOV_TOKEN }}
72- files : ./coverage.xml
73- fail_ci_if_error : true # It's good practice to fail if coverage upload fails.
74-
75- - name : Upload Test Results to Codecov (JUnit)
76- if : always() # This ensures test results are uploaded even if previous steps fail.
77- uses : codecov/test-results-action@v1
78- with :
79- token : ${{ secrets.CODECOV_TOKEN }}
80- files : ./junit.xml
81- # This step uploads test timing and failure data
0 commit comments