Skip to content

Commit 6200b70

Browse files
fix: reverted pipeline check implementation (#2102)
1 parent 51b34ce commit 6200b70

1 file changed

Lines changed: 13 additions & 61 deletions

File tree

.github/workflows/tests.yml

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
workflow_dispatch:
55
push:
66
branches: [main, dev, demo]
7+
paths:
8+
- 'code/**'
9+
- 'pyproject.toml'
10+
- 'package.json'
11+
- 'pytest.ini'
12+
- '.github/workflows/tests.yml'
713
pull_request:
814
branches: [main, dev, demo]
915
types:
@@ -15,61 +21,22 @@ on:
1521
merge_group:
1622

1723
jobs:
18-
check-changes:
24+
test_package:
25+
name: Tests
1926
runs-on: ubuntu-latest
20-
outputs:
21-
backend_changed: ${{ steps.filter.outputs.backend }}
22-
frontend_changed: ${{ steps.filter.outputs.frontend }}
2327
steps:
2428
- uses: actions/checkout@v6
25-
with:
26-
fetch-depth: 0
27-
28-
- name: Check for relevant changes
29-
id: filter
30-
uses: dorny/paths-filter@v3
31-
with:
32-
filters: |
33-
backend:
34-
- 'code/backend/**'
35-
- 'code/app.py'
36-
- 'code/create_app.py'
37-
- 'code/tests/**'
38-
- 'pyproject.toml'
39-
- 'pytest.ini'
40-
- '.github/workflows/tests.yml'
41-
frontend:
42-
- 'code/frontend/**'
43-
- 'package.json'
44-
- '.github/workflows/tests.yml'
45-
46-
- name: Log detected changes
47-
run: |
48-
echo "Backend changed: ${{ steps.filter.outputs.backend }}"
49-
echo "Frontend changed: ${{ steps.filter.outputs.frontend }}"
50-
51-
python-tests:
52-
name: Python Tests
53-
needs: check-changes
54-
if: needs.check-changes.outputs.backend_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call'
55-
runs-on: ubuntu-latest
56-
steps:
57-
- uses: actions/checkout@v6
58-
5929
- name: Install Poetry
6030
run: pip install poetry
61-
6231
- name: Setup python
6332
uses: actions/setup-python@v6
6433
with:
6534
python-version: "3.11"
6635
architecture: x64
6736
cache: 'poetry'
68-
6937
- name: Install dependencies through poetry
7038
run: |
7139
poetry install
72-
7340
- name: Get coverage artifact ID
7441
id: coverage-artifact
7542
uses: actions/github-script@v8
@@ -97,32 +64,28 @@ jobs:
9764
return workflowRuns.data.workflow_runs[0]?.id ?? "";
9865
result-encoding: string
9966
retries: 3
100-
10167
- name: Download main coverage artifact
10268
uses: actions/download-artifact@v7
10369
if: github.event_name == 'pull_request' && steps.coverage-artifact.outputs.result != ''
104-
continue-on-error: true
70+
continue-on-error: true # There is a chance that the artifact doesn't exist, or has expired
10571
with:
10672
name: coverage
10773
path: "${{ github.workspace }}/coverage-main"
10874
github-token: ${{ secrets.GITHUB_TOKEN }}
10975
run-id: ${{ steps.coverage-artifact.outputs.result }}
110-
11176
- name: Get coverage from main
11277
id: coverage-value
11378
run: |
11479
MIN_COVERAGE=0
11580
11681
if [[ -f "./coverage-main/coverage.xml" ]]; then
117-
MIN_COVERAGE=$(grep -m 1 "<coverage" "./coverage-main/coverage.xml" | sed -E 's/.*line-rate="([^"]*)".*/\1/')
118-
MIN_COVERAGE=$(awk "BEGIN {print int($MIN_COVERAGE * 100)}")
82+
MIN_COVERAGE=$(grep -m 1 "<coverage" "./coverage-main/coverage.xml" | sed -E 's/.*line-rate="([^"]*)".*/\1/') # Extract the line rate from the XML
83+
MIN_COVERAGE=$(awk "BEGIN {print int($MIN_COVERAGE * 100)}") # Turn into percentage, rounding down to avoid rounding issues
11984
fi
12085
12186
echo "MIN_COVERAGE=$MIN_COVERAGE" >> "$GITHUB_OUTPUT"
122-
12387
- name: Run Python Tests
12488
run: make python-test optional_args="--junitxml=coverage-junit.xml --cov=code --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=${{ steps.coverage-value.outputs.MIN_COVERAGE }} ./code/tests"
125-
12689
- uses: actions/upload-artifact@v6
12790
if: ${{ !cancelled() }}
12891
with:
@@ -131,24 +94,13 @@ jobs:
13194
coverage-junit.xml
13295
coverage.xml
13396
if-no-files-found: error
134-
135-
- name: Lint
136-
run: make lint
137-
138-
frontend-tests:
139-
name: Frontend Tests
140-
needs: check-changes
141-
if: needs.check-changes.outputs.frontend_changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call'
142-
runs-on: ubuntu-latest
143-
steps:
144-
- uses: actions/checkout@v6
145-
14697
- name: Setup node
14798
uses: actions/setup-node@v6
14899
with:
149100
node-version: 20
150101
cache: "npm"
151102
cache-dependency-path: "code/frontend/package-lock.json"
152-
153103
- name: Run frontend unit tests
154104
run: make unittest-frontend
105+
- name: Lint
106+
run: make lint

0 commit comments

Comments
 (0)