Skip to content

Commit 4180f3e

Browse files
committed
ci: upgrade to comprehensive CI/CD pipeline
- Add concurrency control to cancel in-progress runs - Add dependency-review job for PR security scanning - Split test and lint into separate parallel jobs - Add coverage-gate job to enforce minimum coverage - Enable pip caching for faster builds - Upload coverage reports to Codecov - Use fail-fast: false for complete matrix results Refs: gemmology-dev/cdl-parser
1 parent 49ea2af commit 4180f3e

1 file changed

Lines changed: 83 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,30 @@ on:
66
pull_request:
77
branches: [main]
88

9+
# Cancel in-progress runs for the same branch
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
914
jobs:
15+
# Dependency review for PRs (security check)
16+
dependency-review:
17+
if: github.event_name == 'pull_request'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Dependency Review
22+
uses: actions/dependency-review-action@v4
23+
with:
24+
fail-on-severity: high
25+
# Deny licenses that are incompatible with MIT
26+
deny-licenses: GPL-3.0, AGPL-3.0
27+
28+
# Test across Python versions
1029
test:
1130
runs-on: ubuntu-latest
1231
strategy:
32+
fail-fast: false
1333
matrix:
1434
python-version: ['3.10', '3.11', '3.12']
1535

@@ -20,16 +40,72 @@ jobs:
2040
uses: actions/setup-python@v5
2141
with:
2242
python-version: ${{ matrix.python-version }}
43+
cache: 'pip'
2344

2445
- name: Install dependencies
25-
run: |
26-
pip install -e ".[dev]"
46+
run: pip install -e ".[dev]"
47+
48+
- name: Run tests with coverage
49+
run: pytest --cov=src/cdl_parser --cov-report=xml --cov-report=term-missing -v
50+
51+
- name: Upload coverage to Codecov
52+
if: matrix.python-version == '3.11'
53+
uses: codecov/codecov-action@v4
54+
with:
55+
files: ./coverage.xml
56+
flags: cdl-parser
57+
name: cdl-parser-py311
58+
fail_ci_if_error: false
59+
token: ${{ secrets.CODECOV_TOKEN }}
60+
61+
# Lint and type check
62+
lint:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
67+
- name: Set up Python
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: '3.11'
71+
cache: 'pip'
72+
73+
- name: Install dependencies
74+
run: pip install ruff mypy
75+
76+
- name: Lint with Ruff
77+
run: ruff check . --output-format=github
2778

28-
- name: Lint
29-
run: ruff check .
79+
- name: Check formatting with Ruff
80+
run: ruff format --check .
3081

31-
- name: Type check
82+
- name: Type check with mypy
3283
run: mypy src/
3384

34-
- name: Test
35-
run: pytest --cov
85+
# Coverage gate - enforce minimum coverage
86+
coverage-gate:
87+
needs: [test]
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v4
91+
92+
- name: Set up Python
93+
uses: actions/setup-python@v5
94+
with:
95+
python-version: '3.11'
96+
cache: 'pip'
97+
98+
- name: Install dependencies
99+
run: |
100+
pip install pytest pytest-cov
101+
pip install -e .
102+
103+
- name: Check coverage threshold
104+
# Target: 80%, Current threshold: 60% (incrementally increasing)
105+
run: pytest --cov=src/cdl_parser --cov-report=term-missing --cov-fail-under=60
106+
107+
- name: Coverage report
108+
run: |
109+
echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY
110+
echo "" >> $GITHUB_STEP_SUMMARY
111+
echo "Current threshold: **60%** (Target: 80%)" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)