-
Notifications
You must be signed in to change notification settings - Fork 76
Clone specific software-layer-commit and implement CI to check merged status #1353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7a52620
12c2bc7
dd37ed9
219bef9
218e75f
b8355bb
f9d1b7d
2cd6082
6d954c4
36f7541
f1fdcca
c4b1f9a
20d8bd2
0494884
72fbb29
1530fca
cc18733
77167ac
bce9bbc
bee1d29
2c752d2
6d2714e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| # documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions | ||
| # | ||
| # This workflow verifies that the correct version of software-layer-scripts is used. | ||
| # | ||
| # First, check_bot_build_checksums checks if the bot/build.sh code that clones software-layer-scripts is untouched, | ||
| # as this normally shouldn't change (a change could mean a contributor is trying to inject something | ||
| # malicious). Having this CI means that a change in bot/build.sh should at least be accompanied by | ||
| # a change in this CI, making it stand out to reviewers and increasing the likelihood of this being caught. | ||
| # | ||
| # Second, check-software_layer_scripts_commit checks if the commit used in bot/commit_sha is a merge-commit for a | ||
| # merge into the default branch of software-layer-scripts. This guarantees that everything that is associated with | ||
| # that commit was approved by a reviewer (and deployed, if needed) | ||
| name: Verify software-layer-scripts | ||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| workflow_dispatch: | ||
| permissions: | ||
| contents: read # to fetch code (actions/checkout) | ||
| jobs: | ||
| check_bot_build_checksum: | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Check out software-layer repository (shallow) | ||
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
| with: | ||
| fetch-depth: 1 # We only need the current revision to read bot/commit_sha | ||
|
|
||
| - name: Compute bot/build.sh checksum and verify it | ||
| run: | | ||
| # Print clear error if file doesn't exist at all | ||
| if [[ ! -f bot/build.sh ]]; then | ||
| echo "ERROR: File bot/build.sh not found!" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Reference checksum | ||
| # UPDATE THIS CHECKSUM IF AND ONLY IF WE ACTUALLY WANT TO CHANGE bot/build.sh | ||
| EXPECTED_CHECKSUM="9d33368cac2e38e10147eeb0aafc321651ebaa5912387ecef97683570906773a" | ||
|
|
||
| # Compute checksum | ||
| COMPUTED_CHECKSUM=$(sha256sum bot/build.sh | awk '{print $1}') | ||
| echo "Computed checksum: $COMPUTED_CHECKSUM" | ||
| echo "Reference checksum: $EXPECTED_CHECKSUM" | ||
|
|
||
| # Compare checksums | ||
| if [[ "$COMPUTED_CHECKSUM" != "$EXPECTED_CHECKSUM" ]]; then | ||
| echo "ERROR: Checksum mismatch! The file bot/build.sh has been modified." | ||
| exit 1 | ||
| else | ||
| echo "Checksum for bot/build.sh matches the reference value" | ||
| fi | ||
| check_software_layer_scripts_commit: | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Check out software-layer repository (shallow) | ||
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
| with: | ||
| fetch-depth: 1 # We only need the current revision to read bot/commit_sha | ||
| - name: Checkout software-layer-scripts (full history) | ||
| uses: actions/checkout@v4 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should also use specific commit, as above |
||
| with: | ||
| repository: EESSI/software-layer-scripts | ||
| path: upstream-scripts | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why make it difficult, just call this |
||
| fetch-depth: 0 # full history → required for ancestry checks | ||
|
|
||
| - name: Read commit SHA | ||
| id: read_sha | ||
| run: | | ||
| SHA=$(cat bot/commit_sha | tr -d '[:space:]') | ||
| echo "sha=$SHA" >> $GITHUB_OUTPUT | ||
| echo "Found SHA: $SHA" | ||
|
|
||
| - name: Verify SHA exists in software‑layer‑scripts | ||
| working-directory: upstream-scripts | ||
| run: | | ||
| SHA="${{ steps.read_sha.outputs.sha }}" | ||
|
|
||
| echo "Checking out commit ${SHA} from software-layer-scripts" | ||
| git fetch --depth=1 origin ${SHA} | ||
| git checkout --detach ${SHA} | ||
|
|
||
| # Validate that this object is _actually_ a commit | ||
| if ! git cat-file -e "${SHA}^{commit}" 2>/dev/null; then | ||
| echo "Commit $SHA not found in software‑layer‑scripts." | ||
| exit 1 | ||
| fi | ||
| echo "Commit $SHA exists in software‑layer‑scripts." | ||
|
|
||
| - name: Check that SHA is merged into the default branch | ||
| working-directory: upstream-scripts | ||
| run: | | ||
| SHA="${{ steps.read_sha.outputs.sha }}" | ||
|
|
||
| # git merge‑base --is‑ancestor returns 0 if $SHA is an ancestor of origin/main | ||
| if git merge-base --is-ancestor "$SHA" origin/main; then | ||
| echo "Commit $SHA is merged into origin/main." | ||
| else | ||
| echo "Commit $SHA is NOT merged into origin/main." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Verify commit is signed by GitHub’s web‑flow key | ||
| working-directory: upstream-scripts | ||
| env: | ||
| GIT_TRACE: 1 # extra debug output if something goes wrong | ||
| run: | | ||
| SHA="${{ steps.read_sha.outputs.sha }}" | ||
|
|
||
| # Import the public key that GitHub uses for UI‑generated merges | ||
| echo "Importing GitHub web‑flow GPG key…" | ||
| curl -sSfL https://github.com/web-flow.gpg | gpg --dearmor > web-flow.gpg | ||
| gpg --import web-flow.gpg | ||
| # (optional) show the fingerprint for debugging | ||
| echo "Fingerprint of the web-flow GPG key:" | ||
| gpg --list-keys --fingerprint | grep -i "web-flow" -A1 | ||
|
|
||
| # Verify the commit’s GPG signature | ||
| echo "Verifying the signature of commit $SHA…" | ||
| if git verify-commit "$SHA"; then | ||
| echo "Commit $SHA is signed and the signature validates with the web‑flow key." | ||
| echo "All verification steps succeeded." | ||
| else | ||
| echo "Commit $SHA is either unsigned or not signed by the web‑flow key." | ||
| exit 1 | ||
| fi | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,19 @@ | |||||
| # give up as soon as any error occurs | ||||||
| set -e | ||||||
|
|
||||||
| git clone https://github.com/EESSI/software-layer-scripts | ||||||
| TOPDIR=$(dirname $(realpath $0)) | ||||||
|
|
||||||
| # Clone a the commit from software-layer-script that corresponds to `bot/commit_sha` | ||||||
| commit_sha=$(cat ${TOPDIR}/commit_sha) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rename this file so it's clear from the filename what this refers to:
Suggested change
|
||||||
|
|
||||||
| # Get a shallow clone first | ||||||
| git clone --depth 1 --filter=blob:none --no-checkout https://github.com/EESSI/software-layer-scripts | ||||||
|
|
||||||
| # Fetch the relevant commit & check it out | ||||||
| cd software-layer-scripts | ||||||
| git fetch --depth=1 origin ${commit_sha} | ||||||
| git checkout --detach ${commit_sha} | ||||||
| cd .. | ||||||
|
|
||||||
| # symlink everything, except for: | ||||||
| # - common files like LICENSE and README.md | ||||||
|
|
||||||
casparvl marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| f5c45bf7810eb83d2f13e7d94260772cbe5b484d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be toned down, changing the
bot/build.shscript doesn't necessarily imply that something malicious is going on.It's weird/unusual, sure, but let's not brand every possible change to
bot/build.shscript as malicious up frontThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's especially ironic that this very PR is also making changes to
bot/build.sh;-)