mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
There are currently two ways to run try. One is to push to the `try` or `try-*` branches and the other is to trigger a workflow via GitHub comment. This change combines these methods into one workflow. In addition, WPT results are reported together rather than separately and filtered results for all WPT tests are bundled together in the same artifact.
131 lines
5.9 KiB
YAML
131 lines
5.9 KiB
YAML
name: Try
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
push:
|
|
branches: ["try", "try-*"]
|
|
|
|
jobs:
|
|
parse-comment:
|
|
name: Process Comment or Branch Name
|
|
if: ${{ github.event_name == 'push' || (github.event_name == 'issue_comment' && 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);
|
|
if (context.eventName == "issue_comment") {
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body
|
|
});
|
|
}
|
|
}
|
|
|
|
let tryString = "";
|
|
if (context.eventName == "push") {
|
|
// Replace the first instance of "-" in the branch name to make it similar
|
|
// to the try syntax string expected below.
|
|
tryString = process.env.GITHUB_REF_NAME.replace("-", "=");
|
|
} else {
|
|
// This is a pull request comment event.
|
|
let tokens = context.payload.comment.body.split(/\s+/);
|
|
let tagIndex = tokens.indexOf("@bors-servo");
|
|
if (tagIndex == -1 || tagIndex + 1 >= tokens.length) {
|
|
return { try: false };
|
|
}
|
|
tryString = tokens[tagIndex + 1];
|
|
}
|
|
|
|
console.log("Found try string: '" + tryString + "'");
|
|
let returnValue = { try: false };
|
|
if (tryString == "try") {
|
|
returnValue = { try: true, platform: 'all', linux_wpt_layout: 'all', mac_wpt_layout: 'none', unit_tests: true, };
|
|
} else if (tryString == "try=linux") {
|
|
returnValue = { try: true, platform: 'linux', linux_wpt_layout: 'none', mac_wpt_layout: 'none', unit_tests: true };
|
|
} else if (tryString == "try=mac") {
|
|
returnValue = { try: true, platform: 'macos', linux_wpt_layout: 'none', mac_wpt_layout: 'none', unit_tests: true };
|
|
} else if (tryString == "try=windows") {
|
|
returnValue = { try: true, platform: 'windows', linux_wpt_layout: 'none', unit_tests: true };
|
|
} else if (tryString == "try=wpt") {
|
|
returnValue = { try: true, platform: 'linux', linux_wpt_layout: '2013', mac_wpt_layout: 'none', unit_tests: false };
|
|
} else if (tryString == "try=wpt-2020") {
|
|
returnValue = { try: true, platform: 'linux', linux_wpt_layout: '2020', mac_wpt_layout: 'none', unit_tests: false };
|
|
} else if (tryString == "try=mac-wpt") {
|
|
returnValue = { try: true, platform: 'macos', linux_wpt_layout: 'none', mac_wpt_layout: '2013', unit_tests: false };
|
|
} else if (tryString == "try=mac-wpt-2020") {
|
|
returnValue = { try: true, platform: 'macos', linux_wpt_layout: 'none', mac_wpt_layout: '2020', unit_tests: false };
|
|
} else {
|
|
makeComment("🤔 Unknown try string '" + tryString + "'");
|
|
return returnValue;
|
|
}
|
|
|
|
if (returnValue.try && context.eventName == "issue_comment") {
|
|
let username = context.payload.comment.user.login;
|
|
let result = await github.rest.repos.getCollaboratorPermissionLevel({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
username
|
|
});
|
|
if (!result.data.user.permissions.push) {
|
|
makeComment('🔒 User @' + username + ' 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 }}
|
|
linux-wpt-layout: ${{ fromJson(needs.parse-comment.outputs.configuration).linux_wpt_layout }}
|
|
mac-wpt-layout: ${{ fromJson(needs.parse-comment.outputs.configuration).mac_wpt_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: Result Comment
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
let success = ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }};
|
|
|
|
const url = context.serverUrl +
|
|
"/" + context.repo.owner +
|
|
"/" + context.repo.repo +
|
|
"/actions/runs/" + context.runId;
|
|
const formattedURL = "[#" + context.runId + "](" + url + ")";
|
|
|
|
let body = success ?
|
|
"✨ Try run (" + formattedURL + ") " + "succeeded." :
|
|
"⚠️ Try run (" + formattedURL + ") " + "failed.";
|
|
if (context.eventName == "issue_comment") {
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body
|
|
});
|
|
}
|