Skip to content

Bump actions/cache from 3 to 5 #788

Bump actions/cache from 3 to 5

Bump actions/cache from 3 to 5 #788

Workflow file for this run

name: PR
on:
push:
branches: [main]
pull_request:
branches:
- "**"
paths:
- "air/**"
- "core/**"
- "cuda/**"
- "eval/**"
- "perf/**"
- "prover/**"
- "server/**"
- "sppark/**"
- "Cargo.toml"
- ".github/workflows/**"
- ".github/runs-on.yml"
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Lint does not need to be done on a self-hosted runner
lint:
name: Formatting & Clippy
runs-on: [runs-on, runner=8cpu-linux-x64, "run-id=${{ github.run_id }}"]
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Runs-On Runner
uses: ./.github/actions/runs-on
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
env:
CARGO_INCREMENTAL: 1
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --all-targets -- -D warnings -A incomplete-features
env:
CARGO_INCREMENTAL: 1
start-runner:
name: Start Self-Hosted EC2 Runner
runs-on: "ubuntu-latest"
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
# Use an access key for an IAM user with these permissions:
# - ec2:RunInstances
# - ec2:TerminateInstances
# - ec2:DescribeInstances
# - ec2:DescribeInstanceStatus
- name: Configure AWS credentials
uses: "aws-actions/configure-aws-credentials@v1"
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner
id: "start-ec2-runner"
uses: "xJonathanLEI/ec2-github-runner@main"
with:
mode: "start"
# Must use personal access token here as `GITHUB_TOKEN` does not have access to runners.
# Use a fine-grained token with these permissions to at least this repository:
# - Administration: Read and write
# - Contents: Read and write
# - Metadata: Read-only
# - Workflows: Read and write
github-token: ${{ secrets.GH_PAT }}
# github-runner-ami-1726256456 (Ubuntu 22.04)
ec2-image-id: "ami-0a63dc9cb9e934ba3"
# 1 GPU; 8 vCPU; 32 GiB memory; 24 GiB GPU memory
ec2-instance-type: "g6.4xlarge"
# Use a subnet in the default VPC
subnet-id: "${{ secrets.AWS_SUBNET_ID }}"
# Use a security group attached to the default VPC
security-group-id: "${{ secrets.AWS_SG_ID }}"
storage-size: 1024
test:
name: Test
runs-on: "${{ needs.start-runner.outputs.label }}"
needs:
- "start-runner"
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- name: Checkout sources
uses: actions/checkout@v4
# - name: Setup Self-Hosted Runner
# uses: ./.github/actions/self-hosted
- name: rust-cache
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
~/.rustup/
key: rust-1.79.0-${{ hashFiles('**/Cargo.toml') }}
restore-keys: rust-1.79.0-
- name: Set up Docker
uses: docker/setup-buildx-action@v3
# Commented out because the latency of the docker buildx cache is high enough
# with the EC2 builder that it's a wash. Can be added back in if the toolchain gets complex.
# - name: Cache Docker layers
# uses: actions/cache@v5
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-
# - name: Build and cache Docker image
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./Dockerfile.toolchain
# push: false
# load: true
# tags: moongate-toolchain:latest
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# This step is necessary to prevent the cache from growing indefinitely
# - name: Move cache
# run: |
# rm -rf /tmp/.buildx-cache
# mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Run docker build
run: |
docker build -t moongate-toolchain:latest -f Dockerfile.toolchain .
# we need to run cargo test --release in the docker container
- name: Run Tests (docker)
run: |
docker run --gpus all \
-v ~/.cargo/registry:/root/.cargo/registry \
-v ~/.cargo/git:/root/.cargo/git \
moongate-toolchain:latest \
"cargo test --release -- --test-threads=1"
performance:
name: Performance
runs-on: "${{ needs.start-runner.outputs.label }}"
needs:
- "start-runner"
- "test"
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- name: Checkout sources
uses: actions/checkout@v4
# Commented out because the latency of the docker buildx cache is high enough
# with the EC2 builder that it's a wash. Can be added back in if the toolchain gets complex.
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Cache Docker layers
# uses: actions/cache@v5
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-
# - name: Build and cache Docker image
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./Dockerfile.toolchain
# push: false
# load: true
# tags: moongate-toolchain:latest
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# - name: Move cache
# run: |
# rm -rf /tmp/.buildx-cache
# mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Run Evaluation (docker)
env:
RUSTFLAGS: '-C target-cpu=native'
RUST_BACKTRACE: 1
run: |
docker run --gpus all \
-e RUSTFLAGS \
-e RUST_BACKTRACE \
moongate-toolchain \
"cargo run --release \
--manifest-path eval/Cargo.toml \
-- \
--programs fibonacci,ssz-withdrawals,tendermint \
--post-to-slack ${{ github.ref == 'refs/heads/main' }} \
--slack-channel-id '${{ secrets.SLACK_CHANNEL_ID }}' \
--slack-token '${{ secrets.SLACK_TOKEN }}' \
--post-to-github ${{ github.event_name == 'pull_request' }} \
--github-token '${{ secrets.GITHUB_TOKEN }}' \
--repo-owner '${{ github.repository_owner }}' \
--repo-name '${{ github.event.repository.name }}' \
--pr-number '${{ github.event.pull_request.number }}' \
--branch-name '${{ github.head_ref || github.ref_name }}' \
--commit-hash '${{ github.sha }}' \
--author '${{ github.event.pull_request.user.login || github.actor }}'"
stop-runner:
name: Stop Self-Hosted EC2 Runner
runs-on: "ubuntu-latest"
needs:
- "start-runner"
- "test"
- "performance"
if: ${{ always() }}
steps:
- name: Configure AWS credentials
uses: "aws-actions/configure-aws-credentials@v1"
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner
uses: "xJonathanLEI/ec2-github-runner@main"
with:
mode: "stop"
github-token: ${{ secrets.GH_PAT }}
label: "${{ needs.start-runner.outputs.label }}"
ec2-instance-id: "${{ needs.start-runner.outputs.ec2-instance-id }}"