-
Notifications
You must be signed in to change notification settings - Fork 14
151 lines (139 loc) · 4.75 KB
/
pre-merge.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
146
147
148
149
150
151
# This workflow will do a clean install of node dependencies, build the source code and run tests
name: 'Pre-merge checks'
on:
pull_request:
branches: [main]
# Be extremely careful as the env variables defined here are accessible by all the actions of the workflow.
# For critical env variable, declare it within the action.
env:
node-version: 18.x
INSEE_CLIENT_ID: ${{ secrets.INSEE_CLIENT_ID }}
INSEE_CLIENT_SECRET: ${{ secrets.INSEE_CLIENT_SECRET}}
INSEE_CLIENT_ID_FALLBACK: ${{ secrets.INSEE_CLIENT_ID_FALLBACK }}
INSEE_CLIENT_SECRET_FALLBACK: ${{ secrets.INSEE_CLIENT_SECRET_FALLBACK}}
INDEXING_ENABLED: enabled
REDIS_ENABLED: disabled
MATOMO_ENABLED: disabled
MATOMO_SITE_ID: ${{ secrets.MATOMO_SITE_ID }}
MATOMO_API_SITE_ID: ${{ secrets.MATOMO_API_SITE_ID }}
PROXY_API_KEY: ${{ secrets.PROXY_API_KEY }}
IRON_SESSION_PWD: ${{ secrets.IRON_SESSION_PWD }}
GRIST_API_KEY: ${{ secrets.GRIST_API_KEY }}
UPDOWN_IO_API_KEY: ${{ secrets.UPDOWN_IO_API_KEY }}
jobs:
dependencies:
name: 'Install dependencies'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- uses: ./.github/actions/install-dependencies
name: Install and cache dependencies
lint:
name: Lint
runs-on: ubuntu-latest
needs: [dependencies]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- name: Load node_modules
uses: ./.github/actions/load-dependencies
- name: Run linter
run: npm run lint
build:
name: Build
runs-on: ubuntu-latest
needs: [dependencies]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- name: Load node_modules
uses: ./.github/actions/load-dependencies
- name: Build site
run: npm run build
- name: Cache site
uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
tests:
name: Unit tests
runs-on: ubuntu-latest
needs: [dependencies]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- name: Load node_modules
uses: ./.github/actions/load-dependencies
- name: Run unit tests
run: |
npm run test:unit
testE2E:
name: End2end tests
runs-on: ubuntu-latest
needs: [dependencies]
env:
NEXT_PUBLIC_END2END_MOCKING: enabled
AGENTCONNECT_CLIENT_ID: ${{ secrets.AGENTCONNECT_CLIENT_ID }}
AGENTCONNECT_CLIENT_SECRET: ${{ secrets.AGENTCONNECT_CLIENT_SECRET }}
AGENTCONNECT_URL_DISCOVER: https://fca.integ01.dev-agentconnect.fr/api/v2/.well-known/openid-configuration
AGENTCONNECT_REDIRECT_URI: http://localhost:3000/api/auth/agent-connect/callback
AGENTCONNECT_POST_LOGOUT_REDIRECT_URI: http://localhost:3000/api/auth/agent-connect/logout-callback
steps:
- name: Checkout 🛎
uses: actions/checkout@v3
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- name: Load node_modules
uses: ./.github/actions/load-dependencies
- name: Build site with E2E mocking
run: npm run build
env:
NEXT_PUBLIC_END2END_MOCKING: enabled
- name: Run Cypress tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v5
timeout-minutes: 10
with:
start: npm start
record: false
env:
PORT: 3000
NEXT_PUBLIC_END2END_MOCKING: enabled
- name: Upload screenshots 📸
uses: actions/upload-artifact@v4
# add the line below to store screenshots only on failures
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
typecheck:
name: Type check
runs-on: ubuntu-latest
needs: [dependencies]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- name: Load node_modules
uses: ./.github/actions/load-dependencies
- name: Run typescript check
run: npx tsc --noEmit