www/.github/workflows/ci-pipeline.yml
2025-06-22 17:30:13 +12:00

189 lines
5.2 KiB
YAML

name: CI Pipeline
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check_changes:
name: Check Changes
runs-on: ubuntu-latest
outputs:
exists: ${{ steps.filter.outputs.exists }}
steps:
- uses: actions/checkout@v4
- name: Check for relevant changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
exists:
- '!*.md'
- '!.gitignore'
- '!.gitattributes'
- '!.vscode/**'
quality_checks:
name: ${{ matrix.name }}
needs: [check_changes]
if: ${{ needs.check_changes.outputs.exists == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- check: lint
name: Lint
- check: format
name: Format
- check: test
name: Test
- check: spell
name: Spell Check
steps:
- uses: actions/checkout@v4
- name: Restore Turborepo Cache
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ matrix.check }}-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-turbo-${{ matrix.check }}-
${{ runner.os }}-turbo-
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run ${{ matrix.name }}
run: bunx turbo run ${{ matrix.check }}
build:
name: Build
needs: [check_changes]
if: ${{ needs.check_changes.outputs.exists == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Restore Turborepo Cache
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-build-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-turbo-build-
${{ runner.os }}-turbo-
- name: Restore Astro Cache
uses: actions/cache@v4
with:
path: |
.astro
node_modules/.astro
key: ${{ runner.os }}-astro-${{ hashFiles('**/bun.lock') }}
restore-keys: ${{ runner.os }}-astro-
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run Build
run: bunx turbo run build
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-dist
path: dist/
retention-days: 1
playwright:
name: Playwright Tests
needs: [check_changes, build]
if: ${{ needs.check_changes.outputs.exists == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-dist
path: dist/
- name: Restore Turborepo Cache
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-playwright-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-turbo-playwright-
${{ runner.os }}-turbo-
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Cache Playwright Browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/bun.lock') }}
restore-keys: ${{ runner.os }}-playwright-
- name: Install Playwright Browsers
run: bunx playwright install --with-deps
- name: Run Playwright Tests
run: bunx turbo run test:playwright
timeout-minutes: 8
- name: Upload Playwright Report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 7
verify:
name: Verify
needs: [check_changes, quality_checks, playwright]
runs-on: ubuntu-latest
if: always()
outputs:
success: ${{ steps.set-result.outputs.success }}
steps:
- name: Set Result
id: set-result
run: |
# Check if changes exist but no jobs ran, or if any job failed or was cancelled
if [[ "${{ needs.check_changes.outputs.exists }}" != "true" ]]; then
echo "success=true" >> $GITHUB_OUTPUT
echo "No relevant changes detected - pipeline passed"
elif [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "success=false" >> $GITHUB_OUTPUT
echo "Pipeline failed - some jobs failed or were cancelled"
exit 1
else
echo "success=true" >> $GITHUB_OUTPUT
echo "All jobs completed successfully"
fi