Skip to content

Commit b5efb28

Browse files
committed
feat[CI]: Improve CI with Bun cache & workflow refactor
1 parent 343ef91 commit b5efb28

17 files changed

Lines changed: 194 additions & 84 deletions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Setup Bun Cache
2+
description: Setup Bun and restore its global package cache
3+
4+
inputs:
5+
bun-version:
6+
description: Bun version to install
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Setup Bun
13+
uses: oven-sh/setup-bun@v2
14+
with:
15+
bun-version: ${{ inputs.bun-version }}
16+
17+
- name: Restore Bun global cache
18+
uses: actions/cache@v4
19+
with:
20+
path: ~/.bun/install/cache
21+
key: ${{ runner.os }}-bun-cache-${{ inputs.bun-version }}-${{ hashFiles('bun.lock') }}
22+
restore-keys: |
23+
${{ runner.os }}-bun-cache-${{ inputs.bun-version }}-
24+
${{ runner.os }}-bun-cache-

.github/workflows/ci-e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
services:
1313
postgres:
14-
image: postgres:16-alpine
14+
image: postgres:18-alpine
1515
env:
1616
POSTGRES_USER: test
1717
POSTGRES_PASSWORD: test
@@ -28,7 +28,7 @@ jobs:
2828
uses: actions/checkout@v6
2929

3030
- name: Setup Bun
31-
uses: oven-sh/setup-bun@v2
31+
uses: ./.github/actions/setup-bun-cache
3232
with:
3333
bun-version: "1.3.11"
3434

.github/workflows/ci-unit-integration.yml

Lines changed: 124 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,74 @@ on:
66
- "**"
77

88
jobs:
9+
changes:
10+
name: Detect Deploy Targets
11+
runs-on: ubuntu-latest
12+
outputs:
13+
native: ${{ steps.filter.outputs.native }}
14+
web: ${{ steps.filter.outputs.web }}
15+
workers: ${{ steps.filter.outputs.workers }}
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Detect changed files
23+
id: filter
24+
shell: bash
25+
run: |
26+
set -euo pipefail
27+
28+
BEFORE_SHA="${{ github.event.before }}"
29+
AFTER_SHA="${{ github.sha }}"
30+
ZERO_SHA="0000000000000000000000000000000000000000"
31+
32+
if [ "$BEFORE_SHA" = "$ZERO_SHA" ]; then
33+
git ls-tree -r --name-only "$AFTER_SHA" > changed-files.txt
34+
else
35+
git diff --name-only "$BEFORE_SHA" "$AFTER_SHA" > changed-files.txt
36+
fi
37+
38+
if rg -q '^(apps/web/|packages/ai/|packages/configs/|packages/db/|packages/logger/|packages/native-bridge/|packages/yjs-shared/|scripts/install/|package\.json$|bun\.lock$|turbo\.json$|\.github/workflows/web-deploy\.yml$)' changed-files.txt; then
39+
echo "web=true" >> "$GITHUB_OUTPUT"
40+
else
41+
echo "web=false" >> "$GITHUB_OUTPUT"
42+
fi
43+
44+
if rg -q '^(apps/workers/|packages/ai/|packages/configs/|packages/db/|packages/logger/|packages/yjs-shared/|scripts/install/|package\.json$|bun\.lock$|turbo\.json$|\.github/workflows/workers-deploy\.yml$)' changed-files.txt; then
45+
echo "workers=true" >> "$GITHUB_OUTPUT"
46+
else
47+
echo "workers=false" >> "$GITHUB_OUTPUT"
48+
fi
49+
50+
if rg -q '^(apps/native/|scripts/install/|package\.json$|bun\.lock$|\.github/workflows/release-native\.yml$)' changed-files.txt; then
51+
echo "native=true" >> "$GITHUB_OUTPUT"
52+
else
53+
echo "native=false" >> "$GITHUB_OUTPUT"
54+
fi
55+
56+
quality:
57+
name: Quality
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v6
62+
63+
- name: Setup Bun
64+
uses: ./.github/actions/setup-bun-cache
65+
with:
66+
bun-version: "1.3.11"
67+
68+
- name: Install dependencies
69+
run: bun install --frozen-lockfile
70+
71+
- name: Run checks
72+
run: bun run check
73+
74+
- name: Run type checks
75+
run: bun run check-types
76+
977
unit-web:
1078
name: Unit Web
1179
runs-on: ubuntu-latest
@@ -14,7 +82,7 @@ jobs:
1482
uses: actions/checkout@v6
1583

