Skip to content

Commit e4a7b6f

Browse files
karlwaldmanclaude
andcommitted
ci: Add test pipeline and publish gate
Add CI test workflow (Python 3.9-3.12 matrix), weekly integration health check, and require tests pass before PyPI publish. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 82bfc48 commit e4a7b6f

File tree

3 files changed

+110
-3
lines changed

3 files changed

+110
-3
lines changed

.github/workflows/publish.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,43 @@ permissions:
88
contents: read
99

1010
jobs:
11+
test:
12+
name: Run Tests Before Publish
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -e '.[dev]'
26+
27+
- name: Lint with ruff
28+
run: ruff check .
29+
30+
- name: Run unit tests
31+
run: pytest tests/ -m 'not integration and not contract' --cov=oilpriceapi -v
32+
1133
publish:
1234
name: Publish to PyPI
35+
needs: test
1336
runs-on: ubuntu-latest
1437
environment: pypi
1538
permissions:
16-
id-token: write # Required for trusted publishing
39+
id-token: write # Required for trusted publishing
1740

1841
steps:
1942
- uses: actions/checkout@v4
2043

2144
- name: Set up Python
2245
uses: actions/setup-python@v5
2346
with:
24-
python-version: '3.12'
47+
python-version: "3.12"
2548

2649
- name: Install build dependencies
2750
run: |
@@ -32,4 +55,4 @@ jobs:
3255
run: python -m build
3356

3457
- name: Publish to PyPI
35-
uses: pypa/gh-action-pypi-publish@release/v1
58+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test Python SDK
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test (Python ${{ matrix.python-version }})
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.9", "3.10", "3.11", "3.12"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -e '.[dev]'
30+
31+
- name: Lint with ruff
32+
run: ruff check .
33+
34+
- name: Type check with mypy
35+
run: mypy oilpriceapi/ --ignore-missing-imports
36+
continue-on-error: true
37+
38+
- name: Run unit tests
39+
run: pytest tests/ -m 'not integration and not contract' --cov=oilpriceapi --cov-report=xml -v
40+
41+
- name: Upload coverage
42+
if: matrix.python-version == '3.12'
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: coverage-report
46+
path: coverage.xml
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Weekly SDK Health Check
2+
3+
on:
4+
schedule:
5+
- cron: "0 14 * * 1" # Monday 6am PST / 2pm UTC
6+
workflow_dispatch: {}
7+
8+
jobs:
9+
health-check:
10+
name: Integration Health Check
11+
runs-on: ubuntu-latest
12+
env:
13+
OILPRICEAPI_KEY: ${{ secrets.OILPRICEAPI_TEST_KEY }}
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -e '.[dev]'
27+
28+
- name: Run integration tests
29+
run: pytest tests/ -m 'integration' -v --timeout=60
30+
31+
- name: Run contract tests
32+
run: pytest tests/ -m 'contract' -v --timeout=60
33+
34+
- name: Check for dependency vulnerabilities
35+
run: |
36+
pip install pip-audit
37+
pip-audit --strict
38+
continue-on-error: true

0 commit comments

Comments
 (0)