Skip to content

Commit 9d74257

Browse files
committed
Implement build-and-test Github Actions CI using AWS spot instances
1 parent 2ba5d7e commit 9d74257

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Build And Test (x86-64)
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-and-test-x86-64:
7+
uses: ./.github/workflows/build-and-test.yml
8+
with:
9+
architecture: x86_64
10+
instance_type: c5.9xlarge
11+
secrets: inherit

.github/workflows/build-and-test.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build And Test
2+
3+
# Based on
4+
# https://blog.devgenius.io/create-register-and-terminate-ec2-spot-instances-via-github-actions-aef473b8a00f
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
architecture:
10+
required: true
11+
type: string
12+
instance_type:
13+
required: true
14+
type: string
15+
16+
jobs:
17+
start-runner:
18+
name: Start Runner
19+
runs-on: ubuntu-latest
20+
outputs:
21+
RUNNER_ID: ${{ env.RUNNER_ID }}
22+
steps:
23+
- name: "Run :: Create and register AWS spot instance"
24+
run: |2-
25+
# Create and register AWS spot instance
26+
RUNNER_ID=rr_runner_$(uuidgen|tr -d -)
27+
curl -s -X POST --data "{'operation': 'create', 'architecture':'${{ inputs.architecture }}', 'label': '$RUNNER_ID'}" https://gztdxwrnjh46z4ucjge5m4pxhu0vtfzs.lambda-url.us-east-2.on.aws
28+
echo "RUNNER_ID=$RUNNER_ID" >> $GITHUB_ENV
29+
30+
build-and-test:
31+
name: Build And Test
32+
runs-on:
33+
- ${{ env.RUNNER_ID }}
34+
needs:
35+
- start-runner
36+
steps:
37+
- name: Start
38+
run: |2-
39+
# Start
40+
echo " Starting GitHub Action!" &&
41+
echo "STEPS_CAN_PROCEED=true" >> $GITHUB_ENV
42+
43+
- name: "Run :: Checkout repository"
44+
uses: actions/checkout@v2
45+
46+
- name: "Run :: Build"
47+
run: ./scripts/github-actions-build.sh
48+
49+
- name: "Run :: Test"
50+
run: ./scripts/github-actions-test.sh
51+
52+
stop-runner:
53+
name: Stop Runner
54+
runs-on: ubuntu-latest
55+
needs:
56+
- start-runner
57+
- build-and-test
58+
if: ${{ always() }}
59+
steps:
60+
- name: "Run :: Terminate and unregister AWS spot instance"
61+
run: |2-
62+
curl -s -X POST --data "{'operation': 'destroy', 'label': '${{ env.RUNNER_ID' }}}" https://gztdxwrnjh46z4ucjge5m4pxhu0vtfzs.lambda-url.us-east-2.on.aws

scripts/github-actions-build.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set +x # echo commands
4+
set -e # default to exiting on error"
5+
6+
uname -a
7+
8+
sudo apt-get install -y rpm ccache cmake g++ pkg-config zlib1g-dev git python-dev-is-python3 libacl1-dev ninja-build manpages-dev capnproto libcapnp-dev gdb lldb python3-pexpect
9+
10+
mkdir obj
11+
cd obj
12+
cmake -G Ninja -DCMAKE_BUILD_TYPE=DEBUG -Dstaticlibs=FALSE ..
13+
ninja

scripts/github-actions-test.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set +x # echo commands
4+
set -e # default to exiting on error"
5+
6+
# Enable perf events for rr
7+
echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid
8+
# Enable ptrace-attach to any process. This lets us get more data when tests fail.
9+
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
10+
# Disable AppArmor restrictions on user namespaces, which our tests need to use
11+
(echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns) || true
12+
let halfproc=`nproc`/2
13+
ctest -j$halfproc --verbose

0 commit comments

Comments
 (0)