From 605f5c534cfbe64c1b699e79ff89b4bbcafb8da9 Mon Sep 17 00:00:00 2001 From: SoraSuegami Date: Mon, 16 Dec 2024 09:36:25 +0900 Subject: [PATCH] Use self-hosted runner --- .github/workflows/build-fmt.yml | 42 ++++++++++++++++++++++- .github/workflows/unit-tests.yml | 57 +++++++++++++++++++++++++++++--- 2 files changed, 93 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-fmt.yml b/.github/workflows/build-fmt.yml index 0cb1b536..cbe83bb4 100644 --- a/.github/workflows/build-fmt.yml +++ b/.github/workflows/build-fmt.yml @@ -3,9 +3,30 @@ name: Build and Format on: [push] jobs: - build-and-format: + start-spot-vm: + name: Start Spot VM runs-on: ubuntu-latest + steps: + - name: Authenticate with GCP + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' + - name: Start Spot VM + run: gcloud compute instances start email-tx-builder-runner-spot --zone=us-central1-c + + - name: Wait for Spot VM to initialize + run: | + echo "Waiting for Spot VM to initialize..." + sleep 60 + + build-and-format: + runs-on: self-hosted steps: - uses: actions/checkout@v3 @@ -62,3 +83,22 @@ jobs: - name: Run clippy run: cargo clippy -- -D warnings + + stop-spot-vm: + name: Stop Spot VM + needs: [build-and-format] + runs-on: ubuntu-latest + steps: + - name: Authenticate with GCP + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' + + - name: Stop Spot VM + run: gcloud compute instances stop email-tx-builder-runner-spot --zone=us-central1-c + diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 680268bd..56e7267e 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -3,9 +3,32 @@ name: Unit Tests on: [push] jobs: + start-spot-vm: + name: Start Spot VM + runs-on: ubuntu-latest + + steps: + - name: Authenticate with GCP + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' + + - name: Start Spot VM + run: gcloud compute instances start email-tx-builder-runner-spot --zone=us-central1-c + + - name: Wait for Spot VM to initialize + run: | + echo "Waiting for Spot VM to initialize..." + sleep 60 + circuits: name: circuits - runs-on: ubuntu-latest + runs-on: self-hosted steps: - uses: actions/checkout@v3 @@ -21,8 +44,14 @@ jobs: override: true components: rustfmt, clippy + - name: Create bin directory + run: mkdir -p $HOME/bin + - name: Download circom v2.1.9 (Linux) - run: wget https://github.com/iden3/circom/releases/download/v2.1.9/circom-linux-amd64 -O /usr/local/bin/circom && chmod +x /usr/local/bin/circom + run: | + wget https://github.com/iden3/circom/releases/download/v2.1.9/circom-linux-amd64 -O $HOME/bin/circom + chmod +x $HOME/bin/circom + echo "PATH=$HOME/bin:$PATH" >> $GITHUB_ENV - name: Print circom version run: circom --version @@ -40,11 +69,11 @@ jobs: - name: Run tests working-directory: packages/circuits - run: yarn test --runInBand --no-cache + run: yarn test --maxWorkers=75% --no-cache contracts: name: contracts - runs-on: ubuntu-latest + runs-on: self-hosted steps: - uses: actions/checkout@v3 @@ -74,7 +103,7 @@ jobs: relayer: name: relayer - runs-on: ubuntu-latest + runs-on: self-hosted steps: - uses: actions/checkout@v3 @@ -101,3 +130,21 @@ jobs: - name: Run tests working-directory: packages/relayer run: cargo test + + stop-spot-vm: + name: Stop Spot VM + needs: [circuits, contracts, relayer] + runs-on: ubuntu-latest + steps: + - name: Authenticate with GCP + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' + + - name: Stop Spot VM + run: gcloud compute instances stop email-tx-builder-runner-spot --zone=us-central1-c \ No newline at end of file