Skip to content

Commit 8d65e69

Browse files
committed
Split the CI code size measurement job into two jobs: one with read-only
permission to build (and potentially run) untrusted code, and another with PR-write permission that only reports the sizes from the first job.
1 parent fae7e90 commit 8d65e69

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

.github/workflows/check-binary-size.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ on:
99
branches:
1010
- master
1111

12+
# Responsibility is divided between two jobs "measure" and "report", so that the
13+
# job that builds (and potentnially runs) untrusted code does not have PR write
14+
# permission, and vice-versa.
1215
jobs:
13-
test:
16+
measure:
1417
name: Check binary size
1518
runs-on: ubuntu-latest
1619
permissions:
17-
pull-requests: write
20+
contents: read
1821
env:
1922
# This cannot be used as a context variable in the 'uses' key later. If it
2023
# changes, update those steps too.
@@ -23,6 +26,9 @@ jobs:
2326
TEST_MAIN_RS: foo.rs
2427
BASE_COMMIT: ${{ github.event.pull_request.base.sha }}
2528
HEAD_COMMIT: ${{ github.event.pull_request.head.sha }}
29+
outputs:
30+
binary-size-reference: ${{ steps.size-reference.outputs.test-binary-size }}
31+
binary-size-updated: ${{ steps.size-updated.outputs.test-binary-size }}
2632
steps:
2733
- name: Print info
2834
run: |
@@ -77,11 +83,18 @@ jobs:
7783
main-rs: ${{ env.TEST_MAIN_RS }}
7884
rustc-dir: ${{ env.RUSTC_DIR }}
7985
id: size-updated
86+
report:
87+
name: Report binary size changes
88+
runs-on: ubuntu-latest
89+
needs: measure
90+
permissions:
91+
pull-requests: write
92+
steps:
8093
- name: Post a PR comment if the size has changed
8194
uses: actions/github-script@v6
8295
env:
83-
SIZE_REFERENCE: ${{ steps.size-reference.outputs.test-binary-size }}
84-
SIZE_UPDATED: ${{ steps.size-updated.outputs.test-binary-size }}
96+
SIZE_REFERENCE: ${{ needs.measure.outputs.binary-size-reference }}
97+
SIZE_UPDATED: ${{ needs.measure.outputs.binary-size-updated }}
8598
with:
8699
script: |
87100
const reference = process.env.SIZE_REFERENCE;

0 commit comments

Comments
 (0)