Skip to content

Commit 5dff5e1

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

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build And Test (x86-64)
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
generate-runner-id:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- id: generate
10+
name: Generate runner ID
11+
run: |
12+
RUNNER_ID=rr_runner_$(uuidgen|tr -d -)
13+
echo "RUNNER_ID=$RUNNER_ID" >> "$GITHUB_OUTPUT"
14+
outputs:
15+
RUNNER_ID: ${{ steps.generate.outputs.RUNNER_ID }}
16+
17+
build-and-test-x86-64:
18+
uses: ./.github/workflows/build-and-test.yml
19+
needs: generate-runner-id
20+
with:
21+
architecture: x86_64
22+
runner_id: ${{ needs.generate-runner-id.outputs.RUNNER_ID }}

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

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build And Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
architecture:
7+
required: true
8+
type: string
9+
runner_id:
10+
required: true
11+
type: string
12+
13+
jobs:
14+
start-runner:
15+
name: Start Runner
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: "Run :: Create and register AWS spot instance"
19+
run: |2-
20+
curl --fail -X POST -H "Content-Type: application/json" --data "{\"operation\": \"create\", \"architecture\":\"${{ inputs.architecture }}\", \"label\": \"${{ inputs.runner_id }}\"}" https://gztdxwrnjh46z4ucjge5m4pxhu0vtfzs.lambda-url.us-east-2.on.aws
21+
22+
build-and-test:
23+
name: Build And Test
24+
runs-on:
25+
- ${{ inputs.runner_id }}
26+
needs:
27+
- start-runner
28+
steps:
29+
- name: "Run :: Checkout repository"
30+
uses: actions/checkout@v2
31+
32+
- name: "Run :: Build"
33+
run: ./scripts/github-actions-build.sh
34+
35+
- name: "Run :: Test"
36+
run: ./scripts/github-actions-test.sh
37+
38+
stop-runner:
39+
name: Stop Runner
40+
runs-on: ubuntu-latest
41+
needs:
42+
- start-runner
43+
- build-and-test
44+
if: ${{ always() }}
45+
steps:
46+
- name: "Run :: Terminate and unregister AWS spot instance"
47+
run: |2-
48+
curl --fail -X POST -H "Content-Type: application/json" --data "{\"operation\": \"destroy\", \"label\": \"${{ inputs.runner_id }}\"}" https://gztdxwrnjh46z4ucjge5m4pxhu0vtfzs.lambda-url.us-east-2.on.aws

scripts/github-actions-build.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set +x # echo commands
4+
set -e # default to exiting on error"
5+
6+
uname -a
7+
8+
EXTRA_PACKAGES=
9+
MACHINE_TYPE=`uname -m`
10+
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
11+
EXTRA_PACKAGES=g++multilib
12+
fi
13+
14+
sudo apt-get install -y $EXTRA_PACKAGES cmake g++ pkg-config zlib1g-dev git python-dev-is-python3 libacl1-dev ninja-build manpages-dev capnproto libcapnp-dev gdb lldb python3-pexpect
15+
16+
mkdir obj
17+
cd obj
18+
cmake -G Ninja -DCMAKE_BUILD_TYPE=DEBUG -Dstaticlibs=FALSE ..
19+
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)