|
1 |
| -name: Testing |
| 1 | +name: Tests |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - main
|
7 | 7 | pull_request:
|
8 |
| - branches: |
9 |
| - - "**" |
10 | 8 |
|
11 | 9 | 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 |
| - |
26 | 10 | test:
|
27 | 11 | runs-on: ubuntu-latest
|
28 |
| - name: test |
29 | 12 | 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 |
33 | 20 | 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 |
40 | 33 | - 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 |
0 commit comments