Skip to content

Commit e274882

Browse files
author
Charles Li
committed
Make the AddLabel workflow work as expected
Make AddLabel workflow in chain of "MaxText Package Tests". Remove single commit enforcement, as it is not in practice Make AddLabel workflow exit(1) to show failed if it fails to add label.
1 parent b117f50 commit e274882

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

.github/workflows/AddLabel.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ name: Add Label
1616

1717
on:
1818
workflow_run:
19-
workflows: [Tests, CodeQL]
19+
workflows: ["MaxText Package Tests"]
2020
types:
2121
- completed
2222
pull_request_review:
@@ -31,7 +31,8 @@ jobs:
3131
runs-on: ubuntu-latest
3232

3333
steps:
34-
- uses: actions/github-script@v7
34+
- name: Add Pull Request Label
35+
uses: actions/github-script@v7
3536
with:
3637
script: |
3738
const owner = "google"
@@ -42,7 +43,7 @@ jobs:
4243
} else if (context.payload.workflow_run !== undefined) {
4344
if (context.payload.workflow_run.pull_requests.length === 0) {
4445
console.log("This workflow is NOT running within a PR's context")
45-
process.exit()
46+
process.exit(1)
4647
}
4748
console.log(context.payload.workflow_run.pull_requests)
4849
pull_number = context.payload.workflow_run.pull_requests[0].number
@@ -68,15 +69,15 @@ jobs:
6869
6970
if (reviews.data.length === 0) {
7071
console.log("Not adding pull ready because the PR is not approved yet.")
71-
process.exit()
72+
process.exit(1)
7273
}
7374
let is_approved = false
7475
if (decision_result.repository.pullRequest.reviewDecision === "APPROVED") {
7576
is_approved = true
7677
}
7778
if (!is_approved) {
7879
console.log("Not adding pull ready because the PR is not approved yet by sufficient code owners.")
79-
process.exit()
80+
process.exit(1)
8081
}
8182
8283
const commits = await github.rest.pulls.listCommits({
@@ -85,11 +86,11 @@ jobs:
8586
pull_number,
8687
per_page: 100,
8788
})
88-
// Check that the number of commits in the PR is 1.
89-
if (commits.data.length !== 1) {
90-
console.log("Not adding pull ready because the PR has more than one commit. Please squash your commits.")
91-
process.exit(1)
92-
}
89+
// Check that the number of commits in the PR is 1. This is not enforced in practice.
90+
// if (commits.data.length !== 1) {
91+
// console.log("Not adding pull ready because the PR has more than one commit. Please squash your commits.")
92+
// process.exit(1)
93+
// }
9394
const ref = commits.data.slice(-1)[0].sha
9495
const checkRuns = await github.rest.checks.listForRef({
9596
owner,
@@ -98,13 +99,13 @@ jobs:
9899
})
99100
if (checkRuns.data.check_runs.length === 0) {
100101
console.log("Not adding pull ready because no check runs are associated with the last commit: " + ref)
101-
process.exit()
102+
process.exit(1)
102103
}
103104
for (const checkRun of checkRuns.data.check_runs) {
104105
if (checkRun.name.endsWith(context.job)) continue
105106
if (checkRun.conclusion !== "success") {
106107
console.log("Not adding pull ready because " + checkRun.name + " has not passed yet: " + checkRun.html_url)
107-
process.exit()
108+
process.exit(1)
108109
}
109110
}
110111
console.log("Adding pull ready label because the PR is approved AND all the check runs have passed")

0 commit comments

Comments
 (0)