11name : CI
22
3- on : [push]
3+ on :
4+ push :
5+ pull_request :
6+ # Only run on pull requests that change relevant files
7+ paths-ignore :
8+ - ' **.md'
9+ - ' docs/**'
10+ - ' .gitignore'
11+ - ' LICENSE.txt'
412
513jobs :
6- build-and-test :
14+ # Fast job to install dependencies and cache them for other jobs
15+ setup :
716 runs-on : ubuntu-latest
17+ outputs :
18+ cache-key : ${{ steps.cache-key.outputs.key }}
19+ steps :
20+ - uses : actions/checkout@v4
21+ - name : Generate cache key
22+ id : cache-key
23+ run : echo "key=node-modules-${{ hashFiles('**/yarn.lock') }}" >> $GITHUB_OUTPUT
24+ - name : Use Node.js 20.x
25+ uses : actions/setup-node@v4
26+ with :
27+ node-version : 20.x
28+ cache : ' yarn'
29+ - name : Install Dependencies
30+ run : yarn install --frozen-lockfile
831
9- strategy :
10- matrix :
11- node-version : [20.x]
12-
32+ # Build job - runs in parallel with lint and test jobs
33+ build :
34+ runs-on : ubuntu-latest
35+ needs : setup
1336 steps :
14- - uses : actions/checkout@v2
15- - name : Use Node.js ${{ matrix.node-version }}
16- uses : actions/setup-node@v2
37+ - uses : actions/checkout@v4
38+ - name : Use Node.js 20.x
39+ uses : actions/setup-node@v4
1740 with :
18- node-version : ${{ matrix.node-version }}
41+ node-version : 20.x
42+ cache : ' yarn'
1943 - name : Install Dependencies
2044 run : yarn install --frozen-lockfile
2145 - name : Build
2246 run : |
47+ # Set CI environment variable for optimized builds
48+ export CI=true
2349 yarn workspace ani-cursor build
2450 yarn workspace webamp build
2551 yarn workspace webamp build-library
52+ env :
53+ NODE_ENV : production
54+ - name : Cache build artifacts
55+ uses : actions/cache@v4
56+ with :
57+ path : |
58+ packages/*/built
59+ packages/*/dist
60+ key : build-artifacts-${{ github.sha }}
61+
62+ # Lint job - runs in parallel
63+ lint :
64+ runs-on : ubuntu-latest
65+ needs : setup
66+ steps :
67+ - uses : actions/checkout@v4
68+ - name : Use Node.js 20.x
69+ uses : actions/setup-node@v4
70+ with :
71+ node-version : 20.x
72+ cache : ' yarn'
73+ - name : Install Dependencies
74+ run : yarn install --frozen-lockfile
2675 - name : Lint
2776 run : |
2877 yarn lint
2978 yarn workspace webamp type-check
79+
80+ # Test job - runs in parallel
81+ test :
82+ runs-on : ubuntu-latest
83+ needs : setup
84+ steps :
85+ - uses : actions/checkout@v4
86+ - name : Use Node.js 20.x
87+ uses : actions/setup-node@v4
88+ with :
89+ node-version : 20.x
90+ cache : ' yarn'
91+ - name : Install Dependencies
92+ run : yarn install --frozen-lockfile
3093 - name : Run Unit Tests
3194 run : |
3295 touch packages/skin-database/config.js
33- yarn test
34- yarn workspace webamp test
96+ # Run tests with optimizations for CI
97+ export CI=true
98+ yarn test --maxWorkers=2
99+ yarn workspace webamp test --maxWorkers=2
100+ env :
101+ NODE_ENV : test
35102 # - name: Run Integration Tests
36103 # run: yarn workspace webamp integration-tests
37104 # env:
@@ -56,14 +123,24 @@ jobs:
56123 name : Publish to NPM
57124 runs-on : ubuntu-latest
58125 if : github.event_name == 'push' && github.repository == 'captbaritone/webamp'
59- needs : [build-and- test]
126+ needs : [build, lint, test]
60127 steps :
61- - uses : actions/checkout@v2
62- - uses : actions/setup-node@v2
128+ - uses : actions/checkout@v4
129+ - uses : actions/setup-node@v4
63130 with :
131+ node-version : 20.x
64132 registry-url : https://registry.npmjs.org/
133+ cache : ' yarn'
65134 - name : Install dependencies
66135 run : yarn install --frozen-lockfile
136+ - name : Restore build artifacts
137+ uses : actions/cache@v4
138+ with :
139+ path : |
140+ packages/*/built
141+ packages/*/dist
142+ key : build-artifacts-${{ github.sha }}
143+ fail-on-cache-miss : true
67144 - name : Set version
68145 if : github.ref == 'refs/heads/master'
69146 run : |
77154 - name : Publish to npm
78155 working-directory : ./packages/webamp
79156 if : github.ref == 'refs/heads/master' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
80- # Note: This also triggers a build
157+ # Use pre-built artifacts instead of rebuilding
81158 run : |
82159 npm publish ${TAG}
83160 env :
0 commit comments