Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

setup-affected

Install the affected CLI in GitHub Actions. Downloads, caches, and adds the binary to PATH.

Usage

- uses: Rani367/setup-affected@v1
- run: affected list --base origin/main --explain

Pin a version

- uses: Rani367/setup-affected@v1with:
version: 'v0.2.0'

Dynamic Matrix (run each package as a separate job)

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 }}

Simple usage (test all affected in one job)

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

Run custom commands on affected packages

 - 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

Inputs

InputDescriptionDefault
versionVersion to install (e.g., v0.2.0 or latest)latest
tokenGitHub token for resolving latest version${{ github.token }}

Supported platforms

Runner OSArchitecture
ubuntu-latestx64, arm64
macos-latestx64, arm64
windows-latestx64

About

GitHub Action to install the affected CLI for monorepo test selection

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors