-
Notifications
You must be signed in to change notification settings - Fork 0
257 lines (239 loc) · 9.81 KB
/
ci.yml
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
---
name: Node.js CI
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DOCKER_PLATFORMS: linux/arm64
on:
workflow_dispatch:
push:
paths-ignore:
- README.md
- .github/**
- locales/**
- sounds/**
- package.json
- addons/**
- .gitignore
- docker-compose.yml
pull_request:
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
CommitLint:
name: Lint Commit Messages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: rm tsconfig.json
- uses: wagoid/commitlint-github-action@v6.0.1
Lint:
name: Lint The code
needs:
- CommitLint
runs-on: ubuntu-latest
steps:
# -----------------------------------------------------------------------
# Check out The Repository
# -----------------------------------------------------------------------
- name: 💾 Check out repository
uses: actions/checkout@v4
# -----------------------------------------------------------------------
# Install Node.js and pnpm
# -----------------------------------------------------------------------
- name: Setup Node and pnpm
uses: ./.github/actions/setup-node-pnpm
# - name: 📦 Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 18
# - name: Install pnpm
# shell: bash
# run: npm install -g pnpm@8
# # -----------------------------------------------------------------------
# # Cache dependencies
# # -----------------------------------------------------------------------
# - name: Get PNPM Store Directory
# id: pnpm-cache
# shell: bash
# run: |
# echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
# - name: Setup PNPM Cache
# uses: actions/cache@v4
# with:
# path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-
# # -----------------------------------------------------------------------
# # Install dependencies
# # -----------------------------------------------------------------------
# - name: Install dependencies
# run: pnpm i
# -----------------------------------------------------------------------
# Build and lint
# -----------------------------------------------------------------------
- name: Build
run: pnpm build
- name: Lint
run: pnpm lint
test:
name: Test the Code
needs:
- CommitLint
- Lint
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
strategy:
matrix:
shard: [1, 2, 3, 4, 5]
steps:
# -----------------------------------------------------------------------
# Check out The Repository
# -----------------------------------------------------------------------
- name: 💾 Check out repository
uses: actions/checkout@v4
# -----------------------------------------------------------------------
# Install Node.js and pnpm
# -----------------------------------------------------------------------
- name: Setup Node and pnpm
uses: ./.github/actions/setup-node-pnpm
# - name: 📦 Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 18
# - name: Install pnpm
# shell: bash
# run: npm install -g pnpm@8
# # -----------------------------------------------------------------------
# # Cache dependencies
# # -----------------------------------------------------------------------
# - name: Get PNPM Store Directory
# id: pnpm-cache
# shell: bash
# run: |
# echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
# - name: Setup PNPM Cache
# uses: actions/cache@v4
# with:
# path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-
# # -----------------------------------------------------------------------
# # Install dependencies
# # -----------------------------------------------------------------------
# - name: Install dependencies
# run: pnpm i
# -----------------------------------------------------------------------
# Run tests
# -----------------------------------------------------------------------
- name: Test
run: pnpm test:coverage:ci --maxWorkers=2 --shard=${{ matrix.shard }}/${{ strategy.job-total }}
- name: Rename coverage to shard coverage
run: |
mv coverage/clover.xml coverage/clover-${{matrix.shard}}.xml
mv coverage/lcov.info coverage/lcov-${{matrix.shard}}.info
mv coverage/coverage-final.json coverage/coverage-${{matrix.shard}}.json
- uses: actions/upload-artifact@v4
with:
name: coverage-artifacts-${{ runner.os }}-${{ matrix.shard }}
path: coverage/
check-coverage:
runs-on: ubuntu-latest
needs: [test]
steps:
# -----------------------------------------------------------------------
# Check out The Repository
# -----------------------------------------------------------------------
- uses: actions/checkout@v4
with:
fetch-depth: 0
# -----------------------------------------------------------------------
# Download the Coverage Artifacts
# -----------------------------------------------------------------------
- uses: actions/download-artifact@v4
with:
path: coverage
pattern: coverage-artifacts-*
merge-multiple: true
# -----------------------------------------------------------------------
# Use NYC to process the coverage
# -----------------------------------------------------------------------
# Add these once code is mature: --check-coverage --branches 90 --functions 90 --lines 90 --statements 90
- name: Process Coverage
run: npx nyc report --reporter lcov --reporter text -t coverage
# -----------------------------------------------------------------------
# Upload coverage
# -----------------------------------------------------------------------
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# -----------------------------------------------------------------------
# Delete the Coverage Artifacts
# -----------------------------------------------------------------------
- uses: geekyeggo/delete-artifact@v5
with:
name: coverage-artifacts-*
failOnError: false
release:
name: Semantic Release
runs-on: ubuntu-latest
needs:
- CommitLint
- Lint
- test
if: github.ref == 'refs/heads/main'
steps:
- uses: googleapis/release-please-action@v4
with:
release-type: node
token: ${{ secrets.GITHUB_TOKEN }}
# GitHubPackage:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# needs:
# - CommitLint
# - Lint
# - test
# if: github.ref == 'refs/heads/main'
# steps:
# - name: 💾 Check out repository
# uses: actions/checkout@v4
# - name: 🖥️ Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: 📦 Set up container buildx
# uses: docker/setup-buildx-action@v3
# - name: 🔑 Log in to the container registry
# uses: docker/login-action@v3.0.0
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: 📡 Collect image metadata
# id: meta
# uses: docker/metadata-action@v5.3.0
# with:
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# tags: |
# type=edge
# - name: 📦 Build and publish container image
# uses: docker/build-push-action@v5.1.0
# with:
# context: .
# platforms: ${{ env.DOCKER_PLATFORMS }}
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha
# cache-to: type=gha,mode=max