Skip to content

Commit 862830d

Browse files
authored
chore(ci): use ec2 for build-and-test-differential (#4413)
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
1 parent 2212b00 commit 862830d

File tree

1 file changed

+52
-4
lines changed

1 file changed

+52
-4
lines changed

.github/workflows/build-and-test-differential.yaml

+52-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,36 @@ jobs:
1313
with:
1414
label: run-build-and-test-differential
1515

16-
build-and-test-differential:
16+
start-runner:
17+
name: Start self-hosted EC2 runner
1718
needs: prevent-no-label-execution
1819
if: ${{ needs.prevent-no-label-execution.outputs.run == 'true' }}
19-
runs-on: [self-hosted, linux, X64]
20+
runs-on: ubuntu-latest
21+
outputs:
22+
label: ${{ steps.start-ec2-runner.outputs.label }}
23+
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
24+
steps:
25+
- name: Configure AWS credentials
26+
uses: aws-actions/configure-aws-credentials@v2
27+
with:
28+
aws-access-key-id: ${{ secrets.EC2_ON_DEMAND_AWS_ACCESS_KEY_ID_COMMON }}
29+
aws-secret-access-key: ${{ secrets.EC2_ON_DEMAND_AWS_SECRET_ACCESS_KEY_COMMON }}
30+
aws-region: ${{ secrets.EC2_ON_DEMAND_AWS_REGION_COMMON }}
31+
- name: Start EC2 runner
32+
id: start-ec2-runner
33+
uses: machulav/ec2-github-runner@v2
34+
with:
35+
mode: start
36+
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN_MFC }}
37+
ec2-image-id: ami-092a175a6ad1aad7a
38+
ec2-instance-type: c6a.xlarge
39+
subnet-id: subnet-070b3d46464230127
40+
security-group-id: sg-0cca5762919221f16
41+
runner-home-dir: /home/ubuntu/actions-runner
42+
43+
build-and-test-differential:
44+
needs: start-runner
45+
runs-on: ${{ needs.start-runner.outputs.label }}
2046
container: ${{ matrix.container }}${{ matrix.container-suffix }}
2147
strategy:
2248
fail-fast: false
@@ -70,9 +96,9 @@ jobs:
7096
flags: differential
7197

7298
clang-tidy-differential:
73-
runs-on: [self-hosted, linux, X64]
74-
container: ghcr.io/autowarefoundation/autoware-universe:humble-latest-cuda
7599
needs: build-and-test-differential
100+
runs-on: ${{ needs.start-runner.outputs.label }}
101+
container: ghcr.io/autowarefoundation/autoware-universe:humble-latest-cuda
76102
steps:
77103
- name: Check out repository
78104
uses: actions/checkout@v3
@@ -103,3 +129,25 @@ jobs:
103129
target-files: ${{ steps.get-modified-files.outputs.all_changed_files }}
104130
clang-tidy-config-url: https://raw.githubusercontent.com/autowarefoundation/autoware/main/.clang-tidy
105131
build-depends-repos: build_depends.repos
132+
133+
stop-runner:
134+
name: Stop self-hosted EC2 runner
135+
needs:
136+
- start-runner
137+
- clang-tidy-differential
138+
runs-on: ubuntu-latest
139+
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
140+
steps:
141+
- name: Configure AWS credentials
142+
uses: aws-actions/configure-aws-credentials@v2
143+
with:
144+
aws-access-key-id: ${{ secrets.EC2_ON_DEMAND_AWS_ACCESS_KEY_ID_COMMON }}
145+
aws-secret-access-key: ${{ secrets.EC2_ON_DEMAND_AWS_SECRET_ACCESS_KEY_COMMON }}
146+
aws-region: ${{ secrets.EC2_ON_DEMAND_AWS_REGION_COMMON }}
147+
- name: Stop EC2 runner
148+
uses: machulav/ec2-github-runner@v2
149+
with:
150+
mode: stop
151+
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN_MFC }}
152+
label: ${{ needs.start-runner.outputs.label }}
153+
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}

0 commit comments

Comments
 (0)