Skip to content

Commit 554fbc6

Browse files
authored
Fix SBOM commands to be suitable for running in CI (#52849)
There were a couple of problems that prevented the SBOM generation to successfully run in our workflows: * remote_name was hard-coded to "apache" for locally pulling tags from the right remote - and we did not have that remote in CI * python parameter was set by default to "default_python_version" in CI, and what we really wanted is to have it empty to use all historical versions of python * generating SBOMs used the "ref" version of breeze rather than "current PR version" of breeze. * python version installed was the default python version that was used in the "reference" of built docs - not the "current" default version - which made it impossible to reinstall breeze to current version when old version of Python was not supported any more * When RC version SBOM was generated, it did not use RC constraints and tags so, all SBOMS were silently skipped. This is fixed by: * you can now pass remote-name as option * historical_python_versions click option now uses --python-versions and PYTHON_VERSIONS envvar and can take list of versions separated by comas - to not confuse it with regular --python option * switching temporarily to the "current-version" of breeze when generating SBOM * we are installing breeze with "current" default python version - assuming that this version will be supported by any versions of packages we want to build the documentation for * when RC version is passed as ref, we are using RC version of constraints and tags but we still produce sboms for "base" version - matching the way how documentation is done.
1 parent 8f8ddf8 commit 554fbc6

15 files changed

+333
-239
lines changed

.github/workflows/publish-docs-to-s3.yml

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ on: # yamllint disable-line rule:truthy
5050
build-sboms:
5151
description: "Build SBOMs"
5252
required: false
53-
default: 'false'
54-
type: string
53+
default: false
54+
type: boolean
5555

5656
permissions:
5757
contents: read
@@ -74,9 +74,11 @@ jobs:
7474
destination-location: ${{ steps.parameters.outputs.destination-location }}
7575
destination: ${{ steps.parameters.outputs.destination }}
7676
extra-build-options: ${{ steps.parameters.outputs.extra-build-options }}
77+
airflow-base-version: ${{ steps.parameters.outputs.airflow-base-version }}
7778
airflow-version: ${{ steps.parameters.outputs.airflow-version }}
7879
# yamllint disable rule:line-length
7980
skip-write-to-stable-folder: ${{ inputs.skip-write-to-stable-folder && '--skip-write-to-stable-folder' || '' }}
81+
default-python-version: "3.10"
8082
if: contains(fromJSON('[
8183
"ashb",
8284
"eladkal",
@@ -116,10 +118,13 @@ jobs:
116118
echo "destination-location=s3://staging-docs-airflow-apache-org/docs/" >> ${GITHUB_OUTPUT}
117119
fi
118120
if [[ " ${INCLUDE_DOCS} " =~ " apache-airflow " ]]; then
119-
AIRFLOW_VERSION=$(echo "${REF}" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
121+
AIRFLOW_BASE_VERSION=$(echo "${REF}" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
122+
AIRFLOW_VERSION="${REF}"
123+
echo "airflow-base-version=${AIRFLOW_BASE_VERSION}" >> ${GITHUB_OUTPUT}
120124
echo "airflow-version=${AIRFLOW_VERSION}" >> ${GITHUB_OUTPUT}
121125
else
122126
echo "airflow-version=no-airflow" >> ${GITHUB_OUTPUT}
127+
echo "airflow-base-version=no-airflow" >> ${GITHUB_OUTPUT}
123128
fi
124129
125130
build-docs:
@@ -132,14 +137,12 @@ jobs:
132137
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133138
GITHUB_USERNAME: ${{ github.actor }}
134139
INCLUDE_SUCCESS_OUTPUTS: false
135-
PYTHON_MAJOR_MINOR_VERSION: 3.10
136140
VERBOSE: "true"
137141
EXTRA_BUILD_OPTIONS: ${{ needs.build-info.outputs.extra-build-options }}
138142
steps:
139143
- name: "Cleanup repo"
140144
shell: bash
141145
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
142-
# Check out the repo first to run cleanup - in sub-folder
143146
- name: "Checkout current version first to clean-up stuff"
144147
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
145148
with:
@@ -158,34 +161,69 @@ jobs:
158161
ref: ${{ inputs.ref }}
159162
fetch-depth: 0
160163
fetch-tags: true
161-
- name: "Install Breeze"
164+
- name: "Install Breeze from the ${{ inputs.ref }} reference"
162165
uses: ./.github/actions/breeze
163166
with:
164167
use-uv: ${{ inputs.use-uv }}
165-
- name: "Building docs with --docs-only flag"
168+
python-version: "${{ needs.build-info.outputs.default-python-version }}"
169+
- name: "Building image from the ${{ inputs.ref }} reference"
170+
env:
171+
INCLUDE_DOCS: ${{ needs.build-info.outputs.include-docs }}
172+
INCLUDE_COMMITS: ${{ startsWith(inputs.ref, 'providers') && 'true' || 'false' }}
173+
run: >
174+
breeze ci-image build
175+
- name: "Building docs with --docs-only flag using ${{ inputs.ref }} reference breeze"
166176
env:
167177
INCLUDE_DOCS: ${{ needs.build-info.outputs.include-docs }}
168178
INCLUDE_COMMITS: ${{ startsWith(inputs.ref, 'providers') && 'true' || 'false' }}
169179
run: >
170180
breeze build-docs ${INCLUDE_DOCS} --docs-only
171-
- name: "Build SBOMS"
181+
- name: "Checkout current version to run SBOM generation"
182+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
183+
with:
184+
persist-credentials: false
185+
fetch-depth: 0
186+
fetch-tags: true
187+
path: current-version
188+
if: inputs.build-sboms
189+
- name: "Reinstall breeze from the current version"
190+
run: |
191+
breeze setup self-upgrade --use-current-airflow-sources
192+
working-directory: current-version
193+
- name: "Make sure SBOM dir exists and has the right permissions"
194+
run: |
195+
sudo mkdir -vp ./files/sbom
196+
sudo chown -R "${USER}" .
197+
working-directory: current-version
198+
if: inputs.build-sboms
199+
- name: "Prepare SBOMs using current version of Breeze"
172200
env:
173201
AIRFLOW_VERSION: ${{ needs.build-info.outputs.airflow-version }}
174202
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
175203
PYTHON_VERSION: "${{ needs.build-info.outputs.default-python-version }}"
176204
FORCE: "true"
177205
run: >
178-
breeze sbom update-sbom-information --airflow-version ${AIRFLOW_VERSION}
206+
breeze sbom update-sbom-information
207+
--airflow-version ${AIRFLOW_VERSION} --remote-name origin --force
179208
--all-combinations --run-in-parallel --airflow-root-path "${GITHUB_WORKSPACE}"
180-
if: inputs.build-sboms == 'true'
209+
working-directory: current-version
210+
if: inputs.build-sboms
211+
- name: "Generated SBOM files"
212+
run: |
213+
echo "Generated SBOM files:"
214+
find ./generated/_build/docs/apache-airflow/stable/sbom/ -type f | sort
215+
- name: "Reinstall breeze from ${{ inputs.ref }} reference"
216+
run:
217+
breeze setup self-upgrade --use-current-airflow-sources
218+
if: inputs.build-sboms
181219
- name: Check disk space available
182220
run: df -H
183221
# Here we will create temp airflow-site dir to publish docs
184222
- name: Create /mnt/airflow-site directory
185223
run: |
186224
sudo mkdir -p /mnt/airflow-site && sudo chown -R "${USER}" /mnt/airflow-site
187225
echo "AIRFLOW_SITE_DIRECTORY=/mnt/airflow-site/" >> "$GITHUB_ENV"
188-
- name: "Publish docs to /mnt/airflow-site directory"
226+
- name: "Publish docs to /mnt/airflow-site directory using ${{ inputs.ref }} reference breeze"
189227
env:
190228
INCLUDE_DOCS: ${{ needs.build-info.outputs.include-docs }}
191229
run: >

0 commit comments

Comments
 (0)