diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d80241df..0849ee12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,28 @@ on: - 'LICENSE.txt' jobs: - # Build job - includes dependency installation and builds everything + # 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 @@ -38,13 +57,12 @@ jobs: path: | packages/*/built packages/*/dist - node_modules - key: build-cache-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }} + key: build-artifacts-${{ github.sha }} - # Lint job - reuses dependencies from build job + # Lint job - runs in parallel lint: runs-on: ubuntu-latest - needs: build + needs: setup steps: - uses: actions/checkout@v4 - name: Use Node.js 20.x @@ -52,24 +70,17 @@ jobs: with: node-version: 20.x cache: 'yarn' - - name: Restore dependencies and build cache - uses: actions/cache@v4 - with: - path: | - packages/*/built - packages/*/dist - node_modules - key: build-cache-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }} - fail-on-cache-miss: true + - name: Install Dependencies + run: yarn install --frozen-lockfile - name: Lint run: | yarn lint yarn workspace webamp type-check - # Test job - reuses dependencies from build job + # Test job - runs in parallel test: runs-on: ubuntu-latest - needs: build + needs: setup steps: - uses: actions/checkout@v4 - name: Use Node.js 20.x @@ -77,15 +88,8 @@ jobs: with: node-version: 20.x cache: 'yarn' - - name: Restore dependencies and build cache - uses: actions/cache@v4 - with: - path: | - packages/*/built - packages/*/dist - node_modules - key: build-cache-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }} - fail-on-cache-miss: true + - name: Install Dependencies + run: yarn install --frozen-lockfile - name: Run Unit Tests run: | touch packages/skin-database/config.js @@ -127,14 +131,15 @@ jobs: node-version: 20.x registry-url: https://registry.npmjs.org/ cache: 'yarn' - - name: Restore dependencies and build cache + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Restore build artifacts uses: actions/cache@v4 with: path: | packages/*/built packages/*/dist - node_modules - key: build-cache-${{ github.sha }}-${{ hashFiles('**/yarn.lock') }} + key: build-artifacts-${{ github.sha }} fail-on-cache-miss: true - name: Set version if: github.ref == 'refs/heads/master'