Skip to content

ALF Automation

ALF Automation #1817

Workflow file for this run

name: build-test
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, labeled, ready_for_review]
push:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 60
env:
VITE_MAPBOX_TOKEN: ${{ secrets.VITE_MAPBOX_TOKEN }}
steps:
- uses: actions/cache@v3
id: check-cache
with:
lookup-only: true
path: dist
key: build-cache-${{ github.sha }}
- name: Checkout
uses: actions/checkout@v3
if: steps.check-cache.outputs.cache-hit != 'true'
with:
lfs: true
- name: Install pnpm
if: steps.check-cache.outputs.cache-hit != 'true'
run: |
corepack enable
corepack prepare pnpm@8.9.2 --activate
- name: Install Node.js
if: steps.check-cache.outputs.cache-hit != 'true'
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
if: steps.check-cache.outputs.cache-hit != 'true'
run: pnpm install
- name: Run code checks
if: steps.check-cache.outputs.cache-hit != 'true'
run: |
pnpm run lint
pnpm run check
- name: Run build script for test output
if: steps.check-cache.outputs.cache-hit != 'true'
run: pnpm run build
env:
THUMBNAIL_DATA_TYPE: datauri
- name: Cache build output
if: steps.check-cache.outputs.cache-hit != 'true'
id: cache-build
uses: actions/cache/save@v3
with:
path: |
dist
.svelte-kit
key: build-cache-${{ github.sha }}
- name: Run unit tests
if: steps.check-cache.outputs.cache-hit != 'true'
run: pnpm run test:unit
snapshot_test:
name: Snapshot testing
needs: build
runs-on: ubuntu-22.04
# Run if:
# - we push to main (so that we can set the baseline in Percy)
# - we open up a pull request that's not a draft
# - we mark a pull request as ready for review
# - we label a pull request with the snapshot requested tag
if: ${{ (github.event_name == 'workflow_dispatch') || (github.ref == 'refs/heads/main' && github.event_name == 'push') || (!github.event.pull_request.draft && github.event.action == 'opened') || github.event.action == 'ready_for_review' || (github.event.action == 'labeled' && github.event.label.name == vars.SNAPSHOT_TRIGGER_LABEL) }}
timeout-minutes: 60
env:
PERCY_POSTINSTALL_BROWSER: true
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
VITE_MAPBOX_TOKEN: ${{ secrets.VITE_MAPBOX_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true
- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@8.9.2 --activate
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Download git LFS files
run: git lfs pull
- name: Restore build cache
id: restore-build-cache
uses: actions/cache/restore@v3
with:
path: |
dist
.svelte-kit
key: build-cache-${{ github.sha }}
- name: Get Playwright version
id: playwright-version
run: |
PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test | grep @playwright | sed 's/.*@//' | sed 's/\//-/g' | sed 's/ /-/g')
echo "Playwright version: $PLAYWRIGHT_VERSION"
echo "version=$PLAYWRIGHT_VERSION" >> ${GITHUB_OUTPUT}
- name: Cache Playwright browsers
id: cache-playwright-browsers
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ steps.playwright-version.outputs.version }}
- name: Setup Playwright (cache miss)
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Setup Playwright (cache hit)
if: steps.cache-playwright-browsers.outputs.cache-hit == 'true'
run: npx playwright install
- name: Run end-to-end tests
run: npx percy exec -- playwright test
- uses: actions-ecosystem/action-remove-labels@v1
with:
labels: ${{ vars.SNAPSHOT_TRIGGER_LABEL }}
- name: Upload Playwright trace
uses: actions/upload-artifact@v3
if: failure()
with:
name: test-results
path: test-results/
retention-days: 7