Skip to content

[6.x] Parallelize GitHub Actions steps #1086

[6.x] Parallelize GitHub Actions steps

[6.x] Parallelize GitHub Actions steps #1086

Workflow file for this run

name: 'ci / Front End'
on:
workflow_dispatch:
push:
branches:
- main
- 6.x
pull_request:
concurrency:
group: js-ci-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: '24'
PHP_VERSION: '8.5'
permissions:
contents: read
jobs:
setup:
name: 'Build + Check'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
- name: Setup Vite+
uses: voidzero-dev/setup-vp@v1
with:
node-version: ${{ env.NODE_VERSION }}
cache: true
- name: Compute cache key
id: cache-key
# Hash everything that can affect installed deps, the cp build, or the
# generated TS/wayfinder files. PHP source is included because both
# `testbench typescript:transform` and `testbench wayfinder:generate`
# derive their output from controllers, DTOs, and routes in src/.
run: |
echo "value=js-ci-v3-${{ runner.os }}-${{ hashFiles('package-lock.json', 'composer.lock', 'package.json', 'packages/*/package.json', 'packages/craftcms-ui/src/**', 'packages/craftcms-ui/tsconfig*.json', 'packages/craftcms-ui/vite.config.*', 'packages/craftcms-ui/tsdown.config.*', 'packages/craftcms-garnish/src/**', 'packages/craftcms-garnish/tsconfig*.json', 'packages/craftcms-garnish/vite.config.*', 'src/**/*.php', 'workbench/**/*.php') }}" >> "$GITHUB_OUTPUT"
- name: Restore install + build + generated cache
id: cache
uses: actions/cache@v4
with:
path: |
node_modules
packages/*/node_modules
packages/craftcms-ui/dist
packages/craftcms-garnish/dist
vendor
resources/js/actions
resources/js/routes
resources/js/wayfinder
resources/js/generated
key: ${{ steps.cache-key.outputs.value }}
- parallel:
- name: Install Composer dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: composer install --no-interaction --no-progress
- name: Install frontend dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: vp install --frozen-lockfile
env:
CRAFT_FONTAWESOME_TOKEN: ${{ secrets.CRAFT_FONTAWESOME_TOKEN }}
# Build the garnish package so its `dist/*.d.ts` exist — `vue-tsc` resolves
# `@craftcms/garnish` from `dist` (its `types`), and dist is gitignored.
# Without this the typecheck job fails to resolve the module.
- name: Build @craftcms/garnish
if: steps.cache.outputs.cache-hit != 'true'
run: vp run build:garnish
- name: Build @craftcms/ui
if: steps.cache.outputs.cache-hit != 'true'
run: vp run build:ui
# `build:cp` does not produce the Custom Elements Manifest (only the
# Storybook pre-hooks do), so generate it explicitly — it lands in the
# packages/craftcms-cp/dist cache path above for the downstream jobs.
- name: Build Custom Elements Manifest
if: steps.cache.outputs.cache-hit != 'true'
run: vp run @craftcms/ui#build:manifest
- name: Generate TypeScript types
if: steps.cache.outputs.cache-hit != 'true'
run: vp run generate:types
- name: Generate Wayfinder routes
if: steps.cache.outputs.cache-hit != 'true'
run: vp run generate:wayfinder
# `vp run` skips the npm pretypecheck hook, which would redundantly run
# generate:types and generate:wayfinder.
# The Storybook tests run headlessly via @vitest/browser-playwright, so
# the full headed Chromium build is unnecessary.
- name: Install Playwright Chromium
run: vp exec playwright install --with-deps --only-shell chromium
- parallel:
- name: Run Oxlint
run: vp lint resources/js/
- name: Run TypeScript type check
run: vp run typecheck
- name: Run @craftcms/ui tests
run: vp run test:ui