-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (113 loc) · 4.23 KB
/
ci-cd.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
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: CI/CD
on: push
# Cancel any previous CI runs for this branch or PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "pnpm"
check-latest: true
- name: Output debugging info
run: node -v && npm -v && pnpm -v
- name: Install
run: pnpm install && pnpm --dir functions install
- name: Lint
run: pnpm run lint
- name: Build
run: pnpm run build:all
- name: Integration tests
run: pnpm run coverage
# env:
# VITEST_MAX_THREADS: 1
# VITEST_MIN_THREADS: 1
- uses: codecov/codecov-action@v4
with:
# fail_ci_if_error: true # optional (default = false)
files: ./coverage/lcov.info # optional
# flags: unittests # optional
# name: codecov-umbrella # optional
token: ${{ secrets.CODECOV_TOKEN }} # required
verbose: true # optional (default = false)
deploy:
if: github.ref_name == 'main' || github.ref_name == 'production'
environment: ${{ github.ref_name == 'main' && 'staging' || github.ref_name == 'production' && 'production' }}
needs: [build_and_test, e2e_test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "pnpm"
check-latest: true
- name: Output debugging info
run: node -v && npm -v && pnpm -v
- name: Install
run: pnpm install && pnpm --dir functions install
# Note: no linting or testing, since it was done in the previous job
- name: Build
run: pnpm run build:all
env:
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }}
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }}
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID }}
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.VITE_FIREBASE_STORAGE_BUCKET }}
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID }}
VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID }}
- name: Create SA key
run: echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}' > $HOME/gcloud.json
- name: Deploy
# This requires a lot of pesky permissions in GCP, inspired from: https://davelms.medium.com/deploy-firebase-functions-using-github-actions-7dbafbd4df77
run: GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json pnpm run deploy --project ${{ secrets.VITE_FIREBASE_PROJECT_ID }}
e2e_test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "pnpm"
check-latest: true
- name: Output debugging info
run: node -v && npm -v && pnpm -v
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps chromium
- name: Setup emulator cache
uses: actions/cache@v4
with:
path: ~/.cache/firebase/emulators
key: emulators-${{ runner.os }}
- name: Run Playwright tests
run: pnpm run test:e2e:coverage
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- uses: codecov/codecov-action@v4
with:
# fail_ci_if_error: true # optional (default = false)
files: ./coverage/lcov.info # optional
# flags: unittests # optional
# name: codecov-umbrella # optional
token: ${{ secrets.CODECOV_TOKEN }} # required
verbose: true # optional (default = false)