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

[workflow] Extract linting into a reusable workflow #953

Merged
merged 5 commits into from
Jun 27, 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
6 changes: 3 additions & 3 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: 'Setup'
description: 'Checkout repository, setup rust toolchain and dependencies'

inputs:
service-name:
description: 'A directory name where the service target is located'
working-directory:
description: 'A directory where the service code is located'
required: true
components:
description: Comma-separated list of components to be additionally installed
Expand All @@ -24,4 +24,4 @@ runs:
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
workspaces: '${{ inputs.workspaces }} -> target'
workspaces: '${{ inputs.working-directory }} -> target'
23 changes: 6 additions & 17 deletions .github/workflows/da-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:
- da-indexer/**
- .github/workflows/da-indexer.yml
- .github/workflows/_*.yml
- .github/workflows/r_*.yml
- .github/actions/**
pull_request:
paths:
- da-indexer/**
- .github/workflows/da-indexer.yml
- .github/workflows/_*.yml
- .github/workflows/r_*.yml
- .github/actions/**

name: Test, lint and docker (da-indexer)
Expand Down Expand Up @@ -46,7 +48,7 @@ jobs:
- name: Setup
uses: ./.github/actions/setup
with:
service-name: da-indexer
working-directory: da-indexer

- name: Unit tests
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins -- --nocapture
Expand All @@ -67,22 +69,9 @@ jobs:

lint:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
with:
service-name: da-indexer
components: rustfmt, clippy

- name: cargo fmt
run: cargo fmt --all -- --check --config imports_granularity=Crate

- name: cargo clippy
run: cargo clippy --all --all-targets --all-features -- -D warnings
uses: ./.github/workflows/r_linting.yml
with:
working-directory: da-indexer

docker:
name: Docker build and docker push
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/r_linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Linting (reusable)

on:
workflow_call:
inputs:
working-directory:
required: true
type: string

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
with:
working-directory: ${{ inputs.working-directory }}
components: rustfmt, clippy

- name: cargo fmt
run: cargo fmt --all -- --check --config imports_granularity=Crate
working-directory: ${{ inputs.working-directory }}

- name: cargo clippy
run: cargo clippy --all --all-targets --all-features -- -D warnings
working-directory: ${{ inputs.working-directory }}
Loading