mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-23 01:57:29 +00:00
162 lines
5 KiB
YAML
162 lines
5 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
# Only run on pull requests that change relevant files
|
|
paths-ignore:
|
|
- '**.md'
|
|
- 'docs/**'
|
|
- '.gitignore'
|
|
- 'LICENSE.txt'
|
|
|
|
jobs:
|
|
# Fast job to install dependencies and cache them for other jobs
|
|
setup:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
cache-key: ${{ steps.cache-key.outputs.key }}
|
|
steps:
|
|
- 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: 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
|
|
# 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:
|
|
# CI: true
|
|
# - name: Upload Screenshot Diffs
|
|
# if: failure()
|
|
# uses: actions/upload-artifact@v4
|
|
# with:
|
|
# name: image_diffs
|
|
# path: packages/webamp/js/__tests__/__image_snapshots__/__diff_output__/
|
|
# - name: Generate New Screenshots
|
|
# if: failure()
|
|
# run: |
|
|
# yarn workspace webamp integration-tests -u
|
|
# - name: Upload New Screenshots
|
|
# if: failure()
|
|
# uses: actions/upload-artifact@v4
|
|
# with:
|
|
# name: new_images
|
|
# path: packages/webamp/js/__tests__/__image_snapshots__/
|
|
main-release:
|
|
name: Publish to NPM
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && github.repository == 'captbaritone/webamp'
|
|
needs: [build, lint, test]
|
|
steps:
|
|
- 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: |
|
|
echo "Setting version to 0.0.0-next-${RELEASE_COMMIT_SHA::7}"
|
|
yarn workspace webamp version --new-version 0.0.0-next-${RELEASE_COMMIT_SHA::7} --no-git-tag-version
|
|
env:
|
|
RELEASE_COMMIT_SHA: ${{ github.sha }}
|
|
- name: Build release version
|
|
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
|
|
run: exit 1 # TODO: Script to update version number in webampLazy.tsx
|
|
- name: Publish to npm
|
|
working-directory: ./packages/webamp
|
|
if: github.ref == 'refs/heads/master' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
|
|
# Use pre-built artifacts instead of rebuilding
|
|
run: |
|
|
npm publish ${TAG}
|
|
env:
|
|
TAG: ${{ github.ref == 'refs/heads/master' && '--tag=next' || ''}}
|
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|