Skip to content

Commit 342d0ec

Browse files
committed
refactor: consolidate CI/CD workflow steps and improve parallel execution of linting and building
1 parent f6f8f98 commit 342d0ec

1 file changed

Lines changed: 39 additions & 113 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 39 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -15,154 +15,80 @@ permissions:
1515
attestations: write
1616

1717
jobs:
18-
lint:
19-
name: Lint
18+
ci-cd:
19+
name: CI/CD Pipeline
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424
with:
25-
fetch-depth: 0
25+
# Smart fetch: full history only for releases (changelog generation), shallow for everything else
26+
fetch-depth: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/rc')) && 0 || 1 }}
2627

2728
- name: Setup Bun
2829
uses: oven-sh/setup-bun@v2
2930
with:
3031
bun-version: 1.2.15
3132

32-
- name: Cache Bun global packages
33+
- name: Cache Dependencies
3334
uses: actions/cache@v4
3435
with:
3536
path: ~/.bun/install/cache
36-
key: ${{ runner.os }}-bun-${{ hashFiles('**/package.json') }}
37+
key: ${{ runner.os }}-bun-${{ hashFiles('**/package.json', '**/bun.lock') }}
3738
restore-keys: |
3839
${{ runner.os }}-bun-
3940
40-
- name: Cache Playwright browser binaries
41-
uses: actions/cache@v4
42-
with:
43-
path: ~/.cache/ms-playwright
44-
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package.json') }}
45-
restore-keys: |
46-
${{ runner.os }}-playwright-
47-
48-
- name: Install dependencies
49-
run: bun install
50-
51-
- name: Run format check
52-
run: bun run format:check
53-
54-
build:
55-
name: Build
56-
needs: lint
57-
runs-on: ubuntu-latest
58-
steps:
59-
- name: Checkout
60-
uses: actions/checkout@v4
61-
with:
62-
fetch-depth: 0
63-
64-
- name: Setup Bun
65-
uses: oven-sh/setup-bun@v2
66-
with:
67-
bun-version: 1.2.15
68-
69-
- name: Cache Bun global packages
70-
uses: actions/cache@v4
71-
with:
72-
path: ~/.bun/install/cache
73-
key: ${{ runner.os }}-bun-${{ hashFiles('**/package.json') }}
74-
restore-keys: |
75-
${{ runner.os }}-bun-
76-
77-
- name: Cache Playwright browser binaries
78-
uses: actions/cache@v4
79-
with:
80-
path: ~/.cache/ms-playwright
81-
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package.json') }}
82-
restore-keys: |
83-
${{ runner.os }}-playwright-
84-
85-
- name: Install dependencies
41+
- name: Install Dependencies
8642
run: bun install
8743

88-
- name: Configure git
44+
- name: Lint & Build (Parallel)
8945
run: |
90-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
91-
git config --global user.name "github-actions[bot]"
46+
echo "🚀 Running lint and build in parallel..."
47+
bun run format:check &
48+
LINT_PID=$!
49+
bun run build &
50+
BUILD_PID=$!
51+
52+
# Wait for both processes and capture exit codes
53+
wait $LINT_PID
54+
LINT_EXIT=$?
55+
wait $BUILD_PID
56+
BUILD_EXIT=$?
57+
58+
# Check if either failed
59+
if [ $LINT_EXIT -ne 0 ]; then
60+
echo "❌ Lint failed"
61+
exit $LINT_EXIT
62+
fi
9263
93-
- name: Build
94-
run: bun run build
64+
if [ $BUILD_EXIT -ne 0 ]; then
65+
echo "❌ Build failed"
66+
exit $BUILD_EXIT
67+
fi
9568
96-
- name: Upload build artifacts
97-
uses: actions/upload-artifact@v4
98-
with:
99-
name: build-artifacts
100-
path: dist/
69+
echo "✅ Lint and build completed successfully"
10170
102-
- name: Attest build artifacts
103-
if: github.ref == 'refs/heads/release' || github.ref == 'refs/heads/rc'
71+
- name: Attest Build Artifacts
72+
if: github.event_name == 'push' && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/rc')
10473
uses: actions/attest-build-provenance@v2
10574
with:
10675
subject-path: 'dist/*'
10776

108-
release:
109-
name: Release
110-
needs: build
111-
if: github.event_name == 'push' && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/rc')
112-
runs-on: ubuntu-latest
113-
steps:
114-
- name: Checkout
115-
uses: actions/checkout@v4
116-
with:
117-
fetch-depth: 0
118-
119-
- name: Setup Bun
120-
uses: oven-sh/setup-bun@v2
121-
with:
122-
bun-version: 1.2.15
123-
124-
- name: Cache Bun global packages
125-
uses: actions/cache@v4
126-
with:
127-
path: ~/.bun/install/cache
128-
key: ${{ runner.os }}-bun-${{ hashFiles('**/package.json') }}
129-
restore-keys: |
130-
${{ runner.os }}-bun-
131-
132-
- name: Cache Playwright browser binaries
133-
uses: actions/cache@v4
134-
with:
135-
path: ~/.cache/ms-playwright
136-
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package.json') }}
137-
restore-keys: |
138-
${{ runner.os }}-playwright-
139-
140-
- name: Install dependencies
141-
run: bun install
142-
143-
- name: Download build artifacts
144-
uses: actions/download-artifact@v4
145-
with:
146-
name: build-artifacts
147-
path: dist
148-
149-
- name: Configure git & npm
77+
- name: Release
78+
if: github.event_name == 'push' && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/rc')
15079
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15181
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
15282
run: |
83+
echo "🔧 Configuring git and npm..."
15384
git config --global user.email "github-actions[bot]@users.noreply.github.com"
154-
git config --global user.name "github-actions[bot]"
85+
git config --global user.name "github-actions[bot]"
15586
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
15687
157-
- name: Release
158-
env:
159-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160-
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
161-
run: |
16288
if [ "${{ github.ref }}" = "refs/heads/release" ]; then
163-
echo "Releasing stable version..."
89+
echo "🚀 Releasing stable version..."
16490
bun run release:ci
16591
elif [ "${{ github.ref }}" = "refs/heads/rc" ]; then
166-
echo "Releasing RC version..."
92+
echo "🚀 Releasing RC version..."
16793
bun run release:rc:ci
16894
fi

0 commit comments

Comments
 (0)