diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..6c33db7 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: CI + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "**" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [22.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm run ci-project + #- run: npm run build --if-present + - run: npm test diff --git a/package.json b/package.json index 0e94b39..fc17de9 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "scripts": { "gen-package": "node package.json.js", "install-project": "npm run gen-package && npm install --force", + "ci-project": "npm ci --force", "node": "node --import=tsx", "repl": "tsx", "plop": "NODE_OPTIONS=\"--import tsx\" plop", @@ -41,11 +42,11 @@ "build": "vite --config=./vite.config.ts --emptyOutDir build", "storybook:serve": "storybook dev -p 6006", "storybook:build": "storybook build --docs", - "check-types": "tsc --noEmit", + "check:types": "tsc --noEmit", "lint:style": "stylelint 'src/**/*.scss'", "lint:script": "biome", "lint": "npm run list:style && npm run lint:script", - "test": "vitest run --root=.", + "test": "npm run check:types", "test-ui": "vitest --ui", "coverage": "vitest run --coverage", "start": "npm run storybook:serve", diff --git a/package.json.js b/package.json.js index 5d5f564..11769db 100644 --- a/package.json.js +++ b/package.json.js @@ -38,7 +38,9 @@ const packageConfig = { scripts: { // Utilities 'gen-package': 'node package.json.js', // Update `package.json` + // Use --force currently since we're using React v19 rc. Once peer deps are updated remove this. 'install-project': 'npm run gen-package && npm install --force', + 'ci-project': 'npm ci --force', // CLI 'node': 'node --import=tsx', @@ -59,14 +61,15 @@ const packageConfig = { 'storybook:build': 'storybook build --docs', // Static analysis - 'check-types': 'tsc --noEmit', + 'check:types': 'tsc --noEmit', 'lint:style': `stylelint 'src/**/*.scss'`, 'lint:script': 'biome', 'lint': 'npm run list:style && npm run lint:script', // Test // Note: use `vitest run --root=. src/...` to run a single test file - 'test': 'vitest run --root=.', // Need to specify `--root=.` since the vite root is set to `./app` + //'test': 'vitest run --root=.', // Need to specify `--root=.` since the vite root is set to `./app` + 'test': 'npm run check:types', 'test-ui': 'vitest --ui', 'coverage': 'vitest run --coverage',