1684
- name: Setup Bun
17-
uses: oven-sh/setup-bun@v2
85+
uses: ./.github/actions/setup-bun-cache
1886
with:
1987
bun-version: "1.3.11"
2088

@@ -50,7 +118,7 @@ jobs:
50118
uses: actions/checkout@v6
51119

52120
- name: Setup Bun
53-
uses: oven-sh/setup-bun@v2
121+
uses: ./.github/actions/setup-bun-cache
54122
with:
55123
bun-version: "1.3.11"
56124

@@ -92,7 +160,7 @@ jobs:
92160
runs-on: ubuntu-latest
93161
services:
94162
postgres:
95-
image: postgres:16-alpine
163+
image: postgres:18-alpine
96164
env:
97165
POSTGRES_USER: test
98166
POSTGRES_PASSWORD: test
@@ -109,7 +177,7 @@ jobs:
109177
uses: actions/checkout@v6
110178

111179
- name: Setup Bun
112-
uses: oven-sh/setup-bun@v2
180+
uses: ./.github/actions/setup-bun-cache
113181
with:
114182
bun-version: "1.3.11"
115183

@@ -134,7 +202,7 @@ jobs:
134202
runs-on: ubuntu-latest
135203
services:
136204
postgres:
137-
image: postgres:16-alpine
205+
image: postgres:18-alpine
138206
env:
139207
POSTGRES_USER: test
140208
POSTGRES_PASSWORD: test
@@ -151,7 +219,7 @@ jobs:
151219
uses: actions/checkout@v6
152220

153221
- name: Setup Bun
154-
uses: oven-sh/setup-bun@v2
222+
uses: ./.github/actions/setup-bun-cache
155223
with:
156224
bun-version: "1.3.11"
157225

@@ -182,7 +250,7 @@ jobs:
182250
uses: actions/checkout@v6
183251

184252
- name: Setup Bun
185-
uses: oven-sh/setup-bun@v2
253+
uses: ./.github/actions/setup-bun-cache
186254
with:
187255
bun-version: "1.3.11"
188256

@@ -204,3 +272,52 @@ jobs:
204272

205273
- name: Check LCOV thresholds
206274
run: bun run scripts/testing/check-lcov-thresholds.ts
275+
276+
ci-passed:
277+
name: CI Passed
278+
runs-on: ubuntu-latest
279+
needs:
280+
- quality
281+
- unit-web
282+
- unit-server-and-packages
283+
- integration-web
284+
- integration-workers
285+
- coverage-gate
286+
steps:
287+
- name: Confirm CI status
288+
run: echo "Quality checks and tests passed."
289+
290+
deploy-web:
291+
name: Deploy Web
292+
if: ${{ github.ref_name == 'origin' && needs.changes.outputs.web == 'true' }}
293+
needs:
294+
- changes
295+
- ci-passed
296+
permissions:
297+
contents: read
298+
packages: write
299+
uses: singularityworks-xyz/lumen/.github/workflows/web-deploy.yml@origin
300+
secrets: inherit
301+
302+
deploy-workers:
303+
name: Deploy Workers
304+
if: ${{ github.ref_name == 'origin' && needs.changes.outputs.workers == 'true' }}
305+
needs:
306+
- changes
307+
- ci-passed
308+
permissions:
309+
contents: read
310+
packages: write
311+
uses: singularityworks-xyz/lumen/.github/workflows/workers-deploy.yml@origin
312+
secrets: inherit
313+
314+
release-native:
315+
name: Release Native
316+
if: ${{ github.ref_name == 'origin' && needs.changes.outputs.native == 'true' }}
317+
needs:
318+
- changes
319+
- ci-passed
320+
permissions:
321+
contents: write
322+
uses: singularityworks-xyz/lumen/.github/workflows/release-native.yml@origin
323+
secrets: inherit

