Skip to content

Commit 8ddb94b

Browse files
authored
ci: skip dependency setup for irrelevant checks (#393)
1 parent ce4472c commit 8ddb94b

1 file changed

Lines changed: 84 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 84 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,28 @@ jobs:
105105
name: Cockpit — secret-gated integration
106106
runs-on: ubuntu-latest
107107
steps:
108+
- name: Check integration secret
109+
id: integration_secret
110+
run: |
111+
if [ -z "${COCKPIT_SECRET_TOKEN}" ]; then
112+
echo "enabled=false" >> "$GITHUB_OUTPUT"
113+
echo "::notice::Skipping secret-gated integration: COCKPIT_SECRET_TOKEN is not configured"
114+
else
115+
echo "enabled=true" >> "$GITHUB_OUTPUT"
116+
fi
117+
env:
118+
COCKPIT_SECRET_TOKEN: ${{ secrets.COCKPIT_SECRET_TOKEN }}
108119
- uses: actions/checkout@v6.0.2
120+
if: steps.integration_secret.outputs.enabled == 'true'
109121
- uses: actions/setup-node@v6.3.0
122+
if: steps.integration_secret.outputs.enabled == 'true'
110123
with:
111124
node-version: 22
112125
cache: npm
113-
- run: npm ci
114-
- run: |
115-
if [ -z "${COCKPIT_SECRET_TOKEN}" ]; then
116-
echo "Skipping secret-gated integration: COCKPIT_SECRET_TOKEN is not configured"
117-
exit 0
118-
fi
119-
npx nx run cockpit-langgraph-deployment-runtime-python:integration --skip-nx-cache
126+
- if: steps.integration_secret.outputs.enabled == 'true'
127+
run: npm ci
128+
- if: steps.integration_secret.outputs.enabled == 'true'
129+
run: npx nx run cockpit-langgraph-deployment-runtime-python:integration --skip-nx-cache
120130
env:
121131
COCKPIT_SECRET_TOKEN: ${{ secrets.COCKPIT_SECRET_TOKEN }}
122132

@@ -257,7 +267,31 @@ jobs:
257267
- uses: actions/checkout@v6.0.2
258268
with:
259269
fetch-depth: 0
270+
- name: Detect deploy-relevant changes
271+
id: deploy_preflight
272+
run: |
273+
base_sha="${{ github.event.before }}"
274+
head_sha="${{ github.sha }}"
275+
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
276+
base_sha="$(git rev-parse "$head_sha^")"
277+
fi
278+
279+
if ! git cat-file -e "$base_sha^{commit}" 2>/dev/null; then
280+
git fetch --no-tags origin "$base_sha"
281+
fi
282+
283+
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
284+
deploy_relevant=false
285+
if printf '%s\n' "$changed_files" | grep -E '^(\.github/workflows/ci\.yml|vercel\.(json|cockpit\.json|examples\.json)|apps/(website|cockpit)/|cockpit/|examples/chat/|libs/|scripts/(assemble-examples|deploy-smoke|demo-middleware|langgraph-proxy|rate-limit)\.ts|scripts/assemble-demo\.ts)$' >/dev/null; then
286+
deploy_relevant=true
287+
fi
288+
289+
echo "relevant=$deploy_relevant" >> "$GITHUB_OUTPUT"
290+
if [ "$deploy_relevant" != "true" ]; then
291+
echo "::notice::No deploy-relevant files changed; skipping Vercel dependency setup."
292+
fi
260293
- uses: actions/setup-node@v6.3.0
294+
if: steps.deploy_preflight.outputs.relevant == 'true'
261295
with:
262296
node-version: 22
263297
cache: npm
@@ -267,9 +301,10 @@ jobs:
267301
# VERCEL_WEBSITE_PROJECT_ID — website project id
268302
# VERCEL_COCKPIT_PROJECT_ID — cockpit project id
269303
# VERCEL_EXAMPLES_PROJECT_ID — examples project id
270-
- run: npm ci
271-
- run: npx playwright install --with-deps chromium
304+
- if: steps.deploy_preflight.outputs.relevant == 'true'
305+
run: npm ci
272306
- name: Resolve deploy targets
307+
if: steps.deploy_preflight.outputs.relevant == 'true'
273308
id: affected
274309
run: |
275310
base_sha="${{ github.event.before }}"
@@ -306,6 +341,9 @@ jobs:
306341
307342
echo "website=$website_changed" >> "$GITHUB_OUTPUT"
308343
echo "cockpit=$cockpit_changed" >> "$GITHUB_OUTPUT"
344+
- name: Install Playwright browsers
345+
if: steps.affected.outputs.website == 'true'
346+
run: npx playwright install --with-deps chromium
309347
- name: Prepare website Vercel project
310348
if: steps.affected.outputs.website == 'true'
311349
run: |
@@ -494,16 +532,50 @@ jobs:
494532
- uses: actions/checkout@v4
495533
with:
496534
fetch-depth: 0
535+
- name: Detect PostHog-relevant changes
536+
id: posthog_preflight
537+
run: |
538+
if [ "${{ github.event_name }}" = "push" ]; then
539+
base_sha="${{ github.event.before }}"
540+
head_sha="${{ github.sha }}"
541+
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
542+
base_sha="$(git rev-parse "$head_sha^")"
543+
fi
544+
else
545+
base_sha=$(git merge-base origin/main HEAD)
546+
head_sha=$(git rev-parse HEAD)
547+
fi
548+
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
549+
posthog_relevant=false
550+
if printf '%s\n' "$changed_files" | grep -E '^(tools/posthog/|package(-lock)?\.json|nx\.json|tsconfig\.base\.json|\.github/workflows/ci\.yml)$' >/dev/null; then
551+
posthog_relevant=true
552+
fi
553+
554+
echo "relevant=$posthog_relevant" >> "$GITHUB_OUTPUT"
555+
if [ "$posthog_relevant" != "true" ]; then
556+
echo "::notice::No PostHog tooling files changed — skipping dependency setup and drift check."
557+
fi
497558
- uses: actions/setup-node@v4
559+
if: steps.posthog_preflight.outputs.relevant == 'true'
498560
with:
499561
node-version: '20'
500562
cache: 'npm'
501-
- run: npm ci
563+
- if: steps.posthog_preflight.outputs.relevant == 'true'
564+
run: npm ci
502565
- name: Detect affected
566+
if: steps.posthog_preflight.outputs.relevant == 'true'
503567
id: affected
504568
run: |
505-
base_sha=$(git merge-base origin/main HEAD)
506-
head_sha=$(git rev-parse HEAD)
569+
if [ "${{ github.event_name }}" = "push" ]; then
570+
base_sha="${{ github.event.before }}"
571+
head_sha="${{ github.sha }}"
572+
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
573+
base_sha="$(git rev-parse "$head_sha^")"
574+
fi
575+
else
576+
base_sha=$(git merge-base origin/main HEAD)
577+
head_sha=$(git rev-parse HEAD)
578+
fi
507579
affected="$(npx nx show projects --affected --base=$base_sha --head=$head_sha)"
508580
if printf '%s\n' "$affected" | grep -Fx 'posthog-tools' >/dev/null; then
509581
echo "is_affected=yes" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)