Skip to content

Commit aa0239c

Browse files
authored
Added Basic Unit Tests (#38)
1 parent 779e242 commit aa0239c

File tree

9 files changed

+9522
-4262
lines changed

9 files changed

+9522
-4262
lines changed

.github/workflows/build.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: YAMG Build & Test
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages-build"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build-and-test:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
build-path: ./out
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Detect package manager
28+
id: detect-package-manager
29+
run: |
30+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
31+
echo "manager=yarn" >> $GITHUB_OUTPUT
32+
echo "command=install" >> $GITHUB_OUTPUT
33+
echo "runner=yarn" >> $GITHUB_OUTPUT
34+
elif [ -f "${{ github.workspace }}/package.json" ]; then
35+
echo "manager=npm" >> $GITHUB_OUTPUT
36+
echo "command=ci" >> $GITHUB_OUTPUT
37+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
38+
else
39+
echo "Unable to determine package manager"
40+
exit 1
41+
fi
42+
43+
- name: Setup Node
44+
uses: pnpm/action-setup@v4
45+
with:
46+
version: 10
47+
cache: ${{ steps.detect-package-manager.outputs.manager }}
48+
49+
- name: Restore cache
50+
uses: actions/cache@v4
51+
with:
52+
path: |
53+
.next/cache
54+
node_modules
55+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
56+
restore-keys: |
57+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
58+
59+
- name: Install dependencies
60+
run: pnpm install --no-frozen-lockfile
61+
62+
- name: Run unit tests
63+
run: pnpm test
64+
65+
- name: Build with Next.js
66+
run: pnpm run build
67+
68+
- name: Upload build artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: nextjs-build
72+
path: ./out

.github/workflows/deploy.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: YAMG Deploy
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
concurrency:
13+
group: "pages-deploy"
14+
cancel-in-progress: false
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
environment:
20+
name: github-pages
21+
steps:
22+
- name: Download build artifact
23+
uses: actions/download-artifact@v4
24+
with:
25+
name: nextjs-build
26+
path: ./out
27+
28+
- name: Deploy to GitHub Pages
29+
id: deployment
30+
uses: actions/deploy-pages@v4

.github/workflows/nextjs.yml

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

jest.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { Config } from "jest"
2+
3+
const config: Config = {
4+
preset: "ts-jest",
5+
testEnvironment: "node",
6+
testMatch: ["**/tests/**/*.test.ts", "**/tests/**/*.test.tsx"],
7+
moduleNameMapper: {
8+
"^@/(.*)$": "<rootDir>/$1", // match your tsconfig paths
9+
},
10+
transform: {
11+
"^.+\\.tsx?$": "ts-jest", // transform TS files
12+
},
13+
clearMocks: true,
14+
}
15+
16+
export default config

0 commit comments

Comments
 (0)