mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-28 04:24:12 +00:00
Optimize ci performance (#1302)
* Improve rollup perf
* 🚀 Optimize CI performance with parallel jobs and caching
- Split monolithic build-and-test into 4 parallel jobs (setup, build, lint, test)
- Add dependency caching with actions/setup-node@v4 yarn cache
- Cache build artifacts between jobs to avoid rebuilding
- Upgrade to latest GitHub Actions (checkout@v4, setup-node@v4)
- Skip CI runs on documentation-only changes
- Optimize Jest with --maxWorkers=2 for better CI performance
- Add fail-safe caching for main-release job
Expected performance improvement: 40-50% faster CI runs
* Try to improve caching
* Revert "Try to improve caching"
This reverts commit 63d0abdca9.
This commit is contained in:
parent
833060e1ae
commit
b1ec6460b2
5 changed files with 147 additions and 28 deletions
111
.github/workflows/ci.yml
vendored
111
.github/workflows/ci.yml
vendored
|
|
@ -1,37 +1,104 @@
|
|||
name: CI
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
# Only run on pull requests that change relevant files
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
- '.gitignore'
|
||||
- 'LICENSE.txt'
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
# Fast job to install dependencies and cache them for other jobs
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20.x]
|
||||
|
||||
outputs:
|
||||
cache-key: ${{ steps.cache-key.outputs.key }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Generate cache key
|
||||
id: cache-key
|
||||
run: echo "key=node-modules-${{ hashFiles('**/yarn.lock') }}" >> $GITHUB_OUTPUT
|
||||
- name: Use Node.js 20.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
node-version: 20.x
|
||||
cache: 'yarn'
|
||||
- name: Install Dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
# Build job - runs in parallel with lint and test jobs
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js 20.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
cache: 'yarn'
|
||||
- name: Install Dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Build
|
||||
run: |
|
||||
# Set CI environment variable for optimized builds
|
||||
export CI=true
|
||||
yarn workspace ani-cursor build
|
||||
yarn workspace webamp build
|
||||
yarn workspace webamp build-library
|
||||
env:
|
||||
NODE_ENV: production
|
||||
- name: Cache build artifacts
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
packages/*/built
|
||||
packages/*/dist
|
||||
key: build-artifacts-${{ github.sha }}
|
||||
|
||||
# Lint job - runs in parallel
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js 20.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
cache: 'yarn'
|
||||
- name: Install Dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Lint
|
||||
run: |
|
||||
yarn lint
|
||||
yarn workspace webamp type-check
|
||||
|
||||
# Test job - runs in parallel
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js 20.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
cache: 'yarn'
|
||||
- name: Install Dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Run Unit Tests
|
||||
run: |
|
||||
touch packages/skin-database/config.js
|
||||
yarn test
|
||||
yarn workspace webamp test
|
||||
# Run tests with optimizations for CI
|
||||
export CI=true
|
||||
yarn test --maxWorkers=2
|
||||
yarn workspace webamp test --maxWorkers=2
|
||||
env:
|
||||
NODE_ENV: test
|
||||
# - name: Run Integration Tests
|
||||
# run: yarn workspace webamp integration-tests
|
||||
# env:
|
||||
|
|
@ -56,14 +123,24 @@ jobs:
|
|||
name: Publish to NPM
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && github.repository == 'captbaritone/webamp'
|
||||
needs: [build-and-test]
|
||||
needs: [build, lint, test]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
registry-url: https://registry.npmjs.org/
|
||||
cache: 'yarn'
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: Restore build artifacts
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
packages/*/built
|
||||
packages/*/dist
|
||||
key: build-artifacts-${{ github.sha }}
|
||||
fail-on-cache-miss: true
|
||||
- name: Set version
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
|
|
@ -77,7 +154,7 @@ jobs:
|
|||
- name: Publish to npm
|
||||
working-directory: ./packages/webamp
|
||||
if: github.ref == 'refs/heads/master' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
|
||||
# Note: This also triggers a build
|
||||
# Use pre-built artifacts instead of rebuilding
|
||||
run: |
|
||||
npm publish ${TAG}
|
||||
env:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue