Skip to content

Commit c4fea79

Browse files
Zie619claude
andcommitted
ci: gate publish on tests, add Trivy scanning, docs deploy, and Codecov
TRU-342: Add test job as gate before PyPI publish in publish.yml TRU-343: Add Trivy vulnerability scanning to docker.yml (build→scan→push) TRU-344: Add docs.yml for auto-deploying mkdocs to GitHub Pages TRU-345: Add Codecov upload to ci.yml, replace static badge in README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1755f8a commit c4fea79

5 files changed

Lines changed: 109 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ jobs:
7474
run: |
7575
coverage report --fail-under=80
7676
77+
- name: Upload coverage to Codecov
78+
if: matrix.python-version == '3.12'
79+
uses: codecov/codecov-action@v5
80+
with:
81+
files: coverage.xml
82+
flags: ai-bom
83+
token: ${{ secrets.CODECOV_TOKEN }}
84+
fail_ci_if_error: false
85+
7786
security:
7887
runs-on: ubuntu-latest
7988
steps:

.github/workflows/docker.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,17 @@ on:
99
permissions:
1010
contents: read
1111
packages: write
12+
security-events: write
1213

1314
jobs:
14-
build-and-push:
15+
build-scan-push:
1516
runs-on: ubuntu-latest
1617
steps:
1718
- uses: actions/checkout@v6
1819

1920
- name: Set up Docker Buildx
2021
uses: docker/setup-buildx-action@v3
2122

22-
- name: Log in to GHCR
23-
uses: docker/login-action@v3
24-
with:
25-
registry: ghcr.io
26-
username: ${{ github.actor }}
27-
password: ${{ secrets.GITHUB_TOKEN }}
28-
2923
- name: Extract metadata
3024
id: meta
3125
uses: docker/metadata-action@v5
@@ -36,7 +30,47 @@ jobs:
3630
type=semver,pattern={{major}}.{{minor}}
3731
type=raw,value=latest
3832
39-
- name: Build and push
33+
- name: Build image (local)
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
load: true
38+
tags: ghcr.io/${{ github.repository }}:scan
39+
cache-from: type=gha
40+
cache-to: type=gha,mode=max
41+
42+
- name: Scan with Trivy
43+
uses: aquasecurity/trivy-action@master
44+
with:
45+
image-ref: ghcr.io/${{ github.repository }}:scan
46+
format: sarif
47+
output: trivy-results.sarif
48+
severity: CRITICAL,HIGH
49+
exit-code: 1
50+
continue-on-error: true
51+
id: trivy
52+
53+
- name: Upload Trivy SARIF
54+
uses: github/codeql-action/upload-sarif@v4
55+
if: always()
56+
with:
57+
sarif_file: trivy-results.sarif
58+
category: trivy
59+
60+
- name: Fail on critical vulnerabilities
61+
if: steps.trivy.outcome == 'failure'
62+
run: |
63+
echo "::error::Trivy found CRITICAL or HIGH vulnerabilities"
64+
exit 1
65+
66+
- name: Log in to GHCR
67+
uses: docker/login-action@v3
68+
with:
69+
registry: ghcr.io
70+
username: ${{ github.actor }}
71+
password: ${{ secrets.GITHUB_TOKEN }}
72+
73+
- name: Push image
4074
uses: docker/build-push-action@v6
4175
with:
4276
context: .

.github/workflows/docs.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'docs/**'
8+
- 'mkdocs.yml'
9+
- '.github/workflows/docs.yml'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
deploy:
17+
name: Deploy docs
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v6
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v6
26+
with:
27+
python-version: "3.12"
28+
cache: 'pip'
29+
30+
- name: Install dependencies
31+
run: pip install -e ".[docs]"
32+
33+
- name: Deploy to GitHub Pages
34+
run: mkdocs gh-deploy --force

.github/workflows/publish.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,29 @@ permissions:
1212
contents: read
1313

1414
jobs:
15+
test:
16+
name: Test before publish
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v6
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v6
23+
with:
24+
python-version: "3.12"
25+
cache: 'pip'
26+
27+
- name: Install dependencies
28+
run: pip install -e ".[dev]"
29+
30+
- name: Lint
31+
run: ruff check src/ tests/
32+
33+
- name: Run tests with coverage
34+
run: pytest -v --cov=ai_bom --cov-report=term-missing --cov-fail-under=80
35+
1536
publish:
37+
needs: [test]
1638
runs-on: ubuntu-latest
1739
environment: pypi
1840

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License" />
1717
<img src="https://img.shields.io/badge/CycloneDX-1.6-green.svg" alt="CycloneDX 1.6" />
1818
<img src="https://img.shields.io/badge/tests-651%20passing-brightgreen.svg" alt="Tests" />
19-
<img src="https://img.shields.io/badge/coverage-81%25-brightgreen.svg" alt="Coverage" />
19+
<a href="https://codecov.io/gh/Trusera/ai-bom"><img src="https://codecov.io/gh/Trusera/ai-bom/graph/badge.svg" alt="Coverage" /></a>
2020
<img src="https://img.shields.io/badge/PRs-welcome-orange.svg" alt="PRs Welcome" />
2121
</p>
2222
<h2 align="center">🎬 Demo</h2>

0 commit comments

Comments
 (0)