Skip to content

Commit

Permalink
Modify rust workflow to support self hosted runner execution + create…
Browse files Browse the repository at this point in the history
… wake up script for runner (#199)
  • Loading branch information
ntampakas authored Dec 1, 2023
1 parent a734d94 commit 3ba1397
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/scripts/wakeup.sh
Original file line number Diff line number Diff line change
@@ -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
31 changes: 29 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -41,4 +68,4 @@ jobs:
run: |
cd backend
cargo run --release --example summa_solvency_flow

0 comments on commit 3ba1397

Please sign in to comment.