Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Replace actions-rs actions in GitHub workflows #678

Merged
merged 7 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
name: Setup rust
description: Sets up rust
name: Setup Rust
description: Sets up Rust
inputs:
toolchain:
description: The Rust toolchain to use
required: false
components:
description: Comma-separated list of components to install
required: false

runs:
using: composite
steps:
- name: Install Rust (stable)
uses: actions-rs/toolchain@v1
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest pinning the version of this action to a commit ref unless it comes from an organization we own or trust. Otherwise, we could open up an attack vector.

      uses: actions-rust-lang/setup-rust-toolchain@4d1965c9142484e48d40c19de54b5cba84953a06 # v1.1.0

Ref: https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions

profile: minimal
override: true

- uses: Swatinem/rust-cache@v2
# Empty string means rust-toolchain if it exists, otherwise stable
toolchain: ${{ inputs.toolchain }}
components: ${{ inputs.components }}
cache: true
# Do not override the RUSTFLAGS by default and instead do that per job,
# if needed. Setting RUSTFLAGS via env var, config, etc. is mutually
# exclusive and often a source of bugs.
# Empty string here means no override.
rustflags: ""
# By default, we do not override the toolchain from rust-toolchain.
# The user needs to explicitly use `<cmd> +<toolchain>` for clarity.
override: false
52 changes: 11 additions & 41 deletions .github/workflows/edr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ jobs:
# Install pre-built binaries for cargo hack
- uses: taiki-e/install-action@cargo-hack

- name: Cargo hack
uses: actions-rs/cargo@v1
with:
command: hack
args: check --feature-powerset --no-dev-deps
- run: cargo hack check --feature-powerset --no-dev-deps

test-edr-rs:
name: Test EDR (${{ matrix.os }})
Expand All @@ -54,25 +50,16 @@ jobs:
key: edr-rs-rpc-cache-v1

- name: Build cargo tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-targets --all-features --no-run
run: cargo test --workspace --all-targets --all-features --no-run

- name: Run cargo test
uses: actions-rs/cargo@v1
env:
ALCHEMY_URL: ${{ secrets.ALCHEMY_URL }}
INFURA_URL: ${{ secrets.INFURA_URL }}
with:
command: test
args: --workspace --all-targets --all-features
run: cargo test --workspace --all-targets --all-features

- name: Doctests
uses: actions-rs/cargo@v1
with:
command: test
args: --doc --workspace --features tracing
run: cargo test --doc --workspace --features tracing

# disable until:
# 1) https://github.com/napi-rs/napi-rs/issues/1405 is resolved (Windows-only)
Expand All @@ -84,43 +71,29 @@ jobs:
# uses: taiki-e/install-action@nextest

# - name: Test with latest nextest release
# uses: actions-rs/cargo@v1
# env:
# CARGO_INCREMENTAL: ${{ matrix.CARGO_INCREMENTAL }}
# ALCHEMY_URL: ${{ secrets.ALCHEMY_URL }}
# with:
# command: nextest
# args: run --workspace --all-features --all-targets
# run: cargo nextest run --workspace --all-features --all-targets

edr-style:
name: Check EDR Style
runs-on: ubuntu-latest
needs: check-edr
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-rust
with:
components: clippy

- name: Install nightly rustfmt
uses: actions-rs/toolchain@v1
uses: ./.github/actions/setup-rust
with:
toolchain: nightly
profile: minimal
components: rustfmt

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
components: clippy

- uses: Swatinem/rust-cache@v2

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
toolchain: nightly
command: fmt
args: --all --check
run: cargo +nightly fmt --all --check

- name: Run cargo clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
Expand All @@ -134,10 +107,7 @@ jobs:
- uses: ./.github/actions/setup-rust

- name: Cargo doc
uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --no-deps --all-features
run: cargo doc --workspace --no-deps --all-features

lint:
name: Run Prettier
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test-recent-mainnet-block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ jobs:
**/edr-cache
key: test-recent-mainnet-block-rpc-cache-v1

- name: Run test
uses: actions-rs/cargo@v1
with:
command: replay-block
args: -u ${{ secrets.ALCHEMY_URL }} -c 1
- run: cargo replay-block -u ${{ secrets.ALCHEMY_URL }} -c 1

- name: Notify failures
if: failure()
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/test-recent-optimism-block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ jobs:
with:
ref: feat/multichain

- name: Install Rust (stable)
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main was already merged to feat/multichain, so this should be safe to do, i.e. the action should already be there.


- name: Cache EDR RPC cache
uses: actions/cache@v4
Expand All @@ -29,11 +23,7 @@ jobs:
**/edr-cache
key: test-recent-optimism-block-rpc-cache-v1

- name: Run test
uses: actions-rs/cargo@v1
with:
command: replay-block
args: -u ${{ secrets.ALCHEMY_URL }} -c optimism
- run: cargo replay-block -u ${{ secrets.ALCHEMY_URL }} -c optimism

- name: Notify failures
if: failure()
Expand Down
Loading