54 lines
1.7 KiB
YAML
54 lines
1.7 KiB
YAML
name: Frontend Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [master, main]
|
|
pull_request:
|
|
branches: [master, main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 22
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
# The metadata generator scans wokwi-elements/src/, which only ships in
|
|
# the upstream repo (not on npm). Clone it once for the freshness check.
|
|
- name: Clone wokwi-elements (for metadata regeneration only)
|
|
run: git clone --depth=1 https://github.com/wokwi/wokwi-elements.git third-party/wokwi-elements
|
|
|
|
- name: Cache frontend node_modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: frontend/node_modules
|
|
key: frontend-${{ hashFiles('frontend/package-lock.json') }}
|
|
|
|
- name: Install frontend dependencies
|
|
run: cd frontend && npm install
|
|
|
|
- name: Install root dev dependencies
|
|
run: npm install
|
|
|
|
# Regenerate metadata and fail if committed JSON is stale. Catches PRs
|
|
# that modify component-overrides.json without running generate:metadata.
|
|
- name: Regenerate component metadata
|
|
run: cd frontend && npm run generate:metadata
|
|
|
|
- name: Fail if components-metadata.json is out of date
|
|
run: |
|
|
if ! git diff --quiet frontend/public/components-metadata.json; then
|
|
echo "::error::components-metadata.json is stale. Run 'cd frontend && npm run generate:metadata' and commit the result."
|
|
git diff frontend/public/components-metadata.json | head -100
|
|
exit 1
|
|
fi
|
|
|
|
- name: Run tests
|
|
run: cd frontend && npm test
|