-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (130 loc) · 5.47 KB
/
tests.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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Build & test project
on:
pull_request:
branches: [ "dev" ]
workflow_dispatch:
inputs:
dbResetOptions:
description: "Options to add to supabase db reset"
required: false
type: string
env:
SUPABASE_INTERNAL_IMAGE_REGISTRY: ghcr.io
SUPABASE_ACCESS_TOKEN: ${{ secrets.HOSTED_SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.HOSTED_SUPABASE_DB_PASSWORD }}
NEXT_PUBLIC_SUPABASE_URL: ${{secrets.HOSTED_SUPABASE_URL}}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{secrets.HOSTED_SUPABASE_ANON_KEY}}
NEXT_PUBLIC_ONESIGNAL_APP_ID: ${{secrets.NEXT_PUBLIC_ONESIGNAL_APP_ID}}
NEXT_PUBLIC_ONESIGNAL_REST_API_KEY: ${{secrets.NEXT_PUBLIC_ONESIGNAL_REST_API_KEY}}
NEXT_PUBLIC_ONESIGNAL_SAFARI_WEB_ID: ${{secrets.NEXT_PUBLIC_ONESIGNAL_SAFARI_WEB_ID}}
NEXT_PUBLIC_DISABLE_ONESIGNAL: "true"
CYPRESS_ENV: ${{secrets.CYPRESS_ENV}}
CYPRESS_ADMIN_ID: ${{secrets.CYPRESS_ADMIN_ID}}
CYPRESS_ADMIN_EMAIL: ${{secrets.CYPRESS_ADMIN_EMAIL}}
CYPRESS_ADMIN_PASSWORD: ${{secrets.CYPRESS_ADMIN_PASSWORD}}
CYPRESS_ADMIN_DISPLAY_NAME: ${{secrets.CYPRESS_ADMIN_DISPLAY_NAME}}
CYPRESS_USER_ID: ${{secrets.CYPRESS_USER_ID}}
CYPRESS_USER_EMAIL: ${{secrets.CYPRESS_USER_EMAIL}}
CYPRESS_USER_PASSWORD: ${{secrets.CYPRESS_USER_PASSWORD}}
CYPRESS_USER_DISPLAY_NAME: ${{secrets.CYPRESS_USER_DISPLAY_NAME}}
CYPRESS_NEW_ID: ${{secrets.CYPRESS_NEW_ID}}
CYPRESS_NEW_EMAIL: ${{secrets.CYPRESS_NEW_EMAIL}}
CYPRESS_NEW_PASSWORD: ${{secrets.CYPRESS_NEW_PASSWORD}}
CYPRESS_SUGGESTION_ID: ${{secrets.CYPRESS_SUGGESTION_ID}}
CYPRESS_SONG_ID: ${{secrets.CYPRESS_SONG_ID}}
CYPRESS_MANUAL_SONG: ${{secrets.CYPRESS_MANUAL_SONG}}
CYPRESS_SPOTIFY_SONG: ${{secrets.CYPRESS_SPOTIFY_SONG}}
CYPRESS_EVENT_ID: ${{secrets.CYPRESS_EVENT_ID}}
CYPRESS_PROJECT_ID: ${{secrets.CYPRESS_PROJECT_ID}}
CYPRESS_RECORD_KEY: ${{secrets.CYPRESS_RECORD_KEY}}
CYPRESS_BASE_URL: ${{vars.CYPRESS_BASE_URL}}
CYPRESS_TIMEOUT_SECONDS: ${{vars.CYPRESS_TIMEOUT_SECONDS}}
CYPRESS_PAGE_LOAD_TIMEOUT_SECONDS: ${{vars.CYPRESS_PAGE_LOAD_TIMEOUT_SECONDS}}
CYPRESS_RETRY_MODE_RUN: ${{vars.CYPRESS_RETRY_MODE_RUN}}
GA_NODE_VERSION: ${{secrets.GA_NODE_VERSION}}
HUSKY: 0
jobs:
install:
runs-on: ubuntu-22.04
environment: dev
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest
- name: Link to hosted Supabase
run: supabase link --project-ref ${{ secrets.HOSTED_SUPABASE_PROJECT_ID }}
- name: Push local migrations to hosted Supabase (with y/N prompt)
run: yes | supabase db reset --db-url ${{ secrets.HOSTED_SUPABASE_DB_URL }} {{ inputs.dbResetOptions }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.GA_NODE_VERSION }}
- name: Setup cache
uses: actions/cache@v4
with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Cypress install
uses: cypress-io/github-action@v5
with:
# Disable running of tests within install job
runTests: false
build: npm run build
- name: Save build files
uses: actions/upload-artifact@v4
with:
name: build
if-no-files-found: error
path: |
.next
public
cypress-run:
runs-on: ubuntu-22.04
container: cypress/browsers:node18.12.0-chrome103-ff107
environment: dev
needs: install
strategy:
# don't fail the entire matrix on failure
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [ 1, 2, 3, 4, 5 ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.GA_NODE_VERSION }}
- name: Download the build files
uses: actions/download-artifact@v4
with:
name: build
- name: Cypress run
uses: cypress-io/github-action@v5
with:
working-directory: ./
record: true
parallel: true
start: npm run start
wait-on: ${{ vars.CYPRESS_BASE_URL }}
browser: chrome
env:
# - if the event is push, the title will be undefined
# and Cypress will get the commit message from Git information
# - if the event is pull_request, then we set the commit
# message to the pull request title
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
# re-enable PR comment bot
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}}