Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/run-tests-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Run test on PR

on:
pull_request:
branches: [main]
jobs:
build:
name: test code
timeout-minutes: 15
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2

- uses: pnpm/action-setup@v2.0.1
with:
version: 6.32.2

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: "16.x"
cache: "pnpm"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Test
run: pnpm test

- name: Build
run: pnpm publish-build
14 changes: 6 additions & 8 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"types": "dist/types/index.d.ts",
"private": false,
"repository": {
"url": "https://github.com/antstackio/hover-design.git",
"type": "git",
"directory": "lib"
"url": "git+https://github.com/antstackio/hover-design.git"
},
"keywords": [
"react",
Expand All @@ -29,7 +28,9 @@
"tsc": "tsc",
"ladle": "ladle serve",
"serve": "vite preview",
"watch": "nodemon --watch src/ -e ts,tsx --exec \"tsc && vite build && tsc --emitDeclarationOnly\""
"watch": "nodemon --watch src/ -e ts,tsx --exec \"tsc && vite build && tsc --emitDeclarationOnly\"",
"test": "vitest",
"coverage": "vitest run --coverage"
},
"dependencies": {
"@ladle/react": "^2.3.0",
Expand All @@ -53,16 +54,13 @@
"typescript": "^4.3.2",
"vite": "^2.6.4",
"vite-plugin-dts": "^0.9.9",
"vite-tsconfig-paths": "^3.4.0"
"vite-tsconfig-paths": "^3.4.0",
"vitest": "^0.23.4"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/antstackio/hover-design.git"
},
"publishConfig": {
"access": "public"
}
Expand Down
9 changes: 9 additions & 0 deletions lib/src/utils/tests/object-utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { describe, test, expect } from "vitest";
import { eliminateUndefinedKeys } from "../object-utils";
describe("Object Utils Test", () => {
test("should eliminate undefined keys", () => {
const record = { a: 1, b: undefined, c: 3 };
const eliminated = eliminateUndefinedKeys(record);
expect(eliminated).toEqual({ a: 1, c: 3 });
});
});
16 changes: 8 additions & 8 deletions lib/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ export default defineConfig({
plugins: [
react(),
vanillaExtractPlugin({ identifiers: "short" }),
tsconfigPaths()
tsconfigPaths(),
],
resolve: {
alias: [{ find: "src", replacement: resolve(__dirname, "src") }]
alias: [{ find: "src", replacement: resolve(__dirname, "src") }],
},
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
fileName: (format) => `hover-react.${format}.js`,
formats: ["es"],
name: "@hover-design/react"
name: "@hover-design/react",
},
rollupOptions: {
external: Object.keys(pkg.peerDependencies),
output: {
globals: {
react: "React"
}
}
}
}
react: "React",
},
},
},
},
});
13 changes: 13 additions & 0 deletions lib/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { mergeConfig } from "vite";
import { defineConfig } from "vitest/config";
import viteConfig from "./vite.config";

export default mergeConfig(
viteConfig,
defineConfig({
test: {
exclude: ["dist/*", ".turbo/*", "node_modules/*"],
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
},
})
);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"scripts": {
"prebuild": "test \"$CI\" = true && npx pnpm install -r --store=node_modules/.pnpm-store || echo skiping pnpm install",
"build": "turbo run build",
"test": "turbo run test",
"dev": "turbo run dev --no-cache --parallel --continue",
"publish-build": "turbo run build --scope=@hover-design/react --no-deps --include-dependencies",
"ladle": "turbo run ladle --scope=@hover-design/react --no-deps --include-dependencies"
Expand Down
Loading