Skip to content

Commit 5f849fd

Browse files
authored
Update manual CI workflows to take commit SHA (#4078)
## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here --> ## Description <!--- Describe your changes in detail --> ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> Canary fails with appropriate error message if provided SHA and retrieved SHA (from the PR number) don't match: https://github.com/smithy-lang/smithy-rs/actions/runs/14210739747 Canary works if the provided SHA and the retrieved SHA do match: https://github.com/smithy-lang/smithy-rs/actions/runs/14210752482 Manual PR bot fails with appropriate error message if provided SHA and retrieved SHA do not match: https://github.com/smithy-lang/smithy-rs/actions/runs/14210797894 Manual PR bot works if the provided SHA and retrieved SHA do match: https://github.com/smithy-lang/smithy-rs/actions/runs/14210813156 ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 854efec commit 5f849fd

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

.github/workflows/manual-canary.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
description: The PR number to invoke the canary for.
99
required: true
1010
type: string
11+
commit_sha:
12+
description: The the full SHA for the HEAD commit of the PR
13+
required: true
14+
type: string
1115
run-name: ${{ github.workflow }} for Pull Request ${{ inputs.pull_request_number }}
1216

1317
# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed
@@ -34,6 +38,9 @@ jobs:
3438
commit_sha: response.data.head.sha,
3539
};
3640
console.log("data:", data);
41+
if(data.commit_sha !== "${{ inputs.commit_sha }}"){
42+
throw new Error("Input SHA does not match retrieved SHA")
43+
}
3744
return data;
3845
outputs:
3946
pull_data: ${{ steps.get-pr-info.outputs.result }}
@@ -48,8 +55,8 @@ jobs:
4855
with:
4956
path: smithy-rs
5057
# The ref used needs to match the HEAD revision of the PR being diffed, or else
51-
# the `docker-build` action won't find the built Docker image.
52-
ref: ${{ fromJSON(needs.get-pr-info.outputs.pull_data).commit_sha }}
58+
# the `docker-build` action won't find the built Docker image.
59+
ref: ${{ inputs.commit_sha }}
5360
fetch-depth: 0
5461
- name: Acquire base image
5562
id: acquire
@@ -71,7 +78,7 @@ jobs:
7178
- uses: actions/checkout@v4
7279
with:
7380
path: smithy-rs
74-
ref: ${{ fromJSON(needs.get-pr-info.outputs.pull_data).commit_sha }}
81+
ref: ${{ inputs.commit_sha }}
7582
- name: Generate a subset of SDKs for the canary
7683
uses: ./smithy-rs/.github/actions/docker-build
7784
with:
@@ -90,7 +97,7 @@ jobs:
9097
- uses: actions/checkout@v4
9198
with:
9299
path: smithy-rs
93-
ref: ${{ fromJSON(needs.get-pr-info.outputs.pull_data).commit_sha }}
100+
ref: ${{ inputs.commit_sha }}
94101
- name: Configure credentials
95102
id: creds
96103
uses: aws-actions/configure-aws-credentials@v4

.github/workflows/manual-pull-request-bot.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
description: The PR number to invoke the PR bot on.
99
required: true
1010
type: string
11+
commit_sha:
12+
description: The the full SHA for the HEAD commit of the PR
13+
required: true
14+
type: string
1115

1216
jobs:
1317
get-pr-info:
@@ -29,6 +33,9 @@ jobs:
2933
head_revision: response.data.head.sha,
3034
};
3135
console.log("data:", data);
36+
if(data.head_revision !== "${{ inputs.commit_sha }}"){
37+
throw new Error("Input SHA does not match retrieved SHA")
38+
}
3239
return data;
3340
outputs:
3441
pull_data: ${{ steps.get-pr-info.outputs.result }}
@@ -45,11 +52,11 @@ jobs:
4552
- uses: actions/checkout@v4
4653
with:
4754
path: smithy-rs
48-
# The ref used needs to match the HEAD revision of the PR being diffed, or else
49-
# the `docker-build` action won't find the built Docker image. This has the unfortunate
50-
# side effect that the codegen diff tool used is the one in the PR rather than in
51-
# the branch this workflow was launched from.
52-
ref: ${{ fromJSON(needs.get-pr-info.outputs.pull_data).head_revision }}
55+
# The ref used needs to match the HEAD revision of the PR being diffed, or else
56+
# the `docker-build` action won't find the built Docker image. This has the unfortunate
57+
# side effect that the codegen diff tool used is the one in the PR rather than in
58+
# the branch this workflow was launched from.
59+
ref: ${{ inputs.commit_sha }}
5360
fetch-depth: 0
5461
- name: Acquire base image
5562
id: acquire
@@ -70,7 +77,7 @@ jobs:
7077
with:
7178
issue_number: ${{ inputs.pull_number }}
7279
base_revision: ${{ fromJSON(needs.get-pr-info.outputs.pull_data).base_revision }}
73-
head_revision: ${{ fromJSON(needs.get-pr-info.outputs.pull_data).head_revision }}
80+
head_revision: ${{ inputs.commit_sha }}
7481
secrets:
7582
SMITHY_RS_PULL_REQUEST_CDN_S3_BUCKET_NAME: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_S3_BUCKET_NAME }}
7683
SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN }}

0 commit comments

Comments
 (0)