From 1261e0564f4bf373afa44527aacf851fdf510aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 6 Mar 2025 12:20:19 +0100 Subject: [PATCH 1/3] Pin version of the `rust-cache` action --- .github/workflows/dry-run.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dry-run.yml b/.github/workflows/dry-run.yml index 7c78218fc..70cccacb4 100644 --- a/.github/workflows/dry-run.yml +++ b/.github/workflows/dry-run.yml @@ -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 - name: Download built JSON API uses: actions/download-artifact@v4 From a654cacb6a4c2a1d293d75c5e1d8df33429ab70d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 6 Mar 2025 12:20:23 +0100 Subject: [PATCH 2/3] Compile in release mode --- .github/workflows/dry-run.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dry-run.yml b/.github/workflows/dry-run.yml index 70cccacb4..94c30d6b8 100644 --- a/.github/workflows/dry-run.yml +++ b/.github/workflows/dry-run.yml @@ -135,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: | From a51fb94902450456a62f9ddb47a71181fd4216d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 6 Mar 2025 13:49:18 +0100 Subject: [PATCH 3/3] Extract PR number from the uploaded archive --- .github/workflows/dry-run.yml | 15 ++++++++++++++- .github/workflows/main.yml | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dry-run.yml b/.github/workflows/dry-run.yml index 94c30d6b8..c3d4afcc0 100644 --- a/.github/workflows/dry-run.yml +++ b/.github/workflows/dry-run.yml @@ -150,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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 933fdafab..632a06202 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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