Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test

on:
pull_request:
branches:
- main

jobs:
template-test-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- uses: actions/setup-node@v6
with:
node-version: 22

- name: Install dependencies
run: npm ci

- name: Run template tests
run: npm run test

- name: Check that code builds
run: npm run build
47 changes: 47 additions & 0 deletions .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Version Check

on:
pull_request:
branches:
- main

jobs:
version-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Check version bump
id: check-version
run: |
git fetch origin main
git fetch --tags origin main
if ! git diff origin/main package.json | grep '"version":'; then
echo "ERROR: package.json version must be bumped"
exit 1
fi
VERSION=$(jq -r '.version' package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Check for git tag on commit
id: check-tag
run: |
# Get tags pointing at HEAD
TAG=$(git tag --points-at HEAD | head -n1)
if [ -z "$TAG" ]; then
echo "ERROR: Commit must be tagged with a version before merging to main"
exit 1
fi
echo "Found tag(s): $TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT

- name: Check that tag matches version
run: |
if [ "$TAG" != "v$VERSION" ]; then
echo "ERROR: Git tag ($TAG) does not match package.json version (v$VERSION)"
exit 1
fi
echo "Git tag matches package.json version ✅"
env:
VERSION: ${{ steps.check-version.outputs.version }}
TAG: ${{ steps.check-tag.outputs.tag }}
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
# . "$(dirname -- "$0")/_/husky.sh"
9 changes: 9 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"

npm run test
CHANGED=$(git diff origin/main package.json | grep '"version":')
if [ -z "$CHANGED" ]; then
echo "ERROR: You must update package.json version before pushing to main!"
exit 1
fi
Loading
Loading