Skip to content
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

Fix dry run workflow for PR from forks #1681

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions .github/workflows/dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:
rustup default stable
rustc -vV

- uses: Swatinem/rust-cache@v2
# Pinning a specific version to avoid surprises
- uses: Swatinem/rust-cache@27b8ea9368cf428f0bfe41b0876b1a7e809d9844
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might also want to pin this action in other workflows


- name: Download built JSON API
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -134,8 +135,8 @@ jobs:
run: |
# Perform build and execution separately to avoid any potential output from
# cargo leaking into the output file.
cargo build
./target/debug/sync-team print-plan --services github --team-json team-api > output.txt
cargo build --release
./target/release/sync-team print-plan --services github --team-json team-api > output.txt

- name: Prepare comment
run: |
Expand All @@ -149,11 +150,24 @@ jobs:

cat comment.txt

- name: Extract PR number
run: |
# We read the PR number that is stored in the uploaded archive
# and check that it is an integer (as the workflow could upload whatever it wants).
UNSANITIZED_PR=`cat team-api/pr.txt`
if [[ ${UNSANITIZED_PR} =~ ^[0-9]+$ ]]; then
echo "PR_NUMBER=${UNSANITIZED_PR}" >> $GITHUB_ENV
else
echo "Invalid PR number passed: ${UNSANITIZED_PR}"
exit 1
fi

- name: Send comment
env:
GH_TOKEN: ${{ github.token }}
run: |
PR=${{ github.event.workflow_run.pull_requests[0].number }}
PR=${PR_NUMBER}
echo "Pull request ${PR}"

# --edit-last doesn't work if there is no previous comment, so we have to figure out
# if we should create a comment or not
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jobs:
cargo run -- static-api build
echo "team-api.infra.rust-lang.org" > build/CNAME

- name: Write PR number into the uploaded archive
if: ${{ github.event_name == 'pull_request' }}
run: echo "${{ github.event.pull_request.number }}" > build/pr.txt

- name: Upload the built JSON as a GitHub artifact
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
Expand Down