GitHub Actions
Pull requests run only the affected tests; main and a nightly schedule run everything as the safety net.
name: testson: pull_request: push: branches: [main] schedule: - cron: "0 3 * * *"
jobs: test: runs-on: ubuntu-latest steps: # The base ref must be in the history, so fetch it all. - uses: actions/checkout@v6 with: { fetch-depth: 0 }
# Installs the latest release to ~/.local/bin. Pin it with TRIMTEST_VERSION=v0.1.0. - name: Install trimtest run: | curl -fsSL https://raw.githubusercontent.com/RabinApps/trimtest/main/install.sh | sh echo "$HOME/.local/bin" >> "$GITHUB_PATH"
# ...your toolchain setup here (actions/setup-python, actions/setup-node, ...)...
- name: Affected tests (pull request) if: github.event_name == 'pull_request' run: trimtest run --base origin/${{ github.base_ref }} --timeout 900
- name: Full run (main and nightly) if: github.event_name != 'pull_request' run: trimtest run --full --timeout 1800fetch-depth: 0is required:--base origin/<branch>compares against git, so the base commit must exist.--baseneeds no recorded map, so there is nothing to cache between runs. Recordings fromrecord --coverageare tied to the commit they were made at and are ignored (with a warning) against another--base.- Keep the nightly full run. It is the safety net behind every selection.
- Always set a timeout. See Timeouts.
- To split a large suite across jobs see Sharding, and for what the exit codes mean see Exit codes.
Skipping the job when nothing is affected
Section titled “Skipping the job when nothing is affected”Run select first and gate later jobs on its output:
select: runs-on: ubuntu-latest outputs: any: ${{ steps.sel.outputs.any }} count: ${{ steps.sel.outputs.count }} steps: - uses: actions/checkout@v6 with: { fetch-depth: 0 } - run: curl -fsSL https://raw.githubusercontent.com/RabinApps/trimtest/main/install.sh | sh - id: sel run: ~/.local/bin/trimtest select --base origin/${{ github.base_ref }} --format github test: needs: select if: needs.select.outputs.any == 'true' # ...--format github appends any, count and a matrix of {adapter, cwd, command} to $GITHUB_OUTPUT.