ci: Refactor scripts #295
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
env: | |
CACHE: true | |
jobs: | |
audit: | |
name: Audit | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Setup Environment | |
uses: ./.github/actions/setup | |
with: | |
cargo-cache-key: cargo-audit | |
- name: Install cargo-audit | |
run: which cargo-audit || cargo install cargo-audit | |
- name: Audit | |
run: pnpm audit | |
filter: | |
name: Filter Workspace | |
runs-on: ubuntu-latest | |
needs: audit | |
outputs: | |
members: ${{ steps.parse.outputs.members }} | |
steps: | |
- name: Git Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Environment | |
uses: ./.github/actions/setup | |
with: | |
cargo-cache-key: cargo-filter-workspace | |
- name: Filter | |
id: parse | |
run: pnpm tsx ./scripts/setup/members.mts | |
process: | |
name: Crate | |
needs: filter | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
member: ${{ fromJson(needs.filter.outputs.members) }} | |
outputs: | |
crate: ${{ steps.changes.outputs.crate }} | |
steps: | |
- name: Git Checkout | |
uses: actions/checkout@v4 | |
- name: Detect Changes | |
uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: | | |
crate: | |
- '${{ matrix.member }}/**' | |
- name: Setup Environment | |
uses: ./.github/actions/setup | |
if: ${{ steps.changes.outputs.crate == 'true' }} | |
with: | |
cargo-cache-key: cargo-${{ matrix.member }} | |
toolchain: build, format, lint, test | |
solana: true | |
- name: Format | |
if: ${{ steps.changes.outputs.crate == 'true' }} | |
run: pnpm format ${{ matrix.member }} | |
- name: Lint / Clippy | |
if: ${{ steps.changes.outputs.crate == 'true' }} | |
run: pnpm lint:clippy ${{ matrix.member }} | |
- name: Lint / Docs | |
if: ${{ steps.changes.outputs.crate == 'true' }} | |
run: pnpm lint:docs ${{ matrix.member }} | |
- name: Lint / Features | |
if: ${{ steps.changes.outputs.crate == 'true' }} | |
run: pnpm lint:features ${{ matrix.member }} | |
- name: Build (SBF) | |
if: ${{ steps.changes.outputs.crate == 'true' }} | |
run: pnpm build ${{ matrix.member }} | |
- name: Test | |
if: ${{ steps.changes.outputs.crate == 'true' }} | |
run: pnpm test ${{ matrix.member }} |