Skip to content

Commit 496e581

Browse files
Add on-demand SBOM generation workflow
- Adds `score_sbom` as a Bazel module dependency (via `git_override`) - Adds a root `reference_integration_sbom` Bazel target covering the core Rust showcase binaries (`//showcases/cli:cli`, `//showcases/orchestration_persistency:orch_per_example`) - Adds `.github/workflows/generate_sbom.yml` triggered only on `workflow_dispatch` (on-demand) What the workflow does: 1. Builds SPDX 2.3 + CycloneDX 1.6 SBOMs via `bazel build //:reference_integration_sbom` 2. Uploads both files as a GitHub Actions artifact (`sbom-<sha>`, retained 90 days) 3. Converts the SPDX output to GitHub Dependency Submission API format and submits it — enables Dependabot vulnerability alerts on the declared dependencies Workflow improvements over initial draft: - Use `astral-sh/setup-uv@v7.6.0` instead of `curl | sh` for reproducible, supply-chain-safe uv installation - Add `apt-get update` before `apt-get install` to prevent intermittent failures on rotating runner images - Invoke SPDX→snapshot converter via `bazel run @score_sbom//scripts:spdx_to_github_snapshot_bin` instead of reaching into Bazel's internal output_base directory; the required `py_binary` target is added in eclipse-score/sbom-tool#2 - Update header comment to accurately reflect that dependency snapshot submission always runs - Use absolute paths (`$GITHUB_WORKSPACE`) for bazel run invocations
1 parent 5b82931 commit 496e581

4 files changed

Lines changed: 1353 additions & 44 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
# SBOM Generation Workflow
14+
#
15+
# Summary:
16+
# Generates a Software Bill of Materials (SPDX 2.3 + CycloneDX 1.6) for the
17+
# core showcase Bazel targets and stores the results as a GitHub Actions
18+
# artifact. Submits the SPDX snapshot to the GitHub Dependency Submission API
19+
# to enable Dependabot vulnerability alerts.
20+
#
21+
# Triggers:
22+
# - workflow_dispatch (on-demand only)
23+
#
24+
# Outputs:
25+
# - Artifact "sbom-<sha>": reference_integration_sbom.spdx.json +
26+
# reference_integration_sbom.cdx.json (retained 90 days)
27+
# - GitHub Dependency Graph snapshot (enables Dependabot alerts per commit)
28+
#
29+
# Covered targets:
30+
# - //showcases/cli:cli
31+
# - //showcases/orchestration_persistency:orch_per_example
32+
name: Generate SBOM
33+
on:
34+
workflow_dispatch:
35+
jobs:
36+
sbom:
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: write # required for GitHub Dependency Submission API
40+
steps:
41+
- name: Clean disk space
42+
uses: eclipse-score/more-disk-space@v1
43+
- name: Checkout repository
44+
uses: actions/checkout@v4.2.2
45+
- name: Setup Bazel
46+
uses: bazel-contrib/setup-bazel@0.18.0
47+
with:
48+
bazelisk-cache: true
49+
disk-cache: ${{ github.workflow }}
50+
repository-cache: true
51+
cache-save: true
52+
- name: Install uv
53+
uses: astral-sh/setup-uv@v7.6.0
54+
- name: Install Java for Rust crate metadata
55+
run: |
56+
sudo apt-get update
57+
sudo apt-get install -y --no-install-recommends openjdk-11-jre-headless
58+
- name: Build SBOM
59+
run: bazel build --lockfile_mode=error //:reference_integration_sbom
60+
- name: Upload SBOM artifacts
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: sbom-${{ github.sha }}
64+
path: |
65+
bazel-bin/reference_integration_sbom.spdx.json
66+
bazel-bin/reference_integration_sbom.cdx.json
67+
retention-days: 90
68+
- name: Convert SPDX to GitHub Dependency snapshot
69+
run: |
70+
bazel run @score_sbom//scripts:spdx_to_github_snapshot_bin -- \
71+
--input "$GITHUB_WORKSPACE/bazel-bin/reference_integration_sbom.spdx.json" \
72+
--output "$GITHUB_WORKSPACE/snapshot.json" \
73+
--sha "${{ github.sha }}" \
74+
--ref "${{ github.ref }}" \
75+
--job-correlator "generate-sbom" \
76+
--job-id "${{ github.run_id }}"
77+
- name: Submit to GitHub Dependency Submission API
78+
uses: actions/github-script@v7
79+
with:
80+
script: |
81+
const fs = require('fs');
82+
const snapshot = JSON.parse(fs.readFileSync(process.env.GITHUB_WORKSPACE + '/snapshot.json', 'utf8'));
83+
await github.rest.dependencyGraph.createRepositorySnapshot({
84+
owner: context.repo.owner,
85+
repo: context.repo.repo,
86+
...snapshot,
87+
});

BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# *******************************************************************************
1313

1414
load("@score_docs_as_code//:docs.bzl", "docs")
15+
load("@score_sbom//:defs.bzl", "sbom")
1516
load("@score_tooling//:defs.bzl", "copyright_checker", "setup_starpls", "use_format_targets")
1617

1718
# Docs-as-code
@@ -69,3 +70,15 @@ exports_files([
6970
"MODULE.bazel",
7071
"pyproject.toml",
7172
])
73+
74+
# SBOM for core showcase targets
75+
sbom(
76+
name = "reference_integration_sbom",
77+
auto_crates_cache = True,
78+
component_name = "score_reference_integration",
79+
module_lockfiles = [":MODULE.bazel.lock"],
80+
targets = [
81+
"//showcases/cli:cli",
82+
"//showcases/orchestration_persistency:orch_per_example",
83+
],
84+
)

MODULE.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ git_override(
6060
remote = "https://github.com/bmw-software-engineering/trlc.git",
6161
)
6262

63+
# SBOM generation
64+
bazel_dep(name = "score_sbom")
65+
git_override(
66+
module_name = "score_sbom",
67+
commit = "1adca3f11116f3bfe7c41f7564d011011fba31df",
68+
remote = "https://github.com/eclipse-score/sbom-tool.git",
69+
)
70+
71+
sbom_ext = use_extension("@score_sbom//:extensions.bzl", "sbom_metadata")
72+
sbom_ext.track_module(name = "score_ref_int")
73+
use_repo(sbom_ext, "sbom_metadata")
74+
6375
# Currently required for ifs tooling
6476
bazel_dep(name = "score_toolchains_qnx", version = "0.0.7")
6577

0 commit comments

Comments
 (0)