Skip to content

Commit f83f983

Browse files
[ci] build matrix by script
1 parent e5d48f9 commit f83f983

File tree

2 files changed

+112
-95
lines changed

2 files changed

+112
-95
lines changed

.github/scripts/build-matrix.rb

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
require "json"
2+
require "optparse"
3+
4+
BASE_MATRIX_ENTRIES = [
5+
{
6+
"build_os": "ubuntu-18.04",
7+
"agent_query": "ubuntu-18.04",
8+
"target": "ubuntu18.04_x86_64",
9+
"container": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-18.04",
10+
"run_stdlib_test": true,
11+
"run_full_test": false,
12+
"run_e2e_test": true,
13+
"build_hello_wasm": true,
14+
"clean_build_dir": false,
15+
"free_disk_space": true
16+
},
17+
{
18+
"build_os": "ubuntu-20.04",
19+
"agent_query": "ubuntu-20.04",
20+
"target": "ubuntu20.04_x86_64",
21+
"container": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04",
22+
"run_stdlib_test": true,
23+
"run_full_test": false,
24+
"run_e2e_test": true,
25+
"build_hello_wasm": true,
26+
"clean_build_dir": false,
27+
"free_disk_space": true
28+
},
29+
{
30+
"build_os": "ubuntu-22.04",
31+
"agent_query": "ubuntu-22.04",
32+
"target": "ubuntu22.04_x86_64",
33+
"container": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-22.04",
34+
"run_stdlib_test": true,
35+
"run_full_test": false,
36+
"run_e2e_test": true,
37+
"build_hello_wasm": true,
38+
"clean_build_dir": false,
39+
"free_disk_space": true
40+
},
41+
{
42+
"build_os": "macos-11",
43+
"agent_query": "macos-11",
44+
"target": "macos_x86_64",
45+
"run_stdlib_test": false,
46+
"run_full_test": false,
47+
"run_e2e_test": false,
48+
"build_hello_wasm": false,
49+
"clean_build_dir": false
50+
},
51+
{
52+
"build_os": "macos-11",
53+
"agent_query": ["self-hosted", "macOS", "ARM64"],
54+
"target": "macos_arm64",
55+
"run_stdlib_test": false,
56+
"run_full_test": false,
57+
"run_e2e_test": false,
58+
"build_hello_wasm": true,
59+
"clean_build_dir": true
60+
}
61+
]
62+
63+
def main
64+
options = {}
65+
OptionParser.new do |opts|
66+
opts.banner = "Usage: build-matrix.rb [options]"
67+
opts.on("--runner [JSON FILE]", "Path to runner data file") do |v|
68+
options[:runner] = v
69+
end
70+
end.parse!
71+
72+
matrix_entries = BASE_MATRIX_ENTRIES.dup
73+
if options[:runner]
74+
runner = JSON.parse(File.read(options[:runner]))
75+
if label = runner["outputs"]["ubuntu20_04_aarch64-label"]
76+
matrix_entries << {
77+
"build_os": "amazon-linux-2",
78+
"agent_query": label,
79+
"target": "amazonlinux2_x86_64",
80+
"run_stdlib_test": false,
81+
"run_full_test": false,
82+
"run_e2e_test": false,
83+
"build_hello_wasm": true,
84+
"clean_build_dir": false
85+
}
86+
end
87+
if label = runner["outputs"]["ubuntu20_04_aarch64-label"]
88+
matrix_entries << {
89+
"build_os": "ubuntu-20.04",
90+
"agent_query": label,
91+
"target": "ubuntu20.04_aarch64",
92+
"run_stdlib_test": false,
93+
"run_full_test": false,
94+
"run_e2e_test": false,
95+
"build_hello_wasm": true,
96+
"clean_build_dir": false
97+
}
98+
end
99+
end
100+
101+
print JSON.generate(matrix_entries)
102+
end
103+
104+
if $0 == __FILE__
105+
main
106+
end

.github/workflows/build-toolchain.yml

