Skip to content

Commit bdda240

Browse files
kateinoigakukunMaxDesiatov
authored andcommitted
ci: launch ci runner instance on demands (#4471)
# Conflicts: # .github/workflows/build-toolchain.yml
1 parent ec92a03 commit bdda240

File tree

1 file changed

+163
-61
lines changed

1 file changed

+163
-61
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 163 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -17,70 +17,174 @@ on:
1717
- swiftwasm-release/5.5
1818
- swiftwasm-release/5.6
1919
- swiftwasm-release/5.7
20+
types: [opened, synchronize, reopened, labeled]
2021
jobs:
21-
build_toolchain:
22+
start-runner:
23+
name: Start self-hosted EC2 runner
24+
runs-on: ubuntu-latest
25+
# Run only on main branches to avoid triggers by non-collaborator
26+
if: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'check-self-hosted-ci') }}
27+
outputs:
28+
ubuntu20_04_aarch64-label: ${{ steps.start-ubuntu20_04_aarch64-runner.outputs.label }}
29+
amazonlinux2_x86_64-label: ${{ steps.start-amazonlinux2_x86_64-runner.outputs.label }}
30+
ubuntu20_04_aarch64-ec2-instance-id: ${{ steps.start-ubuntu20_04_aarch64-runner.outputs.ec2-instance-id }}
31+
amazonlinux2_x86_64-ec2-instance-id: ${{ steps.start-amazonlinux2_x86_64-runner.outputs.ec2-instance-id }}
32+
steps:
33+
- name: Configure AWS credentials
34+
uses: aws-actions/configure-aws-credentials@v1
35+
with:
36+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
37+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
38+
aws-region: ${{ secrets.AWS_REGION }}
39+
- name: Start EC2 runner (ubuntu20_04_aarch64)
40+
id: start-ubuntu20_04_aarch64-runner
41+
uses: machulav/ec2-github-runner@v2
42+
with:
43+
mode: start
44+
github-token: ${{ secrets.SWIFTWASM_BUILDBOT_TOKEN }}
45+
ec2-image-id: ami-0d08b938af6d9dbb0 # swiftwasm-ci/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-arm64-server-20211129
46+
ec2-instance-type: c6g.large
47+
subnet-id: subnet-327f4a13
48+
security-group-id: sg-0429f5ec2bee9dc0c
49+
- name: Start EC2 runner (amazonlinux2_x86_64)
50+
id: start-amazonlinux2_x86_64-runner
51+
uses: machulav/ec2-github-runner@v2
52+
with:
53+
mode: start
54+
github-token: ${{ secrets.SWIFTWASM_BUILDBOT_TOKEN }}
55+
ec2-image-id: ami-059fc55111c686d49 # swiftwasm-ci/amzn2-ami-kernel-5.10-hvm-2.0.20211223.0-x86_64-gp2
56+
ec2-instance-type: c6i.large
57+
subnet-id: subnet-327f4a13
58+
security-group-id: sg-0429f5ec2bee9dc0c
59+
stop-runner:
60+
name: Stop self-hosted EC2 runner
61+
needs: [start-runner, build-toolchain]
62+
runs-on: ubuntu-latest
63+
# Required to stop the runner even if the error happened in the previous jobs
64+
if: ${{ always() && needs.start-runner.result == 'success' }}
65+
steps:
66+
- name: Configure AWS credentials
67+
uses: aws-actions/configure-aws-credentials@v1
68+
with:
69+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
70+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
71+
aws-region: ${{ secrets.AWS_REGION }}
72+
- name: Stop EC2 runner (ubuntu20_04_aarch64)
73+
uses: machulav/ec2-github-runner@v2
74+
with:
75+
mode: stop
76+
github-token: ${{ secrets.SWIFTWASM_BUILDBOT_TOKEN }}
77+
label: ${{ needs.start-runner.outputs.ubuntu20_04_aarch64-label }}
78+
ec2-instance-id: ${{ needs.start-runner.outputs.ubuntu20_04_aarch64-ec2-instance-id }}
79+
- name: Stop EC2 runner (amazonlinux2_x86_64)
80+
uses: machulav/ec2-github-runner@v2
81+
with:
82+
mode: stop
83+
github-token: ${{ secrets.SWIFTWASM_BUILDBOT_TOKEN }}
84+
label: ${{ needs.start-runner.outputs.amazonlinux2_x86_64-label }}
85+
ec2-instance-id: ${{ needs.start-runner.outputs.amazonlinux2_x86_64-ec2-instance-id }}
86+
87+
build-matrix:
88+
name: Build matrix
89+
needs: [start-runner]
90+
runs-on: ubuntu-latest
91+
if: ${{ always() }}
92+
outputs:
93+
entries: ${{ steps.generate.outputs.entries }}
94+
steps:
95+
- name: Generate entries
96+
id: generate
97+
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+
"run_stdlib_test": true,
105+
"run_full_test": false,
106+
"run_e2e_test": true,
107+
"build_hello_wasm": true,
108+
"clean_build_dir": false,
109+
"free_disk_space": true
110+
},
111+
{
112+
"build_os": "ubuntu-20.04",
113+
"agent_query": "ubuntu-20.04",
114+
"target": "ubuntu20.04_x86_64",
115+
"run_stdlib_test": true,
116+
"run_full_test": false,
117+
"run_e2e_test": true,
118+
"build_hello_wasm": true,
119+
"clean_build_dir": false,
120+
"free_disk_space": true
121+
},
122+
{
123+
"build_os": "macos-11",
124+
"agent_query": "macos-11",
125+
"target": "macos_x86_64",
126+
"run_stdlib_test": true,
127+
"run_full_test": true,
128+
"run_e2e_test": true,
129+
"build_hello_wasm": true,
130+
"clean_build_dir": false
131+
},
132+
{
133+
"build_os": "macos-11",
134+
"agent_query": ["self-hosted", "macOS", "ARM64"],
135+
"target": "macos_arm64",
136+
"run_stdlib_test": false,
137+
"run_full_test": false,
138+
"run_e2e_test": false,
139+
"build_hello_wasm": true,
140+
"clean_build_dir": true
141+
}
142+
EOS
143+
)
144+
145+
if [[ ${{ needs.start-runner.result }} == "success" ]]; then
146+
MATRIX_ENTRIES="$MATRIX_ENTRIES,"
147+
MATRIX_ENTRIES="$MATRIX_ENTRIES"$(cat <<EOS
148+
{
149+
"build_os": "amazon-linux-2",
150+
"agent_query": "${{ needs.start-runner.outputs.amazonlinux2_x86_64-label }}",
151+
"target": "amazonlinux2_x86_64",
152+
"run_stdlib_test": false,
153+
"run_full_test": false,
154+
"run_e2e_test": false,
155+
"build_hello_wasm": true,
156+
"clean_build_dir": false
157+
}
158+
EOS
159+
)
160+
161+
MATRIX_ENTRIES="$MATRIX_ENTRIES,"
162+
MATRIX_ENTRIES="$MATRIX_ENTRIES"$(cat <<EOS
163+
{
164+
"build_os": "ubuntu-20.04",
165+
"agent_query": "${{ needs.start-runner.outputs.ubuntu20_04_aarch64-label }}",
166+
"target": "ubuntu20.04_aarch64",
167+
"run_stdlib_test": false,
168+
"run_full_test": false,
169+
"run_e2e_test": false,
170+
"build_hello_wasm": true,
171+
"clean_build_dir": false
172+
}
173+
EOS
174+
)
175+
fi
176+
MATRIX_ENTRIES="$MATRIX_ENTRIES]"
177+
MATRIX_ENTRIES="${MATRIX_ENTRIES//$'\n'/''}"
178+
echo "::set-output name=entries::$MATRIX_ENTRIES"
179+
180+
build-toolchain:
22181
env:
23182
TOOLCHAIN_CHANNEL: DEVELOPMENT
24183
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer/
184+
needs: [build-matrix]
25185
strategy:
26186
matrix:
27-
include:
28-
- build_os: amazon-linux-2
29-
agent_query: [AmazonLinux2, X64]
30-
target: amazonlinux2_x86_64
31-
run_stdlib_test: false
32-
run_full_test: false
33-
run_e2e_test: false
34-
build_hello_wasm: true
35-
clean_build_dir: true
36-
37-
- build_os: ubuntu-18.04
38-
agent_query: ubuntu-18.04
39-
target: ubuntu18.04_x86_64
40-
run_stdlib_test: true
41-
run_full_test: false
42-
run_e2e_test: true
43-
build_hello_wasm: true
44-
clean_build_dir: false
45-
46-
- build_os: ubuntu-20.04
47-
agent_query: ubuntu-20.04
48-
target: ubuntu20.04_x86_64
49-
run_stdlib_test: true
50-
run_full_test: false
51-
run_e2e_test: true
52-
build_hello_wasm: true
53-
clean_build_dir: false
54-
55-
- build_os: ubuntu-20.04
56-
agent_query: [ubuntu20.04, ARM64]
57-
target: ubuntu20.04_aarch64
58-
run_stdlib_test: false
59-
run_full_test: false
60-
run_e2e_test: false
61-
build_hello_wasm: true
62-
clean_build_dir: true
63-
64-
- build_os: macos-11
65-
agent_query: macos-11
66-
target: macos_x86_64
67-
run_stdlib_test: true
68-
run_full_test: true
69-
run_e2e_test: true
70-
build_hello_wasm: true
71-
clean_build_dir: false
72-
73-
- build_os: macos-11
74-
agent_query: [self-hosted, macOS, ARM64]
75-
target: macos_arm64
76-
# FIXME: Enable stdlib test after wasmer fixes singlepass bug on arm64,
77-
# fixes cranelift bug on x64, or wasmtime supports arm64
78-
# Currently it's hard to run tests on both x64 and arm64.
79-
run_stdlib_test: false
80-
run_full_test: false
81-
run_e2e_test: false
82-
build_hello_wasm: true
83-
clean_build_dir: true
187+
include: ${{ fromJSON(needs.build-matrix.outputs.entries) }}
84188

85189
name: Target ${{ matrix.target }}
86190
timeout-minutes: 0
@@ -114,10 +218,8 @@ jobs:
114218

115219
- name: Prepare sccache timestamp
116220
id: cache_timestamp
117-
shell: cmake -P {0}
118221
run: |
119-
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
120-
message("::set-output name=timestamp::${current_date}")
222+
echo "::set-output name=timestamp::$(date +'%Y-%m-%d-%I-%M-%S')"
121223
122224
- name: Check Xcode version
123225
if: ${{ startsWith(matrix.build_os, 'macos-') }}

0 commit comments

Comments
 (0)