Skip to content

Commit 80f8c06

Browse files
committed
Optimize CI: skip docs, merge build+e2e, improve turbo cache
1 parent 1ecb80b commit 80f8c06

2 files changed

Lines changed: 53 additions & 59 deletions

File tree

.github/workflows/ci.yml

Lines changed: 37 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@ name: CI
33
on:
44
push:
55
branches: [main, develop]
6+
paths-ignore:
7+
- '**/*.md'
8+
- 'content/**'
9+
- 'docs/**'
10+
- 'apps/site/**'
11+
- '.changeset/**'
612
pull_request:
713
branches: [main, develop]
14+
paths-ignore:
15+
- '**/*.md'
16+
- 'content/**'
17+
- 'docs/**'
18+
- 'apps/site/**'
19+
- '.changeset/**'
820

921
concurrency:
1022
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -44,28 +56,43 @@ jobs:
4456
node-version: '20.x'
4557
cache: 'pnpm'
4658

59+
# Per-branch turbo cache. PRs restore from base branch via restore-keys
60+
# for maximum cache hit rate; only changed packages re-run.
4761
- name: Turbo Cache
4862
uses: actions/cache@v5
4963
with:
5064
path: node_modules/.cache/turbo
51-
key: turbo-${{ runner.os }}-${{ github.sha }}
65+
key: turbo-${{ runner.os }}-test-${{ github.sha }}
5266
restore-keys: |
67+
turbo-${{ runner.os }}-test-
5368
turbo-${{ runner.os }}-
5469
5570
- name: Install dependencies
5671
run: pnpm install --frozen-lockfile
5772

58-
- name: Run tests with coverage
73+
# PRs: skip coverage instrumentation (v8 adds 40-100% overhead) and
74+
# leverage turbo per-package cache so unchanged packages are skipped.
75+
- name: Run tests (PR — fast, no coverage)
76+
if: github.event_name == 'pull_request'
77+
run: pnpm turbo run test --concurrency=4
78+
79+
# Push to main/develop: still run coverage so Codecov stays current.
80+
- name: Run tests with coverage (push)
81+
if: github.event_name == 'push'
5982
run: pnpm test:coverage --coverage.reporter=json --coverage.reporter=text
6083

6184
- name: Upload coverage to Codecov
85+
if: github.event_name == 'push'
6286
uses: codecov/codecov-action@v6
6387
with:
6488
fail_ci_if_error: false
6589
token: ${{ secrets.CODECOV_TOKEN }}
6690

67-
build:
68-
name: Build Core
91+
# Build + E2E merged into one job: avoids artifact upload/download (~30s)
92+
# and a duplicate `pnpm install` (~60s). Turbo cache makes the build
93+
# essentially free on subsequent runs.
94+
e2e:
95+
name: Build & E2E
6996
runs-on: ubuntu-latest
7097

7198
steps:
@@ -90,8 +117,9 @@ jobs:
90117
uses: actions/cache@v5
91118
with:
92119
path: node_modules/.cache/turbo
93-
key: turbo-${{ runner.os }}-${{ github.sha }}
120+
key: turbo-${{ runner.os }}-build-${{ github.sha }}
94121
restore-keys: |
122+
turbo-${{ runner.os }}-build-
95123
turbo-${{ runner.os }}-
96124
97125
- name: Install dependencies
@@ -102,64 +130,14 @@ jobs:
102130
pnpm turbo run build --filter='./packages/*'
103131
pnpm --filter @object-ui/console build
104132
105-
- name: Check for build artifacts
133+
- name: Verify build artifacts
106134
run: |
107135
if [ ! -d "packages/core/dist" ]; then
108136
echo "Protocol package build failed"
109137
exit 1
110138
fi
111139
echo "All packages built successfully"
112140
113-
- name: Upload build artifacts
114-
uses: actions/upload-artifact@v7
115-
with:
116-
name: build-output
117-
path: |
118-
packages/*/dist
119-
apps/console/dist
120-
retention-days: 1
121-
122-
e2e:
123-
name: E2E Tests
124-
runs-on: ubuntu-latest
125-
needs: build
126-
permissions:
127-
contents: read
128-
129-
steps:
130-
- name: Checkout code
131-
uses: actions/checkout@v6
132-
with:
133-
submodules: true
134-
135-
- name: Enable Corepack
136-
run: corepack enable
137-
138-
- name: Verify pnpm version
139-
run: pnpm --version
140-
141-
- name: Setup Node.js
142-
uses: actions/setup-node@v6
143-
with:
144-
node-version: '20.x'
145-
cache: 'pnpm'
146-
147-
- name: Turbo Cache
148-
uses: actions/cache@v5
149-
with:
150-
path: node_modules/.cache/turbo
151-
key: turbo-${{ runner.os }}-${{ github.sha }}
152-
restore-keys: |
153-
turbo-${{ runner.os }}-
154-
155-
- name: Install dependencies
156-
run: pnpm install --frozen-lockfile
157-
158-
- name: Download build artifacts
159-
uses: actions/download-artifact@v8.0.1
160-
with:
161-
name: build-output
162-
163141
- name: Get Playwright version
164142
id: playwright-version
165143
run: echo "version=$(pnpm list @playwright/test --depth=0 --json | jq -r '.[0].devDependencies["@playwright/test"].version')" >> $GITHUB_OUTPUT
@@ -184,7 +162,7 @@ jobs:
184162

185163
- name: Upload Playwright report
186164
uses: actions/upload-artifact@v7
187-
if: ${{ !cancelled() }}
165+
if: ${{ !cancelled() && failure() }}
188166
with:
189167
name: playwright-report
190168
path: playwright-report/
@@ -240,8 +218,9 @@ jobs:
240218
uses: actions/cache@v5
241219
with:
242220
path: node_modules/.cache/turbo
243-
key: turbo-${{ runner.os }}-${{ github.sha }}
221+
key: turbo-${{ runner.os }}-docs-${{ github.sha }}
244222
restore-keys: |
223+
turbo-${{ runner.os }}-docs-
245224
turbo-${{ runner.os }}-
246225
247226
- name: Install dependencies

turbo.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,22 @@
1010
"test": {
1111
"dependsOn": ["^build"],
1212
"outputs": ["coverage/**"],
13-
"cache": true
13+
"cache": true,
14+
"inputs": [
15+
"src/**",
16+
"test/**",
17+
"tests/**",
18+
"vitest.config.*",
19+
"vitest.setup.*",
20+
"tsconfig*.json",
21+
"package.json",
22+
"$TURBO_DEFAULT$",
23+
"!**/*.md",
24+
"!**/CHANGELOG.md",
25+
"!storybook-static/**",
26+
"!.storybook/**",
27+
"!**/*.stories.*"
28+
]
1429
},
1530
"test:watch": {
1631
"cache": false,

0 commit comments

Comments
 (0)