-
-
Notifications
You must be signed in to change notification settings - Fork 76
Various CI improvements suggested by zizmor #2139
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
Open
bjorn3
wants to merge
12
commits into
pendulum-project:main
Choose a base branch
from
bjorn3:safer_ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3003896
Use the least amount of privileges possible for each CI workflow
bjorn3 fdc299e
Remove unnecessary docker workflow trigger
bjorn3 b32d9f9
Explain why add-prs-to-project is safe
bjorn3 0c92f6d
Remove cache from the packaging workflow
bjorn3 210c9b9
Use gh cli for commit verified check
bjorn3 1450cf7
Use gh cli for creating draft release
bjorn3 df59948
Add zizmor config
bjorn3 3fa4c15
Ignore template-injection that only a maintainer can do
bjorn3 c89daf4
Use persist-credentials: false
bjorn3 01a85d6
Use shell expansion for RELEASE_VERSION
bjorn3 11f0d80
Add dependency update cooldown
bjorn3 98365b3
Run zizmor on CI
bjorn3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,6 @@ | ||||||
| name: packaging | ||||||
|
|
||||||
| permissions: | ||||||
| contents: read | ||||||
| permissions: {} | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
|
|
@@ -21,10 +20,8 @@ jobs: | |||||
| - i686-unknown-linux-gnu | ||||||
| steps: | ||||||
| - name: Setup packaging tools for cross compiled artifacts | ||||||
| uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0 | ||||||
|
Member
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. @rnijveld was there a specific reason we used caching here? |
||||||
| with: | ||||||
| packages: musl-tools qemu-user-static crossbuild-essential-armhf crossbuild-essential-arm64 crossbuild-essential-i386 | ||||||
| version: 1 | ||||||
| run: | | ||||||
| sudo apt install --update musl-tools qemu-user-static crossbuild-essential-armhf crossbuild-essential-arm64 crossbuild-essential-i386 | ||||||
davidv1992 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| - name: Install toolchain | ||||||
| uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 | ||||||
|
|
@@ -39,6 +36,8 @@ jobs: | |||||
|
|
||||||
| - name: Checkout sources | ||||||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | ||||||
| with: | ||||||
| persist-credentials: false | ||||||
|
|
||||||
| - name: Build the release binaries | ||||||
| run: RELEASE_TARGETS="${{ matrix.target }}" utils/build-release.sh | ||||||
|
|
@@ -85,6 +84,8 @@ jobs: | |||||
| steps: | ||||||
| - name: Checkout sources | ||||||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||||||
| with: | ||||||
| persist-credentials: false | ||||||
|
|
||||||
| - name: Download artifacts | ||||||
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 | ||||||
|
|
@@ -99,17 +100,16 @@ jobs: | |||||
| components: "llvm-tools" | ||||||
|
|
||||||
| - name: Check that the release commit is verified | ||||||
| env: | ||||||
| GH_TOKEN: ${{ github.token }} | ||||||
| run: | | ||||||
| commit_url="${{ github.api_url }}/repos/${{ github.repository }}/commits/${{ github.sha }}" | ||||||
| json_accept_header="Accept: application/vnd.github+json" | ||||||
| auth_bearer_header="Authorization: Bearer ${{ github.token }}" | ||||||
| test "$(curl -sf -H "$json_accept_header" -H "$auth_bearer_header" "$commit_url" | jq .commit.verification.verified)" == "true" | ||||||
| test "$(gh api "repos/${{ github.repository }}/commits/${{ github.sha }}" --jq .commit.verification.verified)" == "true" | ||||||
|
|
||||||
| - name: Read the version from the manifest file | ||||||
| run: echo "release_version=$(cargo read-manifest --manifest-path ntpd/Cargo.toml | jq -r .version)" >> "$GITHUB_ENV" | ||||||
|
|
||||||
| - name: Version in Cargo.toml must match the branch name | ||||||
| run: test "release/$release_version" == "${{ github.ref_name }}" | ||||||
| run: test "release/$release_version" == "${{ github.ref_name }}" # zizmor: ignore[template-injection] attacker can't push to arbitrary branch on our repo | ||||||
|
|
||||||
| - name: Ensure there is not already a released tag with a non-draft release | ||||||
| run: test "$(gh release view "v$release_version" --json isDraft --jq .isDraft 2>/dev/null || echo "true")" == "true" | ||||||
|
|
@@ -124,21 +124,14 @@ jobs: | |||||
| release_notes_body="${release_notes_body%"${release_notes_body##*[![:space:]]}"}" | ||||||
| release_notes_version="$(echo "$release_notes_header" | cut -d' ' -f2 | sed 's/[][]//g')" | ||||||
| echo "Found version '$release_notes_version' in release notes" | ||||||
| test "$release_notes_version" == "${{ env.release_version }}" | ||||||
| { | ||||||
| echo "release_notes_body<<RELEASE_NOTES_EOF" | ||||||
| echo "$release_notes_body" | ||||||
| echo RELEASE_NOTES_EOF | ||||||
| } >> "$GITHUB_ENV" | ||||||
|
|
||||||
| - name: Create a draft release | ||||||
| uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 | ||||||
| with: | ||||||
| draft: true | ||||||
| fail_on_unmatched_files: true | ||||||
| tag_name: "v${{ env.release_version }}" | ||||||
| target_commitish: "${{ github.sha }}" | ||||||
| name: "Version ${{ env.release_version }}" | ||||||
| files: target/pkg/* | ||||||
| body: "${{ env.release_notes_body }}" | ||||||
| test "$release_notes_version" == "${release_version}" | ||||||
| echo "$release_notes_body" > release_notes.md | ||||||
|
|
||||||
| - name: Create release | ||||||
|
Member
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. I think this should keep the original title.
Suggested change
|
||||||
| env: | ||||||
| GH_TOKEN: ${{ github.token }} | ||||||
| run: | | ||||||
| gh release create "v${release_version}" --draft \ | ||||||
| --target "${{ github.sha }}" \ | ||||||
| --title "Version ${release_version}" \ | ||||||
| --notes-file release_notes.md target/pkg/* | ||||||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: zizmor | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["**"] | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| zizmor: | ||
| name: Run zizmor | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| security-events: write # Required for upload-sarif (used by zizmor-action) to upload SARIF files. | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Run zizmor | ||
| uses: zizmorcore/zizmor-action@0dce2577a4760a2749d8cfb7a84b7d5585ebcb7d # v0.5.0 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| rules: | ||
| cache-poisoning: | ||
| ignore: | ||
| - checks.yaml # this workflow doesn't produce any release artifacts | ||
| - docker.yaml # only executed by a maintainer and built images not used in production |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@rnijveld I think we dont use this, but am not a 100% sure.