Skip to content

Commit 7cb200e

Browse files
committed
chore: Add test workflow
1 parent 203750a commit 7cb200e

File tree

3 files changed

+51
-34
lines changed

3 files changed

+51
-34
lines changed

.github/workflows/testing.yaml

+48-32
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,61 @@
1-
name: Testing
1+
name: Tests
22

33
on:
44
push:
55
branches:
66
- main
77
pull_request:
8-
branches:
9-
- "**"
108

119
jobs:
12-
lint:
13-
runs-on: ubuntu-latest
14-
name: linting
15-
steps:
16-
- uses: actions/checkout@v2
17-
- name: Setup node
18-
uses: actions/setup-node@v1
19-
with:
20-
node-version: 16
21-
- name: Yarn install
22-
run: yarn
23-
- name: ESLint
24-
run: yarn run lint
25-
2610
test:
2711
runs-on: ubuntu-latest
28-
name: test
2912
steps:
30-
- uses: actions/checkout@v2
31-
- name: Setup node
32-
uses: actions/setup-node@v1
13+
# Checkout the repository
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
# Set up Node.js environment and install pnpm
18+
- name: Setup Node.js and pnpm
19+
uses: actions/setup-node@v3
3320
with:
34-
node-version: 16
35-
- name: Yarn install
36-
run: yarn
37-
- name: Yarn install (functions)
38-
working-directory: functions
39-
run: yarn
21+
node-version: '20.11.1'
22+
cache: 'pnpm'
23+
24+
# Install pnpm
25+
- name: Install pnpm
26+
run: npm install -g pnpm
27+
28+
# Install all dependencies at the root
29+
- name: Install dependencies
30+
run: pnpm install
31+
32+
# Install Firebase CLI
4033
- name: Install Firebase CLI
41-
run: npm i -g firebase-tools
42-
- name: Run tests
43-
run: yarn run test:ci
44-
env:
45-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
34+
run: npm install -g firebase-tools
35+
36+
# Determine which packages have changed
37+
- name: Determine changed packages
38+
id: changes
39+
uses: dorny/paths-filter@v2
40+
with:
41+
filters: |
42+
react:
43+
- 'packages/react/**'
44+
45+
# Start the Firebase emulator in the background
46+
- name: Start Firebase Emulator
47+
run: firebase emulators:start --project test-project &
48+
49+
# Wait for the Firebase emulator to be ready (Firestore up on port 8080)
50+
- name: Wait for Firebase Emulator
51+
run: npx wait-on tcp:8080
52+
53+
# Run tests for the React package if it has changed
54+
- name: Run React Tests
55+
if: steps.changes.outputs.react == 'true'
56+
run: vitest --dom 'packages/react'
57+
58+
# Run tests for the Vue package if it has changed
59+
# - name: Run Vue Tests
60+
# if: steps.changes.outputs.vue == 'true'
61+
# run: pnpm --filter vue test

functions/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"logs": "firebase functions:log"
1010
},
1111
"engines": {
12-
"node": "16"
12+
"node": "20"
1313
},
1414
"main": "src/index.js",
1515
"dependencies": {

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"scripts": {
55
"test": "vitest --dom --coverage",
66
"serve:coverage": "npx serve coverage",
7-
"emulator": "firebase emulators:start --project test-project --only firestore"
7+
"emulator": "firebase emulators:start --project test-project --only firestore",
8+
"emulator:kill": "lsof -t -i:4001 -i:8080 -i:9000 -i:9099 -i:9199 -i:8085 | xargs kill -9"
89
},
910
"devDependencies": {
1011
"@tanstack/react-query": "^5.55.4",

0 commit comments

Comments
 (0)