Skip to content

Commit

Permalink
Implement build-and-test Github Actions CI using AWS spot instances
Browse files Browse the repository at this point in the history
  • Loading branch information
rocallahan committed May 25, 2024
1 parent 2ba5d7e commit b1eb6a4
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build-and-test-x86_64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build And Test (x86-64)

on: [push, pull_request]

jobs:
generate-runner-id:
runs-on: ubuntu-latest
steps:
- id: generate
name: Generate runner ID
run: |
RUNNER_ID=rr_runner_$(uuidgen|tr -d -)
echo "RUNNER_ID=$RUNNER_ID" >> "$GITHUB_OUTPUT"
outputs:
RUNNER_ID: ${{ steps.generate.outputs.RUNNER_ID }}

build-and-test-x86-64:
uses: ./.github/workflows/build-and-test.yml
with:
architecture: x86_64
runner_id: ${{ needs.generate-runner-id.outputs.RUNNER_ID }}
48 changes: 48 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build And Test

on:
workflow_call:
inputs:
architecture:
required: true
type: string
runner_id:
required: true
type: string

jobs:
start-runner:
name: Start Runner
runs-on: ubuntu-latest
steps:
- name: "Run :: Create and register AWS spot instance"
run: |2-
curl -s -X POST --data "{'operation': 'create', 'architecture':'${{ inputs.architecture }}', 'label': '${{ inputs.runner_id }}'}" https://gztdxwrnjh46z4ucjge5m4pxhu0vtfzs.lambda-url.us-east-2.on.aws
build-and-test:
name: Build And Test
runs-on:
- ${{ inputs.runner_id }}
needs:
- start-runner
steps:
- name: "Run :: Checkout repository"
uses: actions/checkout@v2

- name: "Run :: Build"
run: ./scripts/github-actions-build.sh

- name: "Run :: Test"
run: ./scripts/github-actions-test.sh

stop-runner:
name: Stop Runner
runs-on: ubuntu-latest
needs:
- start-runner
- build-and-test
if: ${{ always() }}
steps:
- name: "Run :: Terminate and unregister AWS spot instance"
run: |2-
curl -s -X POST --data "{'operation': 'destroy', 'label': '${{ inputs.runner_id }}'}" https://gztdxwrnjh46z4ucjge5m4pxhu0vtfzs.lambda-url.us-east-2.on.aws
13 changes: 13 additions & 0 deletions scripts/github-actions-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set +x # echo commands
set -e # default to exiting on error"

uname -a

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

mkdir obj
cd obj
cmake -G Ninja -DCMAKE_BUILD_TYPE=DEBUG -Dstaticlibs=FALSE ..
ninja
13 changes: 13 additions & 0 deletions scripts/github-actions-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set +x # echo commands
set -e # default to exiting on error"

# Enable perf events for rr
echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid
# Enable ptrace-attach to any process. This lets us get more data when tests fail.
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
# Disable AppArmor restrictions on user namespaces, which our tests need to use
(echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns) || true
let halfproc=`nproc`/2
ctest -j$halfproc --verbose

0 comments on commit b1eb6a4

Please sign in to comment.