forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (116 loc) · 4.01 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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:
configuration:
required: true
type: string
workflow_dispatch:
inputs:
platform:
required: false
type: choice
options: ["linux", "windows", "macos", "all"]
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: |
// If this is a workflow call with a configuration object,
// then just return it immediately.
let configuration = ${{ inputs.configuration || '""' }};
if (configuration != "") {
console.log("Using configuration: " + JSON.stringify(configuration));
return configuration;
}
// 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 platforms = [];
if (platform == "all") {
platforms = [ "linux", "windows", "macos" ];
} else {
platforms = [ platform ];
}
let returnValue = {
platforms,
layout,
unit_tests,
};
console.log("Using configuration: " + JSON.stringify(returnValue));
return returnValue;
build-win:
name: Windows
needs: ["decision"]
if: ${{ contains(fromJson(needs.decision.outputs.configuration).platforms, 'windows') }}
uses: ./.github/workflows/windows.yml
with:
unit-tests: ${{ fromJson(needs.decision.outputs.configuration).unit_tests }}
build-mac:
name: Mac
needs: ["decision"]
if: ${{ contains(fromJson(needs.decision.outputs.configuration).platforms, 'macos') }}
uses: ./.github/workflows/mac.yml
with:
unit-tests: ${{ fromJson(needs.decision.outputs.configuration).unit_tests }}
build-linux:
name: Linux
needs: ["decision"]
if: ${{ contains(fromJson(needs.decision.outputs.configuration).platforms, 'linux') }}
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).platforms[0] != null }}
run: exit 0
- name: Mark the job as successful
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
run: exit 0
- name: Mark the job as unsuccessful
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1