.github/workflows/ci-visual-regression.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
uses: actions/checkout@v6
1515

1616
- name: Setup Bun
17-
uses: oven-sh/setup-bun@v2
17+
uses: ./.github/actions/setup-bun-cache
1818
with:
1919
bun-version: "1.3.11"
2020

.github/workflows/presence-deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ jobs:
7474
file: ./apps/presence/Dockerfile
7575
push: true
7676
platforms: linux/amd64,linux/arm64
77+
cache-from: type=gha,scope=lumen-presence
78+
cache-to: type=gha,mode=max,scope=lumen-presence
7779
tags: ${{ steps.meta.outputs.tags }}
7880
labels: ${{ steps.meta.outputs.labels }}
7981

.github/workflows/release-native.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name: "Release Native App"
22

33
on:
4-
push:
5-
branches:
6-
- origin
4+
workflow_call:
5+
workflow_dispatch:
76

87
concurrency:
98
group: ${{ github.workflow }}-${{ github.ref }}
@@ -60,7 +59,7 @@ jobs:
6059
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
6160
6261
- name: Setup Bun
63-
uses: oven-sh/setup-bun@v2
62+
uses: ./.github/actions/setup-bun-cache
6463
with:
6564
bun-version: latest
6665

.github/workflows/web-deploy.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
name: Deploy Web Service
22

33
on:
4-
push:
5-
branches: [origin]
6-
paths:
7-
- "apps/web/**"
8-
- "package.json"
9-
- ".github/workflows/web-deploy.yml"
4+
workflow_call:
5+
workflow_dispatch:
106

117
env:
128
REGISTRY: ghcr.io
@@ -75,6 +71,8 @@ jobs:
7571
file: ./apps/web/Dockerfile
7672
push: true
7773
platforms: linux/amd64,linux/arm64
74+
cache-from: type=gha,scope=lumen-web
75+
cache-to: type=gha,mode=max,scope=lumen-web
7876
tags: ${{ steps.meta.outputs.tags }}
7977
labels: ${{ steps.meta.outputs.labels }}
8078

.github/workflows/workers-deploy.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
name: Deploy Workers Service
22

33
on:
4-
push:
5-
branches: [origin]
6-
paths:
7-
- "apps/workers/**"
8-
- ".github/workflows/workers-deploy.yml"
4+
workflow_call:
5+
workflow_dispatch:
96

107
env:
118
REGISTRY: ghcr.io
@@ -74,6 +71,8 @@ jobs:
7471
file: ./apps/workers/Dockerfile
7572
push: true
7673
platforms: linux/amd64,linux/arm64
74+
cache-from: type=gha,scope=lumen-workers
75+
cache-to: type=gha,mode=max,scope=lumen-workers
7776
tags: ${{ steps.meta.outputs.tags }}
7877
labels: ${{ steps.meta.outputs.labels }}
7978

apps/web/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM oven/bun:alpine AS builder
22
RUN apk add --no-cache git
33
WORKDIR /app
44
COPY package.json bun.lock* turbo.json ./
5+
COPY scripts/install/prepare.ts ./scripts/install/
56
COPY packages/ai/package.json ./packages/ai/
67
COPY packages/db/package.json ./packages/db/
78
COPY packages/logger/package.json ./packages/logger/

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lumen/web",
3-
"version": "1.0.46",
3+
"version": "1.0.47",
44
"private": true,
55
"type": "module",
66
"scripts": {

0 commit comments

Comments
 (0)