Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/sbom-diff-and-risk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ The [examples/](examples/) directory includes:
- a Scorecard-aware policy example at `examples/policy-scorecard-minimal.yml`
- a sample pass JSON report at [sample-report.json](examples/sample-report.json)
- a sample summary-only JSON artifact at [sample-summary.json](examples/sample-summary.json)
- a consumer GitHub Actions workflow example at [github-actions-consumer.yml](examples/github-actions-consumer.yml)
- a sample pass Markdown report at [sample-report.md](examples/sample-report.md)
- sample policy-warn reports at [sample-policy-warn-report.json](examples/sample-policy-warn-report.json) and [sample-policy-warn-report.md](examples/sample-policy-warn-report.md)
- sample policy-fail reports at [sample-policy-fail-report.json](examples/sample-policy-fail-report.json) and [sample-policy-fail-report.md](examples/sample-policy-fail-report.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ an explicit local threshold to `summary.json`, and uploads the outputs as CI
artifacts.

Replace the placeholder input paths with files from the consumer repository.
The same workflow is also checked in as
[../examples/github-actions-consumer.yml](../examples/github-actions-consumer.yml)
for copying into consumer repositories.

```yaml
name: Dependency diff review
Expand Down
85 changes: 85 additions & 0 deletions tools/sbom-diff-and-risk/examples/github-actions-consumer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Example only.
# Copy this file into a consumer repository under .github/workflows/ if useful.
# This repository does not run this file as a workflow.
# Production PyPI publishing for sbom-diff-and-risk is intentionally deferred;
# install from a GitHub Release asset or local checkout instead.

name: Dependency diff review

on:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
dependency-diff:
runs-on: ubuntu-latest

steps:
- name: Check out consumer repository
uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.x"

- name: Download sbom-diff-and-risk release wheel
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p .tooling/sbom-diff-risk
gh release download v0.6.0 \
--repo stacknil/scientific-computing-toolkit \
--pattern "sbom_diff_and_risk-0.6.0-py3-none-any.whl" \
--dir .tooling/sbom-diff-risk

- name: Install sbom-diff-risk
run: |
python -m pip install \
.tooling/sbom-diff-risk/sbom_diff_and_risk-0.6.0-py3-none-any.whl

- name: Compare dependency evidence
run: |
mkdir -p outputs
sbom-diff-risk compare \
--before path/to/before-sbom.json \
--after path/to/after-sbom.json \
--format auto \
--out-json outputs/report.json \
--out-md outputs/report.md \
--summary-json outputs/summary.json \
--out-sarif outputs/report.sarif

- name: Apply local summary threshold
run: |
python - <<'PY'
import json
from pathlib import Path

summary = json.loads(
Path("outputs/summary.json").read_text(encoding="utf-8")
)
risk_counts = summary["risk_counts"]

max_new_packages = 2
new_package_count = risk_counts.get("new_package", 0)
print(f"new_package={new_package_count}")

if new_package_count > max_new_packages:
raise SystemExit(
f"new_package count exceeds local threshold: {max_new_packages}"
)
PY

- name: Upload dependency diff outputs
uses: actions/upload-artifact@v7
Comment on lines +77 to +78
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Upload artifacts even when threshold check fails

If new_package_count exceeds the threshold, the prior step exits non-zero, and this upload step is skipped because GitHub Actions applies a default success() condition to steps without an explicit status check. In that common policy-failure scenario, the workflow drops report.json, report.md, summary.json, and report.sarif, which prevents reviewers from inspecting the exact failure output; add an explicit condition such as if: ${{ always() }} (or !cancelled()) on the upload step to retain artifacts for failed runs.

Useful? React with 👍 / 👎.

with:
name: dependency-diff-outputs
path: |
outputs/report.json
outputs/report.md
outputs/summary.json
outputs/report.sarif