mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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.
135 lines
4.6 KiB
YAML
135 lines
4.6 KiB
YAML
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_call:
|
|
inputs:
|
|
platform:
|
|
required: true
|
|
type: string
|
|
layout:
|
|
required: true
|
|
type: string
|
|
unit-tests:
|
|
required: true
|
|
type: boolean
|
|
workflow_dispatch:
|
|
inputs:
|
|
platform:
|
|
required: false
|
|
type: choice
|
|
options: ["none", "linux", "windows", "macos", "all", "sync"]
|
|
layout:
|
|
required: false
|
|
type: choice
|
|
options: ["none", "2013", "2020", "all"]
|
|
unit-tests:
|
|
required: false
|
|
type: boolean
|
|
|
|
jobs:
|
|
decision:
|
|
name: Decision
|
|
runs-on: ubuntu-20.04
|
|
outputs:
|
|
configuration: ${{ steps.configuration.outputs.result }}
|
|
steps:
|
|
- name: Configuration
|
|
id: configuration
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
// Never skip workflow runs for pull requests, merge groups, or manually triggered
|
|
// workfows / try jobs, which might need to actually run / retry WPT tests.
|
|
if (!['pull_request', 'merge_group', 'workflow_run', 'workflow_call'].includes(context.eventName)) {
|
|
// Skip the run if an identical run already exists. This helps to avoid running
|
|
// the workflow over and over again for the same commit hash.
|
|
if ((await github.rest.actions.listWorkflowRuns({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
workflow_id: "main.yml",
|
|
head_sha: context.sha,
|
|
status: "success",
|
|
})).data.workflow_runs.length > 0) {
|
|
console.log("Skipping workflow, because of duplicate job.");
|
|
return { platform: "none" };
|
|
}
|
|
}
|
|
|
|
// We need to pick defaults if the inputs are not provided. Unprovided inputs
|
|
// are empty strings in this template.
|
|
let platform = "${{ inputs.platform }}" || "linux";
|
|
let layout = "${{ inputs.layout }}" || "none";
|
|
let unit_tests = Boolean(${{ inputs.unit-tests }})
|
|
|
|
// Merge queue runs and pushes to master should always trigger a full build and test.
|
|
if (["push", "merge_group"].includes(context.eventName)) {
|
|
platform = "all";
|
|
layout = "all";
|
|
unit_tests = true;
|
|
}
|
|
|
|
let returnValue = {
|
|
platform,
|
|
layout,
|
|
unit_tests,
|
|
};
|
|
console.log("Using configuration: " + JSON.stringify(returnValue));
|
|
return returnValue;
|
|
|
|
build-win:
|
|
name: Windows
|
|
needs: ["decision"]
|
|
if: ${{ contains(fromJson('["windows", "all"]'), fromJson(needs.decision.outputs.configuration).platform) }}
|
|
uses: ./.github/workflows/windows.yml
|
|
with:
|
|
unit-tests: ${{ fromJson(needs.decision.outputs.configuration).unit_tests }}
|
|
|
|
build-mac:
|
|
name: Mac
|
|
needs: ["decision"]
|
|
if: ${{ contains(fromJson('["macos", "all"]'), fromJson(needs.decision.outputs.configuration).platform) }}
|
|
uses: ./.github/workflows/mac.yml
|
|
with:
|
|
unit-tests: ${{ fromJson(needs.decision.outputs.configuration).unit_tests }}
|
|
|
|
build-linux:
|
|
name: Linux
|
|
needs: ["decision"]
|
|
if: ${{ contains(fromJson('["linux", "all"]'), fromJson(needs.decision.outputs.configuration).platform) }}
|
|
uses: ./.github/workflows/linux.yml
|
|
with:
|
|
wpt: 'test'
|
|
layout: ${{ fromJson(needs.decision.outputs.configuration).layout }}
|
|
unit-tests: ${{ fromJson(needs.decision.outputs.configuration).unit_tests }}
|
|
|
|
build-result:
|
|
name: Result
|
|
runs-on: ubuntu-latest
|
|
if: always()
|
|
# needs all build to detect cancellation
|
|
needs:
|
|
- "decision"
|
|
- "build-win"
|
|
- "build-mac"
|
|
- "build-linux"
|
|
|
|
steps:
|
|
- name: Mark skipped jobs as successful
|
|
if: ${{ fromJson(needs.decision.outputs.configuration).platform == 'none' }}
|
|
run: exit 0
|
|
- name: Mark the job as successful
|
|
if: ${{ !contains(join(needs.*.result, ','), 'failure') && !contains(join(needs.*.result, ','), 'cancelled') }}
|
|
run: exit 0
|
|
- name: Mark the job as unsuccessful
|
|
if: contains(join(needs.*.result, ','), 'failure') || contains(join(needs.*.result, ','), 'cancelled')
|
|
run: exit 1
|