The best way to control Claude Code, Codex and more from any computer or phone
| 1 | name: CI changes |
| 2 | description: Decide which CI jobs a change needs. See .github/scripts/ci-changes.cjs. |
| 3 | outputs: |
| 4 | typecheck: |
| 5 | value: ${{ steps.detect.outputs.typecheck }} |
| 6 | build: |
| 7 | value: ${{ steps.detect.outputs.build }} |
| 8 | desktop_launch: |
| 9 | value: ${{ steps.detect.outputs.desktop_launch }} |
| 10 | test: |
| 11 | value: ${{ steps.detect.outputs.test }} |
| 12 | test_packages: |
| 13 | value: ${{ steps.detect.outputs.test_packages }} |
| 14 | test_web: |
| 15 | value: ${{ steps.detect.outputs.test_web }} |
| 16 | test_server: |
| 17 | value: ${{ steps.detect.outputs.test_server }} |
| 18 | rust: |
| 19 | value: ${{ steps.detect.outputs.rust }} |
| 20 | release_smoke: |
| 21 | value: ${{ steps.detect.outputs.release_smoke }} |
| 22 | mobile_native: |
| 23 | value: ${{ steps.detect.outputs.mobile_native }} |
| 24 | runs: |
| 25 | using: composite |
| 26 | steps: |
| 27 | - id: detect |
| 28 | shell: bash |
| 29 | env: |
| 30 | EVENT_NAME: ${{ github.event_name }} |
| 31 | BEFORE_SHA: ${{ github.event.before }} |
| 32 | run: | |
| 33 | set -uo pipefail |
| 34 | |
| 35 | decide() { |
| 36 | node .github/scripts/ci-changes.cjs "$@" | tee -a "$GITHUB_OUTPUT" |
| 37 | exit "${PIPESTATUS[0]}" |
| 38 | } |
| 39 | |
| 40 | fail_open() { |
| 41 | echo "$* Running every job." |
| 42 | decide |
| 43 | } |
| 44 | |
| 45 | # Reads the change from git rather than the REST API: every job that |
| 46 | # runs this shares the repository's 1,000 requests/hour GITHUB_TOKEN quota. |
| 47 | if [[ "$EVENT_NAME" == pull_request ]]; then |
| 48 | # A pull request checks out GitHub's merge commit with fetch-depth: 2, |
| 49 | # so its first parent is the base branch and the diff is the PR's change. |
| 50 | base=HEAD^1 |
| 51 | mode=() |
| 52 | else |
| 53 | base=$BEFORE_SHA |
| 54 | git fetch --quiet --no-tags --depth=1 --filter=blob:none origin "$base" \ |
| 55 | || fail_open "Could not fetch ${base}." |
| 56 | # main keeps a full run as the backstop for anything the gate misses. |
| 57 | mode=(--full) |
| 58 | fi |
| 59 | |
| 60 | # --no-renames lists a rename as its old and new path: renaming a file out |
| 61 | # of a package changes that package just like editing it. It also keeps |
| 62 | # git from fetching file contents to score renames. |
| 63 | git diff --name-only --no-renames "$base" HEAD > "$RUNNER_TEMP/changed-paths" \ |
| 64 | || fail_open "Could not diff against ${base}." |
| 65 | decide --paths "$RUNNER_TEMP/changed-paths" "${mode[@]}" |