From 3ba1397c2df3acf6756dd8ec1ee5743898e55b50 Mon Sep 17 00:00:00 2001 From: ntampakas Date: Fri, 1 Dec 2023 07:38:43 +0200 Subject: [PATCH] Modify rust workflow to support self hosted runner execution + create wake up script for runner (#199) --- .github/scripts/wakeup.sh | 18 ++++++++++++++++++ .github/workflows/rust.yml | 31 +++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100755 .github/scripts/wakeup.sh diff --git a/.github/scripts/wakeup.sh b/.github/scripts/wakeup.sh new file mode 100755 index 00000000..e8302270 --- /dev/null +++ b/.github/scripts/wakeup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +runner="i-0e04845bff4576909" + +while true; do + runner_status=$(aws ec2 describe-instances --instance-ids $runner --query "Reservations[*].Instances[*].State.[Name]" --output text) + if [ $runner_status = "stopped" ]; then + aws ec2 start-instances --instance-ids $runner + break + elif [ $runner_status = "running" ]; then + break + else + sleep 5 + fi +done + +exit 0 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 67624491..8a91c9b5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -6,16 +6,43 @@ on: pull_request: branches: ["*"] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + env: CARGO_TERM_COLOR: always jobs: - build: + wakeup: runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + + steps: + - uses: actions/checkout@v3 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::490752553772:role/summa-solvency-ec2-slc + role-duration-seconds: 900 + aws-region: us-west-2 + + - name: Wakeup runner + run: .github/scripts/wakeup.sh + + build: + runs-on: [summa-solvency-runner] + needs: [wakeup] steps: - uses: actions/checkout@v3 + - name: Set Environment + run: echo "PATH=/home/ubuntu/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" >> "$GITHUB_ENV" + - name: Install solc run: (hash svm 2>/dev/null || cargo install --version 0.2.23 svm-rs) && svm install 0.8.20 && solc --version @@ -41,4 +68,4 @@ jobs: run: | cd backend cargo run --release --example summa_solvency_flow - \ No newline at end of file +