diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..c3e5729 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,39 @@ +# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs +name: CI + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +jobs: + test: + runs-on: ubuntu-latest + env: + # @devvit/test pulls in redis-memory-server, which by default downloads + # and compiles Redis (plus modules) from source on install and on first + # test run. That source build is slow and unreliable in CI. Point it at + # the prebuilt redis-server we install below: this both skips the + # install-time compile and makes the tests use the system binary. + REDISMS_SYSTEM_BINARY: /usr/bin/redis-server + steps: + - name: Checkout + uses: actions/checkout@v7.0.0 + - name: Install Node.js + uses: actions/setup-node@v6.4.0 + with: + node-version: 22.20.0 + - name: Install Redis + run: sudo apt-get update && sudo apt-get install -y redis-server + - name: Install Dependencies + run: npm install --no-fund + - parallel: + - name: Typecheck + run: npm run test:types + - name: Lint + run: npm run lint + - name: Unit Test + run: npm run test:unit + - name: Build + run: npm run build diff --git a/package.json b/package.json index 1eec728..dfad270 100644 --- a/package.json +++ b/package.json @@ -6,17 +6,18 @@ "type": "module", "scripts": { "build": "vite build", - "deploy": "npm run type-check && npm run lint && npm run test && devvit upload", + "deploy": "npm run test:types && npm run lint && npm run test:unit && devvit upload", "dev": "devvit playtest", "launch": "npm run deploy && devvit publish", "lint": "eslint 'src/**/*.{ts,tsx}'", "login": "devvit login", "prettier": "prettier-package-json --write ./package.json && prettier --write .", - "test": "vitest run", - "type-check": "tsc --build" + "test": "npm run test:types && npm run lint && npm run test:unit && npm run build", + "test:types": "tsc --build", + "test:unit": "vitest run" }, "engines": { - "node": ">=22.2.0" + "node": ">=22.12.0" }, "dependencies": { "@devvit/start": "0.13.10", @@ -45,6 +46,7 @@ "eslint": "10.8.0", "eslint-plugin-react-hooks": "7.1.1", "eslint-plugin-react-refresh": "0.5.3", + "globals": "17.8.0", "prettier": "3.9.6", "prettier-package-json": "2.8.0", "prettier-plugin-tailwindcss": "0.8.1",