-
-
Notifications
You must be signed in to change notification settings - Fork 131
206 lines (164 loc) · 5.13 KB
/
Copy pathci.yml
File metadata and controls
206 lines (164 loc) · 5.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: CI
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
NEXT_PUBLIC_SITE_URL: ${{ secrets.NEXT_PUBLIC_SITE_URL }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
IP_ADDRESS_SALT: ${{ secrets.IP_ADDRESS_SALT }}
BETTER_AUTH_SECRET: ${{ secrets.BETTER_AUTH_SECRET }}
GITHUB_CLIENT_ID: ${{ secrets.GH_CLIENT_ID }}
GITHUB_CLIENT_SECRET: ${{ secrets.GH_CLIENT_SECRET }}
jobs:
tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Configure environment
uses: ./.github/actions/setup
- name: Run unit tests
run: pnpm test:unit
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Configure environment
uses: ./.github/actions/setup
- name: Run ESLint
run: pnpm lint
spellcheck:
name: Spell Check
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Configure environment
uses: ./.github/actions/setup
- name: Run cspell
run: pnpm lint:spell
types:
name: TypeScript
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Configure environment
uses: ./.github/actions/setup
- name: Run type check
run: pnpm typecheck
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Configure environment
uses: ./.github/actions/setup
- name: Run Prettier format check
run: pnpm format:check
knip:
name: Knip
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Configure environment
uses: ./.github/actions/setup
- name: Run Knip
run: pnpm knip
i18n:
name: i18n
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Configure environment
uses: ./.github/actions/setup
- name: Run i18n check
run: pnpm check:i18n
e2e:
name: End-to-end Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Configure environment
uses: ./.github/actions/setup
- name: Install Playwright with dependencies
run: pnpm playwright install --with-deps chromium --only-shell
- name: Create test posts and copy dummy images
run: |
mkdir -p src/content/blog/en/
mkdir -p public/images/blog/
frontmatter() {
local title="$1"
local slug="$2"
local display_title="${title//_/ }"
cat << EOF
---
title: $display_title
date: '1970-01-01T00:00:00Z'
modifiedTime: '1970-01-01T00:00:00Z'
summary: This is a test post.
---
This is a test post.
EOF
}
dummy_image_path="public/images/dummy.png"
if [ ! -f "$dummy_image_path" ]; then
echo "Error: Dummy image not found at $dummy_image_path"
exit 1
fi
titles=("Test_Submit_Comment" "Test_Delete_Comment" "Test_Reply_Comment" "Test_Delete_Reply" "Test_View_Post" "Test_Like_Post")
slugs=("test-submit" "test-delete" "test-reply" "test-delete-reply" "test-view" "test-like")
for i in "${!titles[@]}"; do
title="${titles[$i]}"
slug="${slugs[$i]}"
post_path="src/content/blog/en/$slug.mdx"
cover_dir="public/images/blog/$slug"
cover_path="$cover_dir/cover.png"
frontmatter "$title" "$slug" > "$post_path"
if [ -f "$post_path" ]; then
echo "Successfully created test post at $post_path"
else
echo "Error: Failed to create test post at $post_path"
exit 1
fi
mkdir -p "$cover_dir"
cp "$dummy_image_path" "$cover_path"
if [ -f "$cover_path" ]; then
echo "Successfully copied dummy image to $cover_path"
else
echo "Error: Failed to copy dummy image to $cover_path"
exit 1
fi
done
- name: Build apps
run: pnpm build
- name: Run services
run: docker compose up -d
- name: Migrate database
run: pnpm db:migrate
- name: Seed database
run: pnpm db:seed
- name: Run Playwright tests
run: pnpm test:e2e
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 30