Update github actions #298
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Format | |
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 | |
build-and-format: | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v3 | |
- run: rustup show | |
- name: Install rustfmt and clippy | |
run: | | |
rustup component add rustfmt | |
rustup component add clippy | |
- uses: Swatinem/rust-cache@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: "yarn" | |
- name: Cache clean | |
run: yarn cache clean | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Install Foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
version: nightly-0079a1146b79a4aeda58b0258215bedb1f92700b | |
- name: Build contracts | |
working-directory: packages/contracts | |
run: yarn build | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: false | |
# all of these default to true, but feel free to set to | |
# "false" if necessary for your workflow | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: true | |
swap-storage: true | |
- name: Build and check for warnings | |
env: | |
RUSTFLAGS: "-D warnings" | |
run: cargo build --release | |
- name: Check formatting | |
run: cargo fmt -- --check | |
- 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 | |