forked from c2siorg/Codelabz
-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (90 loc) · 3.56 KB
/
cypress.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
name: Cypress Tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [18, 20, 22]
containers: [1, 2, 3, 4, 5]
name: E2E Testing with Cypress
env:
CI: false
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Node.js Environment
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-
- name: Create .env File
run: |
echo "VITE_APP_FIREBASE_API_KEY=${{ secrets.VITE_APP_FIREBASE_API_KEY }}" >> .env
echo "VITE_APP_FIREBASE_PROJECT_ID=${{ secrets.VITE_APP_FIREBASE_PROJECT_ID }}" >> .env
echo "VITE_APP_FIREBASE_MESSAGING_SENDER_ID=${{ secrets.VITE_APP_FIREBASE_MESSAGING_SENDER_ID }}" >> .env
echo "VITE_APP_FIREBASE_APP_ID=${{ secrets.VITE_APP_FIREBASE_APP_ID }}" >> .env
echo "VITE_APP_FIREBASE_MEASUREMENTID=${{ secrets.VITE_APP_FIREBASE_MEASUREMENTID }}" >> .env
echo "VITE_APP_FIREBASE_FCM_VAPID_KEY=${{ secrets.VITE_APP_FIREBASE_FCM_VAPID_KEY }}" >> .env
echo "VITE_APP_AUTH_DOMAIN=${{ secrets.VITE_APP_AUTH_DOMAIN }}" >> .env
echo "VITE_APP_DATABASE_URL=${{ secrets.VITE_APP_DATABASE_URL }}" >> .env
echo "VITE_APP_USE_EMULATOR=true" >> .env
echo "SKIP_PREFLIGHT_CHECK=true" >> .env
echo "CI=false" >> .env
echo "CYPRESS_PROJECT_ID=${{ secrets.CYPRESS_PROJECT_ID }}" >> .env
- name: Prepare Firebase Service Account
run: |
cd functions
mkdir -p private
echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_CODELABZ_2CD64 }}" > private/cl-dev-pk.json
- name: Install Functions Dependencies
run: cd functions && npm install --legacy-peer-deps
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Start Firebase Emulators
run: |
firebase emulators:start --import=./testdata --project ${{ secrets.VITE_APP_FIREBASE_PROJECT_ID }} &
sleep 15
- name: Run Cypress Tests
uses: cypress-io/github-action@v6
with:
config-file: cypress.config.js
group: "GitHub Actions"
install-command: npm install --legacy-peer-deps
# build: npm run build
start: npm run dev
wait-on: "http://localhost:5173"
browser: chrome
record: true
parallel: true
tag: node-${{ matrix.node }}
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_INFO_BRANCH: ${{ github.ref_name }}
- name: Upload Cypress Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: Cypress Artifacts
path: |
cypress/screenshots
cypress/videos/
- name: Print Cypress Cloud URL
if: always()
run: |
echo Cypress finished with: ${{ steps.cypress.outcome }}
echo See results at ${{ steps.cypress.outputs.resultsUrl }}
- name: Notify on Failure
if: failure()
run: echo "The workflow has failed!"