Skip to content

Commit c073a03

Browse files
committed
feat: integrate Vitest for testing and update workflows
- Added Vitest as a testing framework in package.json and configured test scripts. - Created new test files for CLI and client functionalities, ensuring comprehensive coverage. - Updated GitHub Actions workflows to include testing steps and streamlined release process. - Removed the deprecated onRelease workflow to consolidate CI/CD processes.
1 parent 0869e2d commit c073a03

8 files changed

Lines changed: 978 additions & 45 deletions

File tree

.github/workflows/onPushToMain.yml

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# test
2-
name: version, tag and github release
1+
name: release and publish
32

43
on:
54
push:
@@ -10,47 +9,51 @@ jobs:
109
runs-on: ubuntu-latest
1110
steps:
1211
- uses: actions/checkout@v4
12+
with:
13+
token: ${{ secrets.GH_TOKEN }}
14+
15+
- uses: pnpm/action-setup@v6
16+
with:
17+
version: latest
18+
1319
- uses: actions/setup-node@v4
20+
with:
21+
node-version: latest
22+
cache: pnpm
23+
registry-url: https://registry.npmjs.org
24+
25+
- run: pnpm install
26+
- run: pnpm run build
27+
1428
- name: Check if version already exists
1529
id: version-check
1630
run: |
1731
package_version=$(node -p "require('./package.json').version")
1832
exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "")
1933
20-
if [ -n "$exists" ];
21-
then
34+
if [ -n "$exists" ]; then
2235
echo "Version v$package_version already exists"
23-
echo "::warning file=package.json,line=1::Version v$package_version already exists - no release will be created. If you want to create a new release, please update the version in package.json and push again."
2436
echo "skipped=true" >> $GITHUB_OUTPUT
2537
else
26-
echo "Version v$package_version does not exist. Creating release..."
38+
echo "Version v$package_version does not exist"
2739
echo "skipped=false" >> $GITHUB_OUTPUT
2840
echo "tag=v$package_version" >> $GITHUB_OUTPUT
2941
fi
3042
env:
3143
GH_TOKEN: ${{ secrets.GH_TOKEN }}
32-
- name: Setup git
33-
if: ${{ steps.version-check.outputs.skipped == 'false' }}
34-
run: |
35-
git config --global user.email ${{ secrets.GH_EMAIL }}
36-
git config --global user.name ${{ secrets.GH_USERNAME }}
37-
- name: Generate oclif README
38-
if: ${{ steps.version-check.outputs.skipped == 'false' }}
39-
id: oclif-readme
40-
run: |
41-
pnpm install
42-
pnpm exec oclif readme
43-
if [ -n "$(git status --porcelain)" ]; then
44-
git add .
45-
git commit -am "chore: update README.md"
46-
git push -u origin ${{ github.ref_name }}
47-
fi
44+
4845
- name: Create Github Release
46+
if: steps.version-check.outputs.skipped == 'false'
4947
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
50-
if: ${{ steps.version-check.outputs.skipped == 'false' }}
5148
with:
5249
name: ${{ steps.version-check.outputs.tag }}
5350
tag: ${{ steps.version-check.outputs.tag }}
5451
commit: ${{ github.ref_name }}
5552
token: ${{ secrets.GH_TOKEN }}
5653
skipIfReleaseExists: true
54+
55+
- name: Publish to npm
56+
if: steps.version-check.outputs.skipped == 'false'
57+
run: pnpm publish --no-git-checks
58+
env:
59+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/onRelease.yml

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

.github/workflows/test.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
name: tests
2+
23
on:
34
push:
45
branches-ignore: [main]
56
workflow_dispatch:
67

78
jobs:
8-
unit-tests:
9+
test:
910
strategy:
1011
matrix:
11-
os: ['ubuntu-latest', 'windows-latest']
12-
node_version: [lts/-1, lts/*, latest]
12+
os: [ubuntu-latest, windows-latest]
13+
node_version: [lts/*, latest]
1314
fail-fast: false
1415
runs-on: ${{ matrix.os }}
1516
steps:
1617
- uses: actions/checkout@v4
18+
- uses: pnpm/action-setup@v6
19+
with:
20+
version: latest
1721
- uses: actions/setup-node@v4
1822
with:
1923
node-version: ${{ matrix.node_version }}
2024
cache: pnpm
2125
- run: pnpm install
2226
- run: pnpm run build
27+
- run: pnpm run test

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"@biomejs/biome": "2.1.1",
2626
"@types/node": "^18",
2727
"tsx": "^4.21.0",
28-
"typescript": "^5"
28+
"typescript": "^5",
29+
"vitest": "^4.1.4"
2930
},
3031
"engines": {
3132
"node": ">=18.0.0"
@@ -48,6 +49,7 @@
4849
"prebuild": "pnpm run generate",
4950
"dev": "tsx src/index.ts",
5051
"lint": "biome check --write .",
52+
"test": "vitest run",
5153
"publish": "npm publish"
5254
},
5355
"types": "dist/index.d.ts"

0 commit comments

Comments
 (0)