Skip to content

Commit e206624

Browse files
amikofalvyclaude
andauthored
perf(ci): skip container init for changeset PRs (#2902)
* fix(ci): configure git remote with App token in release workflow The changesets/action pushes commits using the default GITHUB_TOKEN credential, which GitHub ignores for triggering downstream workflows. This left the Version Packages PR (#2881) stuck with required checks (ci, Cypress E2E, Create Agents E2E) permanently waiting. Configures the git remote URL with the inkeep-internal-ci App token before changesets/action runs — same pattern applied to ci.yml and auto-format.yml in #2871. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * perf(ci): skip container init for changeset PRs by extracting check job Service containers (Doltgres, Postgres) in cypress-e2e and create-agents-e2e were initialized before the changeset check ran, wasting ~30s of ubuntu-32gb runner time on every changeset PR. Extracts the changeset check into a lightweight job on ubuntu-latest that runs first. The heavy jobs now depend on it via `needs:` and skip entirely (including container init) when it's a changeset PR. Also removes all redundant step-level `if: changeset-check` guards since the job-level `if` already gates everything. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor(ci): extract changeset check into reusable composite action The changeset detection logic (~60 lines of shell) was duplicated across ci.yml and cypress.yml. Extracts it into a shared composite action at .github/composite-actions/changeset-check/action.yml. Both workflows now do a sparse checkout (just the composite action directory) and delegate to the shared action, keeping the changeset detection logic in one place. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3debd2e commit e206624

File tree

3 files changed

+109
-222
lines changed

3 files changed

+109
-222
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: "Changeset Check"
2+
description: "Detects changeset PRs (branch name, merge group, or changeset-only file changes) and outputs a skip flag"
3+
4+
outputs:
5+
is_changeset:
6+
description: "Whether this is a changeset PR that should skip heavy CI jobs"
7+
value: ${{ steps.check.outputs.is_changeset }}
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Check if changeset PR
13+
id: check
14+
shell: bash
15+
run: |
16+
IS_CHANGESET=false
17+
18+
# Pull request: check branch name directly
19+
if [ "$HEAD_REF" = "changeset-release/main" ]; then
20+
IS_CHANGESET=true
21+
echo "Changeset PR detected via branch name"
22+
fi
23+
24+
# Merge group: extract PR number from ref and check branch via API
25+
if [ "$GITHUB_EVENT_NAME" = "merge_group" ] && [ "$IS_CHANGESET" = "false" ]; then
26+
PR_NUM=$(echo "$MERGE_GROUP_HEAD_REF" | sed -n 's|.*/pr-\([0-9]*\)-.*|\1|p')
27+
if [ -n "$PR_NUM" ]; then
28+
BRANCH=$(gh pr view "$PR_NUM" --repo "$GITHUB_REPOSITORY" --json headRefName -q .headRefName 2>/dev/null || echo "")
29+
if [ "$BRANCH" = "changeset-release/main" ]; then
30+
IS_CHANGESET=true
31+
echo "Changeset PR detected via merge group (PR #$PR_NUM)"
32+
fi
33+
fi
34+
fi
35+
36+
# Check if PR only contains .changeset/ file changes
37+
if [ "$IS_CHANGESET" = "false" ] && [ "$GITHUB_EVENT_NAME" != "push" ]; then
38+
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] && [ -n "$PR_NUMBER" ]; then
39+
if ! CHANGED_FILES=$(gh pr diff "$PR_NUMBER" --name-only --repo "$GITHUB_REPOSITORY" 2>&1); then
40+
echo "::warning::Failed to fetch PR diff for #$PR_NUMBER: $CHANGED_FILES"
41+
CHANGED_FILES=""
42+
fi
43+
elif [ "$GITHUB_EVENT_NAME" = "merge_group" ] && [ -n "$PR_NUM" ]; then
44+
if ! CHANGED_FILES=$(gh pr diff "$PR_NUM" --name-only --repo "$GITHUB_REPOSITORY" 2>&1); then
45+
echo "::warning::Failed to fetch PR diff for #$PR_NUM: $CHANGED_FILES"
46+
CHANGED_FILES=""
47+
fi
48+
fi
49+
50+
if [ -n "$CHANGED_FILES" ]; then
51+
NON_CHANGESET=$(echo "$CHANGED_FILES" | grep -v '^\.changeset/' || true)
52+
if [ -z "$NON_CHANGESET" ]; then
53+
IS_CHANGESET=true
54+
echo "Only .changeset/ files changed — skipping heavy CI jobs"
55+
fi
56+
fi
57+
fi
58+
59+
echo "is_changeset=$IS_CHANGESET" >> $GITHUB_OUTPUT
60+
if [ "$IS_CHANGESET" = "true" ]; then
61+
echo "Changeset PR — skipping heavy CI jobs"
62+
fi
63+
env:
64+
HEAD_REF: ${{ github.head_ref }}
65+
GITHUB_EVENT_NAME: ${{ github.event_name }}
66+
MERGE_GROUP_HEAD_REF: ${{ github.event.merge_group.head_ref }}
67+
GH_TOKEN: ${{ github.token }}
68+
PR_NUMBER: ${{ github.event.pull_request.number }}

0 commit comments

Comments
 (0)