Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

action.yml

63 lines2.2 KB

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