datahaven/.github/workflows/task-rust-lint.yml
Tim B ce59dd9625
fix: 🐳 Improve Docker Caching (#66)
## Summary

This PR attempts to improve caching, and thus speeds, for Docker image
generation.

This is to dramatically reduce the times of building images by using:

- cargo chef 
- cache mounts
- sccache
- cache dance

## Context

As a result this means thats changes that Do not Affect the code, should
(in theory) not trigger a new build to be run.

Changes that do change the rust code should also in theory be shorter as
the dependencies are unlikely to have changed and so that too can be
reused. In fact some part of the process should always be able to be
re-used unless we do something like drastic like change rust-toolchain,
but even then should only be a one time thing to regenerate that part of
the cache.

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-05-13 09:12:32 +00:00

74 lines
1.8 KiB
YAML

# Lint and Format: CI for Rust components (DataHaven runtime and node Rust tests)
#
# Overview:
# 1. Check Rust Format: Check that the Rust code is formatted correctly
# 2. Check Rust Lint: Check that the Rust code is linted correctly
name: Lint and Format
on:
workflow_call:
workflow_dispatch:
inputs:
pull_request:
description: set to pull_request number to execute on external pr
required: false
env:
CARGO_TERM_COLOR: always
WORKING_DIR: operator
RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=mold"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
jobs:
cargo-fmt:
name: "Check format with rustfmt"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/setup-env
with:
cache-key: FMT
cache-targets: false
- name: Run cargo fmt
run: cargo fmt --all -- --check
check-rust-lint:
name: "Check lint with clippy"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/setup-env
with:
cache-key: LINT
- name: Run cargo clippy
run: SKIP_WASM_BUILD=1 cargo clippy --features try-runtime,runtime-benchmarks --locked --release
check-cargo-sort:
name: "Check Cargo sort"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- name: Check out the repository to the runner
uses: actions/checkout@v4
- uses: uncenter/setup-taplo@v1
with:
version: "0.8.1"
- run: taplo fmt --check
- run: taplo lint