Skip to content

Commit

Permalink
Add try support via GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
mrobinson committed Jul 19, 2023
1 parent ae3f33b commit bf9af4c
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 35 deletions.
60 changes: 41 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
name: Main

on:
push:
# Run the entire pipeline for 'master' even though the merge queue already runs checks
# for every change. This just offers an extra layer of testing and covers the case of
# random force pushes.
branches: ["master", "try"]
pull_request:
types: ['opened', 'synchronize']
branches: ["**"]
merge_group:
types: [checks_requested]
workflow_dispatch:
workflow_call:
inputs:
platform:
required: true
type: string
layout:
required: true
type: string

jobs:
decision:
name: Decision
runs-on: ubuntu-20.04
outputs:
skipped: ${{ steps.skipDecision.outputs.result }}
platforms: ${{ steps.platformDecision.outputs.result }}
platform: ${{ steps.platformDecision.outputs.result }}
layout-engine: ${{ steps.layoutEngineDecision.outputs.result }}
unit-tests: ${{ steps.unitTestDecision.outputs.result }}
steps:
- name: Skip Decision
- name: Skip Duplicates Decision
id: skipDecision
uses: actions/github-script@v6
with:
result-encoding: string
script: |
// Never skip workflow runs for pull requests or merge groups, which might
// need to actually run / retry WPT tests.
if (context.eventName == "pull_request" || context.eventName == "merge_group") {
if (context.eventName == "pull_request" || context.eventName == "merge_group" || context.eventName == "workflow_run") {
return "run";
}
// Skip the run if an identical run already exists. This helps to avoid running
Expand All @@ -51,40 +50,63 @@ jobs:
with:
result-encoding: string
script: |
if (context.eventName == "workflow_call" && "${{ inputs.platform }}" != "") {
return "${{ inputs.platform }}";
}
if ("${{ steps.skipDecision.outputs.result }}" == "skip") {
return "none";
}
if (context.eventName == "push" || context.eventName == "merge_group") {
return "all";
}
return "linux"
- name: Layout Engine Decision
id: layoutEngineDecision
uses: actions/github-script@v6
with:
result-encoding: string
script: |
if ("context.eventName == "workflow_call") {
return "${{ inputs.layout }}";
}
if (context.eventName == "push" || context.eventName == "merge_group") {
return "all";
}
return "none"
- name: Unit Test Decision
id: unitTestDecision
uses: actions/github-script@v6
with:
result-encoding: string
script: |
return ['push', 'merge_group', 'workflow_call'].includes(context.eventName);
build-win:
name: Windows
needs: ["decision"]
if: ${{ needs.decision.outputs.platforms == 'all' }}
if: ${{ contains(fromJson('["windows", "all"]'), needs.decision.outputs.platform) }}
uses: ./.github/workflows/windows.yml
with:
unit-tests: true

build-mac:
name: Mac
needs: ["decision"]
if: ${{ needs.decision.outputs.platforms == 'all' }}
if: ${{ contains(fromJson('["macos", "all"]'), needs.decision.outputs.platform) }}
uses: ./.github/workflows/mac.yml
with:
unit-tests: true

build-linux:
name: Linux
needs: ["decision"]
if: ${{ needs.decision.outputs.platforms == 'all' || needs.decision.outputs.platforms == 'linux' }}
if: ${{ contains(fromJson('["linux", "all"]'), needs.decision.outputs.platform) }}
uses: ./.github/workflows/linux.yml
with:
wpt: 'test'
layout: ${{ (github.event_name == 'push' || github.event_name == 'merge_group') && 'all' || 'none' }}
unit-tests: ${{ github.event_name == 'push' || github.event_name == 'merge_group' }}
layout: ${{ needs.decision.outputs.layout-engine }}
unit-tests: ${{ needs.decision.outputs.unit-tests }}

build-result:
name: Result
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/quick-check.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/run-workflow-on-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
on: issue_comment

jobs:
parse-comment:
name: PR 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: |
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) {
return { try: false };
}
let tokens = "${{ github.event.comment.body }}".split(" ");
console.log(tokens);
let tagIndex = token.indexOf("@bors-servo");
if (tagIndex == -1 || tagIndex + 1 >= tokens.length) {
return { try: false };
}
let tryString = tokens[tagIndex + 1];
console.log(tryString);
if (tryString == "try") {
return { try: true, platform: 'all', layout: 'all' };
} else if (tryString == "try=wpt") {
return { try: true, platform: 'linux', layout: '2013' };
} else if (tryString == "try=wpt-2020") {
return { try: true, platform: 'linux', layout: '2020' };
} else if (tryString == "try=linux") {
return { try: true, platform: 'linux', layout: 'none' };
} else if (tryString == "try=mac") {
return { try: true, platform: 'macos', layout: 'none' };
} else if (tryString == "try=windows") {
return { try: true, platform: 'windows', layout: 'none' };
}
return { try: false };
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 }}

0 comments on commit bf9af4c

Please sign in to comment.