Skip to content

Commit 923d7cc

Browse files
committed
Adding test workflows, basic test setup with vitest, update README
1 parent d2f9a53 commit 923d7cc

File tree

9 files changed

+1409
-67
lines changed

9 files changed

+1409
-67
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
9+
jobs:
10+
format-and-lint:
11+
name: Format & Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: pnpm/action-setup@v3
16+
with:
17+
version: 9.1.1
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: 'pnpm'
22+
- name: Install dependencies
23+
run: pnpm install
24+
- name: Format
25+
run: pnpm format
26+
- name: Lint
27+
run: pnpm lint:strict
28+
29+
test:
30+
name: Test
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: pnpm/action-setup@v3
35+
with:
36+
version: 9.1.1
37+
- uses: actions/setup-node@v4
38+
with:
39+
node-version: 20
40+
cache: 'pnpm'
41+
- name: Install dependencies
42+
run: pnpm install
43+
- name: Check types
44+
run: pnpm ts:check
45+
- name: Test
46+
run: pnpm test

.github/workflows/publish-to-npm.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
with:
1818
node-version: '20.x'
1919
registry-url: 'https://registry.npmjs.org'
20-
- name: Install Dependencies
20+
- name: Install dependencies
2121
run: pnpm install
22-
- name: Test
23-
run: pnpm test
22+
- name: Lint and test
23+
run: pnpm pre-publish
2424
- name: Build
2525
run: pnpm build
2626
- name: Publish

README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,30 @@ Please refer to `README.md` files in `src/components` for examples and documenta
3131

3232
## Contributing
3333

34-
TODO...
34+
Run these commands to begin local development and watch for changes:
3535

36-
## Local Development
36+
```bash
37+
pnpm dev
38+
pnpm test:watch
39+
```
40+
41+
- Create a branch off of `main`
42+
- Test your local changes
43+
- Push a PR for review
44+
45+
_NOTE: A development preview environment for the component library will be developed soon: https://github.com/near/pagoda-ui/issues/6_
46+
47+
## Test Local Changes
48+
49+
Follow these steps to preview local changes to the UI library within any project that depends on the library:
3750

38-
Due to this library having peer dependencies, `pnpm link` isn't compatible. Follow these steps to preview local changes to the UI library within any project:
51+
- Have your project and the UI library cloned as siblings. EG: `projects/cool-project` and `projects/pagoda-ui`.
52+
- Inside `pagoda-ui`, run `pnpm dev`.
53+
- Inside your project folder, run `pnpm add file:../pagoda-ui`.
54+
- After making any changes to `pagoda-ui`, you will need to restart your project's development server for the component changes to appear locally within your project.
55+
- Once you're done testing changes, make sure you revert the changes in your project's `package.json` and lock file so that you're no longer referencing the local file protocol (eg: `file:../pagoda-ui`).
3956

40-
- Have your project and the UI library cloned as siblings. EG: `projects/cool-project` and `projects/pagoda-ui`
41-
- Inside `pagoda-ui`, make sure you've installed dependencies and build your changes with `pnpm i` and `pnpm build`
42-
- Inside your project folder, run `pnpm add file:../pagoda-ui` and then boot up your dev server
43-
- After making any changes to `pagoda-ui`, make sure you run `pnpm build` to then see changes when previewing your project
44-
- Once you're done previewing changes, make sure you revert changes to the `package.json` and lock file in your project so that it no longer references `file:../pagoda-ui`.
57+
_NOTE: Due to this library having peer dependencies, `pnpm link` isn't compatible - that's why we have to rely on using `file:` instead._
4558

4659
## Publishing a Release
4760

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
"format:fix": "prettier --write ./src",
2222
"lint": "eslint ./src/**/*.ts*",
2323
"lint:fix": "eslint . --fix",
24-
"pre-commit": "pnpm format && pnpm lint --max-warnings 0 && pnpm ts:check",
25-
"test": "pnpm pre-commit",
24+
"lint:strict": "pnpm lint --max-warnings 0",
25+
"pre-commit": "pnpm format && pnpm lint:strict && pnpm ts:check",
26+
"pre-publish": "pnpm pre-commit && pnpm test",
27+
"test": "vitest run",
28+
"test:watch": "vitest",
2629
"ts:check": "tsc --noEmit --incremental",
2730
"prepare": "husky"
2831
},
@@ -76,6 +79,8 @@
7679
"@rollup/plugin-node-resolve": "^13.3.0",
7780
"@rollup/plugin-terser": "^0.4.4",
7881
"@rollup/plugin-typescript": "^8.3.4",
82+
"@testing-library/dom": "^10.4.0",
83+
"@testing-library/react": "^16.0.0",
7984
"@types/lodash-es": "^4.17.12",
8085
"@types/node": "^20",
8186
"@types/react": "^18.2.34",
@@ -85,6 +90,7 @@
8590
"eslint-config-prettier": "^9",
8691
"eslint-plugin-simple-import-sort": "^12.1.0",
8792
"husky": "^9.1.3",
93+
"jsdom": "^24.1.1",
8894
"postcss": "^8.4.40",
8995
"postcss-preset-env": "^7.6.0",
9096
"postcss-scss": "^4.0.9",
@@ -96,6 +102,7 @@
96102
"rollup-plugin-postcss": "^4.0.2",
97103
"sass": "^1.77.8",
98104
"tslib": "^2.6.2",
99-
"typescript": "^5"
105+
"typescript": "^5",
106+
"vitest": "^2.0.5"
100107
}
101108
}

0 commit comments

Comments
 (0)