Skip to content

Commit 8570d21

Browse files
committed
🐎 ci: Add CI workflow for type checking, linting, and testing
1 parent 25edaca commit 8570d21

File tree

5 files changed

+95
-41
lines changed

5 files changed

+95
-41
lines changed

.github/workflows/ci.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
typecheck:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout the repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: lts/*
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Typecheck
28+
run: npm run typecheck
29+
30+
lint:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout the repository
34+
uses: actions/checkout@v4
35+
36+
- name: Set up Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: lts/*
40+
41+
- name: Install dependencies
42+
run: npm ci
43+
44+
- name: Lint
45+
run: npm run lint
46+
47+
test:
48+
runs-on: ubuntu-latest
49+
50+
strategy:
51+
matrix:
52+
node-version: [18.x, 20.x, 22.x]
53+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
54+
55+
steps:
56+
- name: Checkout the repository
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Node.js ${{ matrix.node-version }}
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: ${{ matrix.node-version }}
63+
cache: "npm"
64+
65+
- name: Install dependencies
66+
run: npm ci --ignore-scripts
67+
68+
- name: Test types
69+
run: npm run test-types
70+
71+
- name: Test
72+
run: npm run test:cov
73+
74+
- name: Report Coveralls
75+
run: curl -sL https://coveralls.io/coveralls-linux.tar.gz | tar -xz && ./coveralls
76+
env:
77+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Handle side effects in a <strong>unified</strong> way, with <strong>type-safety<
1515
<a href="https://bundlephobia.com/package/tinyeffect">
1616
<img src="https://img.shields.io/bundlephobia/minzip/tinyeffect.svg" alt="minzipped size" height="18">
1717
</a>
18-
<a href="https://github.com/Snowflyt/tinyeffect/actions/workflows/test.yml">
19-
<img src="https://github.com/Snowflyt/tinyeffect/actions/workflows/test.yml/badge.svg" alt="test status" height="18">
18+
<a href="https://github.com/Snowflyt/tinyeffect/actions/workflows/ci.yml">
19+
<img src="https://img.shields.io/github/actions/workflow/status/Snowflyt/tinyeffect/ci.yml?label=test" alt="test status" height="18">
2020
</a>
2121
<a href="https://coveralls.io/github/Snowflyt/tinyeffect?branch=main">
2222
<img src="https://coveralls.io/repos/github/Snowflyt/tinyeffect/badge.svg?branch=main" alt="coverage status" height="18">
2323
</a>
24-
<a href="https://github.com/gvergnaud/tinyeffect">
24+
<a href="https://github.com/Snowflyt/tinyeffect">
2525
<img src="https://img.shields.io/npm/l/tinyeffect.svg" alt="MIT license" height="18">
2626
</a>
2727
</p>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@
3838
"lint:fix": "eslint --fix **/*.{js,ts} *.{cjs,mjs,cts,mts} --no-error-on-unmatched-pattern --report-unused-disable-directives-severity error --max-warnings 0",
3939
"prepare": "node -e \"import fs from 'fs'; import path from 'path'; const hooksDir = path.join(process.cwd(), '.githooks'); const gitHooksDir = path.join(process.cwd(), '.git/hooks'); if (!fs.existsSync(gitHooksDir)) { console.error('Git hooks directory not found, please run this in a git repository.'); process.exit(1); } fs.readdirSync(hooksDir).forEach(file => { const srcFile = path.join(hooksDir, file); const destFile = path.join(gitHooksDir, file); fs.copyFileSync(srcFile, destFile); if (process.platform !== 'win32' && !file.endsWith('.cmd')) { fs.chmodSync(destFile, 0o755); } })\"",
4040
"test": "vitest run",
41+
"test-types": "typroof",
4142
"test:cov": "vitest run --coverage --coverage.include \"src/**/!(*.proof).{js,ts}\"",
4243
"test:ui": "vitest --ui --coverage.enabled=true --coverage.include \"src/**/!(*.proof).{js,ts}\"",
4344
"test:watch": "vitest",
4445
"test:watch-cov": "vitest --coverage --coverage.include \"src/**/!(*.proof).{js,ts}\"",
45-
"test-types": "typroof"
46+
"typecheck": "tsc --noEmit --composite false -p tsconfig.build.json && tsc --noEmit --composite false -p tsconfig.test.json"
4647
},
4748
"devDependencies": {
4849
"@commitlint/cli": "^19.8.0",

test/test-env.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Fix TypeScript’s complaint about missing types
2+
3+
// For Vitest
4+
// See: https://github.com/vitejs/vite/issues/9813
5+
declare interface Worker {}
6+
declare interface WebSocket {}
7+
8+
declare namespace WebAssembly {
9+
interface Module {}
10+
}
11+
12+
// For Effect
13+
declare interface QueuingStrategy<T> {}

0 commit comments

Comments
 (0)