From 51916cd3a5ff368a2f8354f7804868dd513fba39 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 23 May 2024 21:27:55 +1200 Subject: [PATCH] Implement build-and-test Github Actions CI using AWS spot instances --- .github/workflows/build-and-test-x86_64.yml | 22 ++++++++++ .github/workflows/build-and-test.yml | 48 +++++++++++++++++++++ scripts/github-actions-build.sh | 13 ++++++ scripts/github-actions-test.sh | 13 ++++++ 4 files changed, 96 insertions(+) create mode 100644 .github/workflows/build-and-test-x86_64.yml create mode 100644 .github/workflows/build-and-test.yml create mode 100755 scripts/github-actions-build.sh create mode 100755 scripts/github-actions-test.sh diff --git a/.github/workflows/build-and-test-x86_64.yml b/.github/workflows/build-and-test-x86_64.yml new file mode 100644 index 00000000000..49e2ed10a2b --- /dev/null +++ b/.github/workflows/build-and-test-x86_64.yml @@ -0,0 +1,22 @@ +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 + needs: generate-runner-id + with: + architecture: x86_64 + runner_id: ${{ needs.generate-runner-id.outputs.RUNNER_ID }} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 00000000000..16bc4266348 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -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 -H "Content-Type: application/json" --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 -H "Content-Type: application/json" --data "{\"operation\": \"destroy\", \"label\": \"${{ inputs.runner_id }}\"}" https://gztdxwrnjh46z4ucjge5m4pxhu0vtfzs.lambda-url.us-east-2.on.aws diff --git a/scripts/github-actions-build.sh b/scripts/github-actions-build.sh new file mode 100755 index 00000000000..118201ceb81 --- /dev/null +++ b/scripts/github-actions-build.sh @@ -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 diff --git a/scripts/github-actions-test.sh b/scripts/github-actions-test.sh new file mode 100755 index 00000000000..5e480b3e02a --- /dev/null +++ b/scripts/github-actions-test.sh @@ -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