diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..10e7193 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,30 @@ +# 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 + 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 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 2f5bbd5..c85a24d 100644 --- a/package.json +++ b/package.json @@ -6,16 +6,17 @@ "type": "module", "scripts": { "build": "vite build", - "deploy": "npm run type-check && npm run lint && devvit upload", + "deploy": "npm run test:types && npm run lint && devvit upload", "dev": "devvit playtest", "launch": "npm run deploy && devvit publish", "lint": "eslint 'src/**/*.{ts,tsx}'", "login": "devvit login", "prettier": "prettier --write .", - "type-check": "tsc --build" + "test:types": "tsc --build", + "test:unit": "node --experimental-strip-types --no-warnings=ExperimentalWarning --test \"src/**/*.test.ts\"" }, "engines": { - "node": ">=22.2.0" + "node": ">=22.12.0" }, "dependencies": { "@devvit/start": "0.13.10", @@ -30,7 +31,7 @@ "eslint": "10.8.0", "globals": "17.8.0", "prettier": "3.9.6", - "typescript": "7.0.2", + "typescript": "6.0.3", "typescript-eslint": "8.65.0", "vite": "8.1.5" } diff --git a/src/core/nuke.ts b/src/core/nuke.ts index be7df74..2d779ea 100644 --- a/src/core/nuke.ts +++ b/src/core/nuke.ts @@ -47,7 +47,7 @@ async function* getAllCommentsInPost( export async function handleNukePost(props: NukePostProps) { const startTime = Date.now(); - let success = true; + let success: boolean; let message: string; const shouldLock = props.lock; @@ -133,7 +133,7 @@ export async function handleNukePost(props: NukePostProps) { export async function handleNuke(props: NukeProps) { const startTime = Date.now(); - let success = true; + let success: boolean; let message: string; const shouldLock = props.lock;