diff --git a/.github/workflows/experiment-tests.yml b/.github/workflows/experiment-tests.yml new file mode 100644 index 00000000..07485bf9 --- /dev/null +++ b/.github/workflows/experiment-tests.yml @@ -0,0 +1,45 @@ +name: Experiment Tests + +# Runs on every PR to main (and pushes to main) that touch the experiment app, so +# a broken change is caught here rather than by the post-merge image build. +on: + push: + branches: + - main + paths: + - 'experiment/**' + - '.github/workflows/experiment-tests.yml' + pull_request: + branches: + - main + paths: + - 'experiment/**' + - '.github/workflows/experiment-tests.yml' + workflow_dispatch: + +# Least privilege: these jobs only need to read the repo to check it out. +permissions: + contents: read + +defaults: + run: + working-directory: experiment + +jobs: + unit: + name: Unit tests (Vitest) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: lts/* + cache: npm + cache-dependency-path: experiment/package-lock.json + - name: Install dependencies + run: npm ci + - name: Typecheck + run: npm run typecheck + # `npm test` is watch mode in this package; test:run is the one-shot script. + - name: Run unit tests + run: npm run test:run diff --git a/.husky/pre-push b/.husky/pre-push deleted file mode 100755 index f59bd2b3..00000000 --- a/.husky/pre-push +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env sh - -# Get the remote ref being pushed to -remote="$1" -url="$2" - -# Read stdin to get local and remote refs -while read local_ref local_sha remote_ref remote_sha; do - # Check if pushing to main branch - if [ "$remote_ref" = "refs/heads/main" ]; then - echo "🔍 Pushing to main - running typecheck for experiment..." - - # Run typecheck in experiment directory - cd experiment && npm run typecheck - - # Capture exit code - TYPECHECK_EXIT=$? - - if [ $TYPECHECK_EXIT -ne 0 ]; then - echo "❌ Type check failed! Fix errors or use --no-verify to skip." - exit 1 - fi - - echo "✅ Type check passed!" - fi -done - -exit 0 diff --git a/package-lock.json b/package-lock.json index fa45efe2..33c1165b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,26 +6,7 @@ "packages": { "": { "name": "writing-tools", - "version": "1.0.0", - "devDependencies": { - "husky": "^9.0.0" - } - }, - "node_modules/husky": { - "version": "9.1.7", - "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", - "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", - "dev": true, - "license": "MIT", - "bin": { - "husky": "bin.js" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } + "version": "1.0.0" } } } diff --git a/package.json b/package.json index 187736dd..7aa79e1b 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,5 @@ "name": "writing-tools", "version": "1.0.0", "private": true, - "description": "Writing tools monorepo", - "scripts": { - "prepare": "husky" - }, - "devDependencies": { - "husky": "^9.0.0" - } + "description": "Writing tools monorepo. No root build: each app (frontend, backend, experiment) has its own package.json." }