Skip to content

Commit bb8494a

Browse files
authored
Various CI (#6)
1 parent d7bf3b6 commit bb8494a

3 files changed

Lines changed: 143 additions & 1 deletion

File tree

.github/workflows/merge-jobs.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Post-merge tasks
5+
6+
on:
7+
push:
8+
branches: ["main", "release/*"]
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-publish:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: "20"
24+
25+
# pnpm/action-setup@v4
26+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda
27+
name: Install pnpm
28+
with:
29+
version: 8
30+
run_install: false
31+
32+
- name: Get pnpm store directory
33+
shell: bash
34+
run: |
35+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
36+
37+
- uses: actions/cache@v4
38+
name: Setup pnpm cache
39+
with:
40+
path: ${{ env.STORE_PATH }}
41+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
42+
restore-keys: |
43+
${{ runner.os }}-pnpm-store-
44+
45+
- name: Install dependencies
46+
run: pnpm install
47+
48+
- name: Run linter
49+
run: pnpm lint
50+
51+
- name: Run tests
52+
run: pnpm test:ci
53+
54+
- name: Build
55+
run: pnpm build
56+
57+
- name: Pack NPM Tarball
58+
working-directory: packages/toolbar
59+
run: |
60+
pnpm install
61+
pnpm build
62+
pnpm pack --pack-destination dist
63+
64+
- name: Archive artifacts
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: ${{ github.sha }}
68+
path: |
69+
${{ github.workspace }}/dist/**
70+
${{ github.workspace }}/**/dist/*.tgz

.github/workflows/test.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: "20"
18+
19+
# pnpm/action-setup@v4
20+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda
21+
name: Install pnpm
22+
with:
23+
version: 8
24+
run_install: false
25+
26+
- name: Get pnpm store directory
27+
shell: bash
28+
run: |
29+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
30+
31+
- uses: actions/cache@v4
32+
name: Setup pnpm cache
33+
with:
34+
path: ${{ env.STORE_PATH }}
35+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pnpm-store-
38+
39+
- name: Install dependencies
40+
run: pnpm install
41+
42+
- name: Run linter
43+
run: pnpm lint
44+
45+
- name: Run tests
46+
run: pnpm test:ci
47+
48+
- name: Upload coverage reports to Codecov
49+
uses: codecov/codecov-action@v4
50+
env:
51+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
52+
with:
53+
directory: ./coverage/
54+
flags: unittests
55+
name: codecov-unittests
56+
fail_ci_if_error: false
57+
58+
- name: Upload results to Codecov
59+
if: ${{ !cancelled() }}
60+
uses: codecov/test-results-action@v1
61+
with:
62+
token: ${{ secrets.CODECOV_TOKEN }}
63+
64+
- name: Publish Test Report
65+
uses: mikepenz/action-junit-report@cf701569b05ccdd861a76b8607a66d76f6fd4857
66+
if: ${{ !cancelled() }}
67+
with:
68+
report_paths: "**/*.junit.xml"
69+
comment: false

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"lint": "biome lint",
2020
"lint:fix": "biome lint --fix",
2121
"prepare": "npm run build && simple-git-hooks",
22-
"test": "vitest"
22+
"postinstall": "simple-git-hooks",
23+
"test": "vitest",
24+
"test:ci": "vitest run --coverage --reporter=junit --outputFile=tests.junit.xml"
2325
},
2426
"repository": {
2527
"type": "git",
@@ -37,6 +39,7 @@
3739
},
3840
"devDependencies": {
3941
"@biomejs/biome": "^1.9.4",
42+
"@vitest/coverage-v8": "^3.1.1",
4043
"autoevals": "^0.0.127",
4144
"lint-staged": "^15.5.0",
4245
"simple-git-hooks": "^2.12.1",

0 commit comments

Comments
 (0)