Lines changed: 6 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -92,104 +92,15 @@ jobs:
9292
outputs:
9393
entries: ${{ steps.generate.outputs.entries }}
9494
steps:
95+
- uses: actions/checkout@v3
9596
- name: Generate entries
9697
id: generate
9798
run: |
98-
MATRIX_ENTRIES="["
99-
MATRIX_ENTRIES="$MATRIX_ENTRIES"$(cat <<EOS
100-
{
101-
"build_os": "ubuntu-18.04",
102-
"agent_query": "ubuntu-18.04",
103-
"target": "ubuntu18.04_x86_64",
104-
"container": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-18.04",
105-
"run_stdlib_test": true,
106-
"run_full_test": false,
107-
"run_e2e_test": true,
108-
"build_hello_wasm": true,
109-
"clean_build_dir": false,
110-
"free_disk_space": true
111-
},
112-
{
113-
"build_os": "ubuntu-20.04",
114-
"agent_query": "ubuntu-20.04",
115-
"target": "ubuntu20.04_x86_64",
116-
"container": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04",
117-
"run_stdlib_test": true,
118-
"run_full_test": false,
119-
"run_e2e_test": true,
120-
"build_hello_wasm": true,
121-
"clean_build_dir": false,
122-
"free_disk_space": true
123-
},
124-
{
125-
"build_os": "ubuntu-22.04",
126-
"agent_query": "ubuntu-22.04",
127-
"target": "ubuntu22.04_x86_64",
128-
"container": "ghcr.io/swiftwasm/swift-ci:main-ubuntu-22.04",
129-
"run_stdlib_test": true,
130-
"run_full_test": false,
131-
"run_e2e_test": true,
132-
"build_hello_wasm": true,
133-
"clean_build_dir": false,
134-
"free_disk_space": true
135-
},
136-
{
137-
"build_os": "macos-11",
138-
"agent_query": "macos-11",
139-
"target": "macos_x86_64",
140-
"run_stdlib_test": false,
141-
"run_full_test": false,
142-
"run_e2e_test": false,
143-
"build_hello_wasm": false,
144-
"clean_build_dir": false
145-
},
146-
{
147-
"build_os": "macos-11",
148-
"agent_query": ["self-hosted", "macOS", "ARM64"],
149-
"target": "macos_arm64",
150-
"run_stdlib_test": false,
151-
"run_full_test": false,
152-
"run_e2e_test": false,
153-
"build_hello_wasm": true,
154-
"clean_build_dir": true
155-
}
156-
EOS
157-
)
158-
159-
if [[ ${{ needs.start-runner.result }} == "success" ]]; then
160-
# MATRIX_ENTRIES="$MATRIX_ENTRIES,"
161-
# MATRIX_ENTRIES="$MATRIX_ENTRIES"$(cat <<EOS
162-
# {
163-
# "build_os": "amazon-linux-2",
164-
# "agent_query": "${{ needs.start-runner.outputs.amazonlinux2_x86_64-label }}",
165-
# "target": "amazonlinux2_x86_64",
166-
# "run_stdlib_test": false,
167-
# "run_full_test": false,
168-
# "run_e2e_test": false,
169-
# "build_hello_wasm": true,
170-
# "clean_build_dir": false
171-
# }
172-
# EOS
173-
# )
174-
175-
MATRIX_ENTRIES="$MATRIX_ENTRIES,"
176-
MATRIX_ENTRIES="$MATRIX_ENTRIES"$(cat <<EOS
177-
{
178-
"build_os": "ubuntu-20.04",
179-
"agent_query": "${{ needs.start-runner.outputs.ubuntu20_04_aarch64-label }}",
180-
"target": "ubuntu20.04_aarch64",
181-
"run_stdlib_test": false,
182-
"run_full_test": false,
183-
"run_e2e_test": false,
184-
"build_hello_wasm": true,
185-
"clean_build_dir": false
186-
}
187-
EOS
188-
)
189-
fi
190-
MATRIX_ENTRIES="$MATRIX_ENTRIES]"
191-
MATRIX_ENTRIES="${MATRIX_ENTRIES//$'\n'/''}"
192-
echo "::set-output name=entries::$MATRIX_ENTRIES"
99+
START_RUNNER_JSON="${{ runner.temp }}/start-runner.json"
100+
cat <<EOF > "$START_RUNNER_JSON"
101+
${{ toJson(needs.start-runner) }}
102+
EOF
103+
echo "entries=$(ruby .github/scripts/build-matrix.rb --runner $START_RUNNER_JSON)" >> $GITHUB_OUTPUT
193104
194105
build-toolchain:
195106
env:

0 commit comments

Comments
 (0)