forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make "@bors-servo try" a GitHub Action
This is the last piece of the puzzle to turning off bors. This makes functionality provided by bors to understand "@bors-servo try" a GitHub Action. For now the syntax is more or less the same, but we can modify it in the future and even add support for custom configuration options (more specific build combinations or even passing compiler flags). The big difference between this and what bors does is that there is no merge commit. GitHub simply runs tests on the version of the branch that is on a pull request. There is always the risk that tests might start failing when a branch is rebased, but this offers a bit more control because you can easily rebase from the PR and the merge queue will check this as well.
- Loading branch information
Showing
3 changed files
with
202 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
on: issue_comment | ||
name: Try | ||
|
||
jobs: | ||
parse-comment: | ||
name: Process Comment | ||
if: ${{ github.event.issue.pull_request }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
configuration: ${{ steps.configuration.outputs.result }} | ||
steps: | ||
- uses: actions/github-script@v6 | ||
id: configuration | ||
with: | ||
script: | | ||
function makeComment(body) { | ||
console.log(body); | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body | ||
}) | ||
} | ||
let tokens = "${{ github.event.comment.body }}".split(" "); | ||
let tagIndex = tokens.indexOf("@bors-servo"); | ||
if (tagIndex == -1 || tagIndex + 1 >= tokens.length) { | ||
return { try: false }; | ||
} | ||
let tryString = tokens[tagIndex + 1]; | ||
console.log("Found try string: '" + tryString + "'"); | ||
let returnValue = { try: false }; | ||
if (tryString == "try") { | ||
returnValue = { try: true, platform: 'all', layout: 'all', unit_tests: true, }; | ||
} else if (tryString == "try=wpt") { | ||
returnValue = { try: true, platform: 'linux', layout: '2013', unit_tests: false }; | ||
} else if (tryString == "try=wpt-2020") { | ||
returnValue = { try: true, platform: 'linux', layout: '2020', unit_tests: false }; | ||
} else if (tryString == "try=linux") { | ||
returnValue = { try: true, platform: 'linux', layout: 'none', unit_tests: true }; | ||
} else if (tryString == "try=mac") { | ||
returnValue = { try: true, platform: 'macos', layout: 'none', unit_tests: true }; | ||
} else if (tryString == "try=windows") { | ||
returnValue = { try: true, platform: 'windows', layout: 'none', unit_tests: true }; | ||
} else { | ||
makeComment("🤔 Unknown try string '" + tryString + "'"); | ||
return returnValue; | ||
} | ||
if (returnValue.try) { | ||
let result = await github.rest.repos.getCollaboratorPermissionLevel({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
username: "${{ github.event.sender.login }}" | ||
}); | ||
if (!result.data.user.permissions.push) { | ||
makeComment('🔒 User @${{ github.event.sender.login }} does not have permission to trigger try jobs.'); | ||
return { try: false }; | ||
} | ||
} | ||
const url = context.serverUrl + | ||
"/" + context.repo.owner + | ||
"/" + context.repo.repo + | ||
"/actions/runs/" + context.runId; | ||
const formattedURL = "[#" + context.runId + "](" + url + ")"; | ||
makeComment("🔨 Triggering try run (" + formattedURL + ") with platform=" + returnValue.platform + " and layout=" + returnValue.layout); | ||
return returnValue; | ||
run-try: | ||
name: Run Try | ||
needs: ["parse-comment"] | ||
if: ${{ fromJson(needs.parse-comment.outputs.configuration).try}} | ||
uses: ./.github/workflows/main.yml | ||
with: | ||
platform: ${{ fromJson(needs.parse-comment.outputs.configuration).platform }} | ||
layout: ${{ fromJson(needs.parse-comment.outputs.configuration).layout }} | ||
unit-tests: ${{ fromJson(needs.parse-comment.outputs.configuration).unit_tests }} | ||
|
||
results: | ||
name: Results | ||
needs: ["parse-comment", "run-try"] | ||
runs-on: ubuntu-latest | ||
if: ${{ always() && fromJson(needs.parse-comment.outputs.configuration).try}} | ||
steps: | ||
- name: Success | ||
if: ${{ !contains(join(needs.*.result, ','), 'failure') }} | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const url = context.serverUrl + | ||
"/" + context.repo.owner + | ||
"/" + context.repo.repo + | ||
"/actions/runs/" + context.runId; | ||
const formattedURL = "[#" + context.runId + "](" + url + ")"; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: "✨ Try run (" + formattedURL + ") " + "succeeded.", | ||
}); | ||
- name: Failure | ||
if: ${{ contains(join(needs.*.result, ','), 'failure') }} | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const url = context.serverUrl + | ||
"/" + context.repo.owner + | ||
"/" + context.repo.repo + | ||
"/actions/runs/" + context.runId; | ||
const formattedURL = "[#" + context.runId + "](" + url + ")"; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: "⚠️ Try run (" + formattedURL + ") " + "failed.", | ||
}); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters