Skip to content

Commit 5a0754b

Browse files
authored
ci: set up basic checks
* test: set up vitest * ci: set up pnpm audio * ci: add vitest * ci: use node 22 * ci: add trivy checks * run security checks on all branches
1 parent 5028128 commit 5a0754b

File tree

7 files changed

+1835
-52
lines changed

7 files changed

+1835
-52
lines changed

.github/actions/setup/action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Setup Node + pnpm
2+
description: Install pnpm, setup Node.js with pnpm cache, and install deps
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Setup pnpm
7+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
8+
with:
9+
version: 10.18.3
10+
11+
- name: Setup Node.js
12+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
13+
with:
14+
node-version: 22
15+
cache: pnpm
16+
17+
- name: Install dependencies
18+
shell: bash
19+
run: pnpm install --frozen-lockfile
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Security Checks
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
permissions:
10+
contents: read
11+
jobs:
12+
trivy:
13+
name: Trivy
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
18+
19+
- name: Scan repo
20+
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1
21+
with:
22+
scan-type: 'fs'
23+
scan-ref: '.'
24+
scanners: 'vuln,secret,config'
25+
exit-code: '1'
26+
ignore-unfixed: 'true'
27+
severity: 'MEDIUM,HIGH,CRITICAL'
28+
29+
npm-audit:
30+
name: PNPM Audit
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout Repository
34+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
35+
36+
- name: Setup
37+
uses: ./.github/actions/setup
38+
39+
- name: Run pnpm audit
40+
run: pnpm audit --prod --audit-level=moderate

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Run Tests
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19+
20+
- name: Setup
21+
uses: ./.github/actions/setup
22+
23+
- name: Run tests
24+
run: pnpm test --run

__tests__/page.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { expect, test } from 'vitest'
2+
import { render, screen } from '@testing-library/react'
3+
import Home from '../src/app/page'
4+
5+
test('Home page', () => {
6+
render(<Home />)
7+
expect(
8+
screen.getByRole('heading', { level: 1, name: /To get started, edit the page.tsx file./i })
9+
).toBeDefined()
10+
})

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"name": "toolhive-cloud-ui",
33
"version": "0.1.0",
44
"private": true,
5+
"packageManager": "[email protected]",
56
"scripts": {
67
"dev": "next dev",
78
"build": "next build",
89
"start": "next start",
910
"lint": "biome check",
10-
"format": "biome format --write"
11+
"format": "biome format --write",
12+
"test": "vitest"
1113
},
1214
"dependencies": {
1315
"next": "16.0.2",
@@ -17,11 +19,17 @@
1719
"devDependencies": {
1820
"@biomejs/biome": "2.3.5",
1921
"@tailwindcss/postcss": "^4",
22+
"@testing-library/dom": "^10.4.1",
23+
"@testing-library/react": "^16.3.0",
2024
"@types/node": "^24.0.0",
2125
"@types/react": "^19",
2226
"@types/react-dom": "^19",
27+
"@vitejs/plugin-react": "^5.1.1",
2328
"babel-plugin-react-compiler": "1.0.0",
29+
"jsdom": "^27.2.0",
2430
"tailwindcss": "^4",
25-
"typescript": "^5"
31+
"typescript": "^5",
32+
"vite-tsconfig-paths": "^5.1.4",
33+
"vitest": "^4.0.8"
2634
}
2735
}

0 commit comments

Comments
 (0)