Skip to content

Commit 6598ad2

Browse files
authored
Merge pull request #1 from roerohan/feat-ci
feat: added CI
2 parents 2c5eed3 + 0bd86f5 commit 6598ad2

File tree

8 files changed

+187
-6
lines changed

8 files changed

+187
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
deploy-worker:
9+
name: Deploy Worker
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup pnpm
16+
uses: pnpm/action-setup@v4
17+
with:
18+
version: 10
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '24'
24+
cache: 'pnpm'
25+
26+
- name: Install dependencies
27+
run: pnpm install --frozen-lockfile
28+
29+
- name: Deploy worker
30+
run: pnpm deploy:worker
31+
env:
32+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
33+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
34+
35+
deploy-web:
36+
name: Deploy Web
37+
runs-on: ubuntu-latest
38+
needs: [deploy-worker]
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v4
42+
43+
- name: Setup pnpm
44+
uses: pnpm/action-setup@v4
45+
with:
46+
version: 10
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: '24'
52+
cache: 'pnpm'
53+
54+
- name: Install dependencies
55+
run: pnpm install --frozen-lockfile
56+
57+
- name: Deploy web
58+
run: pnpm deploy:web
59+
env:
60+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
61+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

.github/workflows/pr-checks.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
lint:
9+
name: Lint
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup pnpm
16+
uses: pnpm/action-setup@v4
17+
with:
18+
version: 10
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '24'
24+
cache: 'pnpm'
25+
26+
- name: Install dependencies
27+
run: pnpm install --frozen-lockfile
28+
29+
- name: Run lint
30+
run: pnpm lint
31+
32+
test:
33+
name: Test
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Setup pnpm
40+
uses: pnpm/action-setup@v4
41+
with:
42+
version: 10
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: '24'
48+
cache: 'pnpm'
49+
50+
- name: Install dependencies
51+
run: pnpm install --frozen-lockfile
52+
53+
- name: Run tests
54+
run: pnpm test
55+
56+
typecheck:
57+
name: Type Check
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout code
61+
uses: actions/checkout@v4
62+
63+
- name: Setup pnpm
64+
uses: pnpm/action-setup@v4
65+
with:
66+
version: 10
67+
68+
- name: Setup Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: '24'
72+
cache: 'pnpm'
73+
74+
- name: Install dependencies
75+
run: pnpm install --frozen-lockfile
76+
77+
- name: Type check worker
78+
run: pnpm --filter @fullstack-monorepo-template/worker exec tsc --noEmit
79+
80+
- name: Type check web
81+
run: pnpm --filter @fullstack-monorepo-template/web exec tsc --noEmit

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Thank you for considering contributing to this project! This document provides g
1616

1717
### Prerequisites
1818

19-
- Node.js >= 18
19+
- Node.js >= 24
2020
- pnpm (`npm install -g pnpm`)
2121
- Git
2222
- A Cloudflare account (for deployment testing)

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ A fullstack monorepo template using pnpm workspaces with Cloudflare Workers for
2424

2525
## Prerequisites
2626

27-
- Node.js >= 18
27+
- Node.js >= 24
2828
- pnpm (`npm install -g pnpm`)
2929
- Cloudflare account (for deployment)
3030

@@ -84,7 +84,39 @@ The worker will run on http://localhost:8787 and the web app on http://localhost
8484
- `pnpm --filter @fullstack-monorepo-template/web build` - Build for production
8585
- `pnpm --filter @fullstack-monorepo-template/web deploy` - Deploy to Cloudflare Workers
8686

87-
## Deployment
87+
## CI/CD
88+
89+
This project includes two GitHub Actions workflows:
90+
91+
### PR Checks (`.github/workflows/pr-checks.yml`)
92+
93+
Runs automatically on pull requests to `main`:
94+
95+
- **Lint** - Checks code style and formatting (`pnpm lint`)
96+
- **Test** - Runs all tests (`pnpm test`)
97+
- **Type Check** - Validates TypeScript types for both packages
98+
99+
### Deploy (`.github/workflows/deploy.yml`)
100+
101+
Runs automatically on push to `main`:
102+
103+
- **Deploy Worker** - Deploys backend worker to Cloudflare
104+
- **Deploy Web** - Deploys frontend worker to Cloudflare (after worker deploys)
105+
106+
### Setup GitHub Secrets
107+
108+
To enable automatic deployments, add these secrets to your GitHub repository:
109+
110+
1. Go to **Settings****Secrets and variables****Actions**
111+
2. Add the following secrets:
112+
- `CLOUDFLARE_API_TOKEN` - Your Cloudflare API token ([Create one here](https://dash.cloudflare.com/profile/api-tokens))
113+
- `CLOUDFLARE_ACCOUNT_ID` - Your Cloudflare account ID
114+
115+
You can find your account ID in your Cloudflare dashboard URL: `https://dash.cloudflare.com/<ACCOUNT_ID>`
116+
117+
**Note:** The API token needs `Workers Scripts:Edit` permissions for deployments.
118+
119+
## Manual Deployment
88120

89121
### Worker
90122

packages/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "vite dev --port 3000",
88
"build": "vite build",
99
"serve": "vite preview",
10-
"test": "vitest run",
10+
"test": "vitest run --passWithNoTests",
1111
"deploy": "npm run build && wrangler deploy",
1212
"preview": "npm run build && vite preview",
1313
"cf-typegen": "wrangler types",

packages/web/src/routes/demo/start.ssr.spa-mode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const Route = createFileRoute('/demo/start/ssr/spa-mode')({
88
});
99

1010
function RouteComponent() {
11-
const [punkSongs, setPunkSongs] = useState<Awaited<ReturnType<typeof getPunkSongs>>>([]);
11+
const [punkSongs, setPunkSongs] = useState<Awaited<ReturnType<typeof getPunkSongs>> | []>([]);
1212

1313
useEffect(() => {
1414
getPunkSongs().then(setPunkSongs);

packages/web/vitest.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
export default defineConfig({
4+
test: {
5+
environment: 'jsdom',
6+
},
7+
});

packages/worker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"scripts": {
1919
"dev": "wrangler dev",
2020
"start": "wrangler dev",
21-
"test": "vitest",
21+
"test": "vitest run --passWithNoTests",
2222
"deploy": "wrangler deploy",
2323
"lint": "eslint src",
2424
"lint:fix": "eslint src --fix",

0 commit comments

Comments
 (0)