Add manual dispatch for scorecard.yml #67
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Regenerate Source | |
| # Most files under source/ are generated by scripts/json2src.py from the Mako | |
| # templates in scripts/templates/. They are committed, so the build never | |
| # regenerates them -- which means editing one directly instead of editing its | |
| # template appears to work right up until the next spec update discards the edit | |
| # and the build breaks. | |
| # | |
| # This job regenerates the sources from the specification metadata archived in | |
| # scripts/spec_metadata/ and then builds and tests the result. The gate is the | |
| # build and the tests: if a hand-edit that other code depends on is lost, the | |
| # regenerated tree fails to compile and this job fails. | |
| # | |
| # Textual drift on its own does NOT fail the job. Comment and doc-string wording | |
| # routinely differs after the spec is edited upstream, and failing on that would | |
| # train everyone to ignore this check. Drift is reported as inline annotations | |
| # and uploaded as an artifact instead. | |
| on: | |
| push: | |
| branches: [ master,release_branch* ] | |
| pull_request: | |
| branches: [ master,release_branch* ] | |
| workflow_dispatch: | |
| permissions: read-all | |
| jobs: | |
| regen-build-linux: | |
| if: github.repository_owner == 'oneapi-src' | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ubuntu:24.04 | |
| steps: | |
| - name: Install dependencies | |
| run: | | |
| apt-get update | |
| apt-get install -y build-essential cmake git python3 python3-pip | |
| # PEP 668 marks the distro interpreter as externally managed. | |
| # Floor kept in step with the spec repository's third_party/requirements.txt; | |
| # verified to produce byte-identical output from 1.3.3 through 1.3.11. | |
| pip3 install --break-system-packages "Mako>=1.3.3" | |
| - uses: actions/checkout@v5 | |
| - name: Regenerate sources from archived spec metadata | |
| run: python3 scripts/spec_metadata.py regen | |
| - name: Report drift (advisory) | |
| run: | | |
| # Git refuses to inspect a checkout owned by another user inside the | |
| # container; the workspace is trusted here. | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| git diff > regen.diff | |
| if [ ! -s regen.diff ]; then | |
| echo "No drift: committed sources match a regeneration of the archived metadata." | |
| exit 0 | |
| fi | |
| echo "::group::Regeneration diff" | |
| cat regen.diff | |
| echo "::endgroup::" | |
| # Annotate each drifting file. This is advisory only -- the build and | |
| # test steps below decide whether the job passes. | |
| git diff --name-only | while read -r f; do | |
| echo "::warning file=${f},line=1::Regenerating from the archived spec metadata changes this file. If the change here was hand-written, move it into the matching scripts/templates/*.mako template or it will be lost on the next spec update." | |
| done | |
| - name: Upload drift report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: regen-diff-linux | |
| path: regen.diff | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| - name: Build the regenerated tree | |
| run: | | |
| cmake -B build \ | |
| -D CMAKE_BUILD_TYPE=Release \ | |
| -D BUILD_L0_LOADER_TESTS=1 \ | |
| -D INSTALL_NULL_DRIVER=1 \ | |
| . | |
| if ! cmake --build build --parallel $(nproc); then | |
| echo "::error::The regenerated tree does not compile." | |
| echo "" | |
| echo "This almost always means a change was made directly to a generated" | |
| echo "file under source/ instead of to its template in scripts/templates/." | |
| echo "Regeneration discarded that change, so something that depended on it" | |
| echo "no longer builds." | |
| echo "" | |
| echo "Fix: move the change into the matching scripts/templates/*.mako" | |
| echo "template, then run 'python3 scripts/spec_metadata.py regen' and commit" | |
| echo "the regenerated files." | |
| exit 1 | |
| fi | |
| - name: Test the regenerated tree | |
| working-directory: build | |
| env: | |
| ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/lib' | |
| LD_LIBRARY_PATH: '${{ github.workspace }}/build/lib' | |
| run: ctest --output-on-failure | |
| regen-build-windows: | |
| if: github.repository_owner == 'oneapi-src' | |
| runs-on: [windows-latest] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install dependencies | |
| # See the Linux job for why this tracks the spec's requirements.txt. | |
| run: pip install "Mako>=1.3.3" | |
| - name: Setup Windows build environment | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Regenerate sources from archived spec metadata | |
| run: python3 scripts/spec_metadata.py regen | |
| - name: Report drift (advisory) | |
| shell: bash | |
| run: | | |
| git diff > regen.diff | |
| if [ ! -s regen.diff ]; then | |
| echo "No drift: committed sources match a regeneration of the archived metadata." | |
| exit 0 | |
| fi | |
| echo "::group::Regeneration diff" | |
| cat regen.diff | |
| echo "::endgroup::" | |
| - name: Build the regenerated tree | |
| shell: bash | |
| run: | | |
| cmake -B build -G "Ninja" -D CMAKE_BUILD_TYPE=Release -D BUILD_L0_LOADER_TESTS=1 . | |
| if ! cmake --build build; then | |
| echo "::error::The regenerated tree does not compile." | |
| echo "A change was likely made directly to a generated file under source/" | |
| echo "instead of to its template in scripts/templates/, and regeneration" | |
| echo "discarded it. Move the change into the template, run" | |
| echo "'python3 scripts/spec_metadata.py regen', and commit the result." | |
| exit 1 | |
| fi | |
| - name: Test the regenerated tree | |
| working-directory: build | |
| env: | |
| ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/bin' | |
| run: ctest --output-on-failure |