Install the affected CLI in GitHub Actions. Downloads, caches, and adds the binary to PATH.
- uses: Rani367/setup-affected@v1
- run: affected list --base origin/main --explain- uses: Rani367/setup-affected@v1with:
version: 'v0.2.0'This is the killer pattern. Each affected package runs as a separate parallel job in the GitHub Actions UI:
name: CIon:
pull_request:
branches: [main]jobs:
detect:
runs-on: ubuntu-latestoutputs:
matrix: ${{ steps.affected.outputs.matrix }}has_affected: ${{ steps.affected.outputs.has_affected }}steps:
- uses: actions/checkout@v4with:
fetch-depth: 0
- uses: Rani367/setup-affected@v1
- name: Detect affected packagesid: affectedrun: affected ci --merge-base origin/maintest:
needs: detectif: needs.detect.outputs.has_affected == 'true'runs-on: ubuntu-lateststrategy:
matrix: ${{ fromJson(needs.detect.outputs.matrix) }}fail-fast: falsesteps:
- uses: actions/checkout@v4
- name: Test ${{ matrix.package }}run: cargo test -p ${{ matrix.package }}name: CIon:
pull_request:
branches: [main]jobs:
test:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v4with:
fetch-depth: 0
- uses: Rani367/setup-affected@v1
- name: Run affected testsrun: affected test --merge-base origin/main --jobs 4 - name: Lint affected packagesrun: affected run "cargo clippy -p {package} -- -D warnings" --merge-base origin/main
- name: Build affected packagesrun: affected run "cargo build -p {package}" --merge-base origin/main --jobs 4| Input | Description | Default |
|---|---|---|
version | Version to install (e.g., v0.2.0 or latest) | latest |
token | GitHub token for resolving latest version | ${{ github.token }} |
| Runner OS | Architecture |
|---|---|
ubuntu-latest | x64, arm64 |
macos-latest | x64, arm64 |
windows-latest | x64 |