Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(ci): use shallow checkout for desktop react doctor (#126724)

posthog[bot]841bc6c56b15
diff --git a/.github/workflows/desktop-react-doctor.yml b/.github/workflows/desktop-react-doctor.yml
index 43b81d765f06..f54b0e9a7373 100644
--- a/.github/workflows/desktop-react-doctor.yml
+++ b/.github/workflows/desktop-react-doctor.yml
@@ -35,10 +35,17 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
- fetch-depth: 0
- filter: blob:none
+ fetch-depth: 2
persist-credentials: false
+ - uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
+ id: app-token
+ if: github.repository == 'PostHog/posthog' && github.event.pull_request.head.repo.full_name == github.repository
+ with:
+ client-id: ${{ vars.GH_APP_POSTHOG_PATHS_FILTER_APP_ID }}
+ private-key: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}
+ permission-pull-requests: read
+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: products/desktop/.node-version
@@ -50,16 +57,38 @@ jobs:
working-directory: products/desktop
env:
NO_COLOR: '1'
- REACT_DOCTOR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
- HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }}
+ GITHUB_REPOSITORY: ${{ github.repository }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ TOTAL_CHANGED_FILES: ${{ github.event.pull_request.changed_files }}
run: |
# -e omitted: exit codes are captured and inspected explicitly.
set -uo pipefail
+ REACT_DOCTOR_BASE_SHA=$(git rev-parse HEAD^) || exit 1
+ export REACT_DOCTOR_BASE_SHA
CHANGED="${RUNNER_TEMP}/react-doctor-changed-files.txt"
- # --relative: react-doctor runs from products/desktop, so the changed
- # file list must be relative to it, not to the repo root.
- if ! git diff --name-only --relative --diff-filter=ACMR "${REACT_DOCTOR_BASE_SHA}...${HEAD_SHA}" -- . > "$CHANGED"; then
- echo "Could not diff ${REACT_DOCTOR_BASE_SHA}...${HEAD_SHA}; failing rather than skipping the scan." >&2
+ DESKTOP_FILES="${RUNNER_TEMP}/react-doctor-desktop-files.json"
+ # The pull-request files API returns at most 3000 files; scan the full tree at that limit.
+ if [ "$TOTAL_CHANGED_FILES" -ge 3000 ]; then
+ git ls-files -z -- . | jq -Rsc 'split("\u0000")[:-1] | map("products/desktop/" + .)' > "$DESKTOP_FILES" || exit 1
+ else
+ gh api --paginate --slurp "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files?per_page=100" | jq '[.[][] |
+ select(.status == "added" or .status == "modified" or .status == "copied" or .status == "renamed") |
+ .filename | select(startswith("products/desktop/"))
+ ]' > "$DESKTOP_FILES" || exit 1
+ fi
+ unset GH_TOKEN
+ # react-doctor expects one path per line, relative to products/desktop.
+ if ! jq -ej '
+ if type == "array" and all(.[];
+ type == "string" and startswith("products/desktop/") and (test("[\\r\\n]") | not)
+ ) then
+ map(ltrimstr("products/desktop/")) | join("\n")
+ else
+ error("Invalid changed-file list")
+ end
+ ' "$DESKTOP_FILES" > "$CHANGED"; then
+ echo "Could not prepare changed desktop files; failing rather than skipping the scan." >&2
echo "exit-code=1" >> "$GITHUB_OUTPUT"
exit 1
fi