Skip to content

Commit 0a6f273

Browse files
committed
ci: provision pinned ScanCode tooling
1 parent 4baeba3 commit 0a6f273

5 files changed

Lines changed: 43 additions & 1 deletion

File tree

‎.github/workflows/_security.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ jobs:
2828
steps:
2929
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3030
- name: Install ScanCode Toolkit
31-
run: pipx install scancode-toolkit
31+
run: |
32+
CBM_CI_VENV="$RUNNER_TEMP/cbm-ci-venv" scripts/ci/install-python-tools.sh
33+
echo "$RUNNER_TEMP/cbm-ci-venv/bin" >> "$GITHUB_PATH"
3234
- name: "Gate self-test (a planted violation must be detected)"
3335
run: scripts/license-gate.sh --selftest
3436
- name: "License compliance gate (one finding fails)"

‎Jenkinsfile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ pipeline {
3636
'''
3737
}
3838
}
39+
stage('Install Python CI tools') {
40+
steps {
41+
sh 'CBM_CI_VENV="$WORKSPACE/.ci-venv" scripts/ci/install-python-tools.sh'
42+
}
43+
}
3944
stage('License gate') {
4045
steps {
4146
sh '''
4247
set -eu
48+
export PATH="$WORKSPACE/.ci-venv/bin:$PATH"
4349
scripts/license-gate.sh --selftest
4450
scripts/license-gate.sh
4551
scripts/audit-license-provenance.py

‎requirements-ci.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Python tooling required by repository CI gates.
2+
# Keep this separate from pkg/pypi/requirements-publish.txt: these packages are
3+
# CI analyzers, not runtime or registry-publishing dependencies.
4+
scancode-toolkit==32.5.0

‎scripts/ci/install-python-tools.sh‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
5+
VENV="${CBM_CI_VENV:-$ROOT/.ci-venv}"
6+
7+
command -v python3 >/dev/null 2>&1 || {
8+
echo "install-python-tools: python3 is required" >&2
9+
exit 2
10+
}
11+
12+
if [[ ! -x "$VENV/bin/python" ]]; then
13+
rm -rf "$VENV"
14+
python3 -m venv "$VENV" || {
15+
echo "install-python-tools: python3-venv is required" >&2
16+
exit 2
17+
}
18+
fi
19+
20+
"$VENV/bin/python" -m pip install \
21+
--disable-pip-version-check \
22+
--requirement "$ROOT/requirements-ci.txt"
23+
24+
echo "CI Python tools installed in $VENV"

‎tests/test_jenkins_artifact_contract.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ for required in \
88
"stage('Lint')" \
99
"stage('Memory lint')" \
1010
"stage('Security static')" \
11+
"stage('Install Python CI tools')" \
1112
"stage('License gate')" \
1213
"stage('Package wrappers')" \
1314
"stage('Thread sanitizer')" \
@@ -21,3 +22,8 @@ for required in \
2122
exit 1
2223
}
2324
done
25+
26+
grep -Fq 'requirements-ci.txt' "$root/scripts/ci/install-python-tools.sh" || {
27+
echo "missing CI Python requirements contract" >&2
28+
exit 1
29+
}

0 commit comments

Comments
 (0)