datahaven/.github/workflows/actions/setup-env/action.yml
Tim B 3776d80a2e
test: ️ CI Refactor (#59)
Eventually our CI will be required to run two private blockchains
locally plus associated relayers.

This PR is to prepare for this fate by improving run times and
refactoring our existing CIs so they are a bit easier to reason about.

### Refactors
- **_We now run ALL CIs on every PR!_** This is so that we decomplexify
the logic around conditional builds and fetching built binaries from
another source. This reduces the surface area of code we have to
maintain at the cost of execution time
- This penalty is ameliorated by a layered caching system. At best, it
will be less than a minute to complete a build since everything will be
cached. On GH runners this is about 6 minutes sadly.
- We will no longer be at risk of important CIs being skipped
erroneously which hide true failures.
- Caching is a low-risk approach because at worst it has to build from
scratch. A bad cache hit will never imply the wrong thing gets build
since cargo is smart enough to just throw away any inappropriate build
artefacts.
- `setup-rust` action created so we have a unified way of setting up
runner and unifying our approach to caching
- Use a unique caching key for different activities and it will fallback
to shared cache if no matches
- we are using `mainnet` kurtosis config so that it works with relayer
assumptions

### Additions
- We can specify the ethereum block time via a new cli arg `--slot-time
<seconds>`
- We can specify arbitrary network_param args which get passed into the
generated yaml
- e.g. giving `bun cli --kurtosis-network-args="pet=cat food=fish" will
add:

```yml
network_params:
  # existing params...
  pet: cat
  food: fish
```

- We now have the ability to programmatically modify the yaml
- This means we are back down to a single `minimal.yml` kurtosis config
so we dont have to maintain changes between them
- Flow is: `add new cli arg` -> `add if() block which mutates yaml` ->
`profit`

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-05-06 20:20:02 +00:00

59 lines
1.7 KiB
YAML

name: "Setup Rust Environment"
description: "Creates a Rust environment with the specified toolchain, cache, and dependencies"
inputs:
cache-key:
description: "Cache key used to retrieve built data. Usually matches the profile of the build"
required: false
default: "cache"
cache-targets:
description: "Whether to cache targets"
required: false
default: "true"
runs:
using: "composite"
steps:
- name: Set Rust version
shell: bash
run: |
echo "BUILD_RUST_VERSION=$(rustc --version)" >> $GITHUB_ENV
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Set Rust caching env vars
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
shell: bash
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
sccache --show-stats
- name: Cache cargo + target + sccache2
uses: Swatinem/rust-cache@v2
with:
cache-targets: true
cache-all-crates: true
shared-key: ${{ runner.os }}-${{inputs.cache-key}}-${{ hashFiles('operator/rust-toolchain.toml') }}-${{ hashFiles('operator/Cargo.lock') }}
workspaces: |
operator -> target
cache-on-failure: true
cache-bin: true
cache-directories: |
~/.cache/sccache
~/.cargo/registry
~/.cargo/git
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: rui314/setup-mold@v1
- name: Install libpq-dev
shell: bash
run: sudo apt-get update && sudo apt-get install -y libpq-dev libclang-dev
- name: Install Protoc
uses: arduino/setup-protoc@v3