Skip to content

Commit 0023a9b

Browse files
webbertakkenGabLeRouxcoderabbitai[bot]
authored
chore: add tests for last two prs (#69)
* test: version scraping * setup vitest * Update .github/workflows/main.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * chore: quality tools --------- Co-authored-by: Gabriel Le Breton <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3055a7b commit 0023a9b

File tree

19 files changed

+2512
-64
lines changed

19 files changed

+2512
-64
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ A clear and concise description of what the bug is.
1212
**To Reproduce**
1313
Steps to reproduce the behavior:
1414

15-
-
15+
- **Expected behavior**
16+
A clear and concise description of what you expected to happen.
1617

17-
**Expected behavior**
18-
A clear and concise description of what you expected to happen.
18+
**Screenshots**
19+
If applicable, add screenshots to help explain your problem.
1920

20-
**Screenshots**
21-
If applicable, add screenshots to help explain your problem.
22-
23-
**Additional context**
24-
Add any other context about the problem here.
21+
**Additional context**
22+
Add any other context about the problem here.

.github/workflows/main.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,24 @@ jobs:
2727
run: yarn install --immutable
2828

2929
- name: run linter
30-
run: yarn lint && yarn workspace functions lint
30+
run: yarn lint
31+
32+
- name: run format
33+
run: yarn format
34+
35+
- name: run typecheck
36+
run: yarn typecheck
3137

3238
- name: run tests
33-
run: yarn test && yarn workspace functions test
39+
run: yarn coverage
40+
41+
- name: Upload coverage reports to Codecov
42+
uses: codecov/[email protected]
43+
with:
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
slug: game-ci/versioning-backend
46+
files: ./functions/coverage/lcov.info
47+
flags: unittests,integration
3448

3549
build:
3650
name: 🛠 Build

.husky/pre-commit

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
# Fix from https://github.com/typicode/husky/issues/968#issuecomment-1176848345
5+
if [ -t 2 ] ; then exec >/dev/tty 2>&1 ; fi
6+
7+
# Check changes that are staged for commit
8+
yarn lint-staged

.oxlintrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"no-unsafe-declaration-merging": "off"
4+
}
5+
}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
**/node_modules/**
22
**/public/**
33
**/lib/**
4+
**/coverage/**

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
nodeLinker: node-modules
22

3-
npmRegistryServer: "https://registry.npmjs.org/"
3+
npmRegistryServer: 'https://registry.npmjs.org/'

DEVELOPMENT.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ This will compile the TypeScript code into JavaScript in the `lib` directory, wh
5252
To use Firebase Admin SDK locally:
5353

5454
1. Download a service account key from your Firebase project settings:
55+
5556
- Go to [Firebase Console](https://console.firebase.google.com/)
5657
- Select your project
5758
- Go to Project Settings > Service accounts
@@ -61,11 +62,13 @@ To use Firebase Admin SDK locally:
6162
2. Set the environment variable to the key file:
6263

6364
**Linux / macOS**:
65+
6466
```bash
6567
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/serviceAccountKey.json"
6668
```
6769

6870
**Windows (PowerShell)**:
71+
6972
```powershell
7073
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\serviceAccountKey.json"
7174
```
@@ -77,17 +80,20 @@ $env:GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\serviceAccountKey.json"
7780
To test integrations locally, set these environment variables:
7881

7982
**Discord**:
83+
8084
```bash
8185
export DISCORD_TOKEN="your_discord_token"
8286
```
8387

8488
**GitHub**:
89+
8590
```bash
8691
export GITHUB_CLIENT_SECRET="your_github_app_client_secret"
8792
export GITHUB_PRIVATE_KEY="your_github_app_private_key"
8893
```
8994

9095
**Internal Token**:
96+
9197
```bash
9298
export INTERNAL_TOKEN="your_internal_token"
9399
```
@@ -141,11 +147,13 @@ To use Firebase Admin SDK locally:
141147
2. Set the environment variable to the key file
142148

143149
**Linux / macOS**:
150+
144151
```bash
145152
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/serviceAccountKey.json"
146153
```
147154

148155
**Windows (PowerShell)**:
156+
149157
```powershell
150158
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\serviceAccountKey.json"
151159
```
@@ -155,17 +163,20 @@ $env:GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\serviceAccountKey.json"
155163
To test integrations locally, set these environment variables:
156164

157165
**Discord**:
166+
158167
```bash
159168
export DISCORD_TOKEN="your_discord_token"
160169
```
161170

162171
**GitHub**:
172+
163173
```bash
164174
export GITHUB_CLIENT_SECRET="your_github_app_client_secret"
165175
export GITHUB_PRIVATE_KEY="your_github_app_private_key"
166176
```
167177

168178
**Internal Token**:
179+
169180
```bash
170181
export INTERNAL_TOKEN="your_internal_token"
171182
```
@@ -177,16 +188,19 @@ export INTERNAL_TOKEN="your_internal_token"
177188
> **Note:** You need project access to deploy.
178189
179190
1. Login to Firebase:
191+
180192
```bash
181193
firebase login
182194
```
183195

184196
2. Deploy everything:
197+
185198
```bash
186199
firebase deploy
187200
```
188201

189202
Or deploy specific services:
203+
190204
```bash
191205
firebase deploy --only functions
192206
```
@@ -216,25 +230,27 @@ firebase functions:config:set internal.token="your_internal_token"
216230
firebase emulators:start
217231
```
218232
4. For hot reloading during development:
233+
219234
```bash
220235
# In one terminal
221236
cd functions && yarn watch
222-
223-
# In another terminal
237+
238+
# In another terminal
224239
firebase emulators:start
225240
```
241+
226242
5. Test your changes
227243
6. Deploy when ready
228244

229245
## Troubleshooting
230246

231247
- **Firebase Login Issues**: Make sure you have access to the Firebase project
232-
- **Emulator Port Conflicts**:
248+
- **Emulator Port Conflicts**:
233249
- Check for services using ports 4000, 5001, 8080, or 9000
234250
- This project uses port 5002 for hosting to avoid conflicts with AirPlay Receiver on macOS
235251
- Feel free to change any port in your local `firebase.json` if you encounter conflicts
236252
- See the [Port Configuration](#port-configuration) section for details
237-
- **Java Not Found Error**:
253+
- **Java Not Found Error**:
238254
- The Firebase emulators require Java to be installed
239255
- On macOS, install Java using `brew install openjdk@17` or download from [java.com](https://www.java.com)
240256
- Make sure Java is on your PATH: `java -version` should return the installed version
@@ -245,6 +261,6 @@ firebase functions:config:set internal.token="your_internal_token"
245261
- **Admin SDK Configuration Errors**:
246262
- Set up the `GOOGLE_APPLICATION_CREDENTIALS` environment variable as described in the [Set Up Credentials](#4-set-up-credentials) section
247263
- For testing, you can often ignore this warning as the emulators will still run with limited functionality
248-
- **Integration Issues**:
264+
- **Integration Issues**:
249265
- Ensure all required environment variables are correctly set
250266
- For local development without integration testing, you can often proceed without setting these variables

functions/.eslintrc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ module.exports = {
2121
'@typescript-eslint/prefer-for-of': 'warn',
2222
'@typescript-eslint/triple-slash-reference': 'error',
2323
'@typescript-eslint/unified-signatures': 'warn',
24-
"@typescript-eslint/no-redeclare": [
25-
"error",
24+
'@typescript-eslint/no-redeclare': [
25+
'error',
2626
{
27-
"ignoreDeclarationMerge": true,
28-
}
27+
ignoreDeclarationMerge: true,
28+
},
2929
],
3030
'comma-dangle': ['warn', 'always-multiline'],
3131
'constructor-super': 'error',

functions/package.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
{
22
"name": "functions",
33
"scripts": {
4+
"dev": "yarn watch",
45
"lint": "eslint \"src/**/*\"",
5-
"build": "tsc",
6-
"watch": "tsc --watch",
7-
"serve": "npm run build && firebase emulators:start --only functions",
8-
"shell": "npm run build && firebase functions:shell",
9-
"start": "npm run shell",
6+
"build": "run -T tsc",
7+
"watch": "run -T tsc --watch",
8+
"serve": "yarn build && firebase emulators:start --only functions",
9+
"shell": "yarn build && firebase functions:shell",
10+
"start": "yarn shell",
1011
"deploy": "firebase deploy --only functions",
1112
"logs": "firebase functions:log",
12-
"test": "echo \"No tests yet, feel free to add\" && exit 0"
13+
"test": "run -T vitest",
14+
"typecheck": "run -T tsc --noEmit",
15+
"coverage": "run -T vitest run --coverage",
16+
"test:run": "run -T vitest run",
17+
"test:ui": "run -T vitest --ui"
1318
},
1419
"engines": {
1520
"node": "22"
@@ -38,8 +43,7 @@
3843
"eslint": "^8.57.0",
3944
"eslint-plugin-import": "^2.29.1",
4045
"firebase-functions-test": "^3.3.0",
41-
"jest": "^29.7.0",
42-
"typescript": "^5.6.3"
46+
"jest": "^29.7.0"
4347
},
4448
"private": true,
4549
"volta": {

functions/src/config/credential.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const getCredential = (): credential.Credential => {
55
const serviceAccount = require(process.env.GOOGLE_APPLICATION_CREDENTIALS ??
66
'../../service-account.json');
77
return credential.cert(serviceAccount);
8-
} catch (e) {
8+
} catch {
99
return credential.applicationDefault();
1010
}
1111
};

0 commit comments

Comments
 (0)