Skip to content

Commit 5258830

Browse files
committed
feat: add early trigger check and caching to CI workflows
Before this change the workflows installed ffmpeg (~94 MB, 100 packages) and Playwright Chromium on every run, even when the trigger config (on-demand / smart mode) would decide to skip the pipeline. Changes: - Add packages/action/src/check.ts: lightweight pre-check entrypoint that evaluates the trigger and writes a `should-run` step output. Mirrors the early logic in index.ts but exits before any heavy work. - Update build script to also compile check.ts → dist/check.js. - demo.yml: run the trigger check immediately after `pnpm install`, then gate ffmpeg, Playwright, app start, and the action itself with `if: steps.check.outputs.should-run == 'true'`. Also adds pnpm store caching and Playwright browser caching. - ci.yml: add pnpm store caching to both jobs, add Playwright browser caching to the integration-tests job. On skipped runs the job now exits after a few seconds of lightweight setup. On cache-hit runs the heavy installs are also significantly faster. https://claude.ai/code/session_014X9H6DRMx8hHT9En1GXDGt
1 parent ee1b456 commit 5258830

8 files changed

Lines changed: 30341 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
- uses: actions/setup-node@v4
1515
with:
1616
node-version: '20'
17+
cache: 'pnpm'
1718

1819
- uses: pnpm/action-setup@v4
1920

@@ -32,6 +33,7 @@ jobs:
3233
- uses: actions/setup-node@v4
3334
with:
3435
node-version: '20'
36+
cache: 'pnpm'
3537

3638
- uses: pnpm/action-setup@v4
3739

@@ -41,6 +43,13 @@ jobs:
4143
- name: Install ffmpeg
4244
run: sudo apt-get install -y ffmpeg
4345

46+
- name: Cache Playwright browsers
47+
uses: actions/cache@v4
48+
with:
49+
path: ~/.cache/ms-playwright
50+
key: playwright-chromium-${{ hashFiles('pnpm-lock.yaml') }}
51+
restore-keys: playwright-chromium-
52+
4453
- name: Install Playwright Chromium
4554
run: pnpm --filter @git-glimpse/core exec playwright install chromium --with-deps
4655

.github/workflows/demo.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,49 @@ jobs:
3030
- uses: actions/setup-node@v4
3131
with:
3232
node-version: '20'
33+
cache: 'pnpm'
3334

3435
- uses: pnpm/action-setup@v4
3536

3637
- name: Install dependencies
3738
run: pnpm install
3839

40+
- name: Build action check script
41+
run: pnpm --filter @git-glimpse/action build
42+
43+
# Check whether the pipeline should run before installing heavy dependencies.
44+
# Subsequent steps are gated on this output to skip ffmpeg/Playwright when
45+
# the trigger config (on-demand, smart, etc.) decides to skip the run.
46+
- name: Check if glimpse should run
47+
id: check
48+
run: node packages/action/dist/check.js
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
INPUT_CONFIG-PATH: examples/simple-app/git-glimpse.config.ts
52+
INPUT_TRIGGER-MODE: ''
53+
3954
- name: Install FFmpeg
55+
if: steps.check.outputs.should-run == 'true'
4056
run: sudo apt-get install -y ffmpeg
4157

58+
- name: Cache Playwright browsers
59+
if: steps.check.outputs.should-run == 'true'
60+
uses: actions/cache@v4
61+
with:
62+
path: ~/.cache/ms-playwright
63+
key: playwright-chromium-${{ hashFiles('pnpm-lock.yaml') }}
64+
restore-keys: playwright-chromium-
65+
4266
- name: Install Playwright Chromium
67+
if: steps.check.outputs.should-run == 'true'
4368
run: pnpm --filter @git-glimpse/core exec playwright install chromium --with-deps
4469

4570
- name: Start example app
71+
if: steps.check.outputs.should-run == 'true'
4672
run: node examples/simple-app/server.js &
4773

4874
- name: Wait for app to be ready
75+
if: steps.check.outputs.should-run == 'true'
4976
run: |
5077
for i in $(seq 1 15); do
5178
curl -sf http://localhost:3000 && echo "App ready" && exit 0
@@ -55,6 +82,7 @@ jobs:
5582
echo "App did not become ready" && exit 1
5683
5784
- uses: ./packages/action
85+
if: steps.check.outputs.should-run == 'true'
5886
with:
5987
preview-url: 'http://localhost:3000'
6088
config-path: examples/simple-app/git-glimpse.config.ts

0 commit comments

Comments
 (0)