-
Notifications
You must be signed in to change notification settings - Fork 1
261 lines (252 loc) · 8.28 KB
/
main.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: Main workflow
on: [ push ]
env:
MIRROR_URL: "[email protected]:EpitechPromo2026/B-DEV-500-PAR-5-1-area-reza.rahemtola.git"
jobs:
build-supervisor:
name: "Build: Supervisor"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend/supervisor/
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed files
uses: tj-actions/changed-files@v39
id: changed-files
with:
files: 'backend/supervisor/**/*'
- name: Setup go
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-go@v4
with:
go-version-file: "backend/supervisor/go.mod"
cache-dependency-path: "backend/supervisor/go.sum"
- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
run: |
go mod download
sudo apt-get install -y protobuf-compiler
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
- name: Generate protobuf go files
if: steps.changed-files.outputs.any_changed == 'true'
run: |
git clone https://github.com/RezaRahemtola/area-proto.git proto
protoc --experimental_allow_proto3_optional --go_out=proto --go_opt=paths=source_relative --go-grpc_out=proto --go-grpc_opt=paths=source_relative --proto_path=proto proto/area_supervisor.proto proto/area_types.proto
- name: Run go build
if: steps.changed-files.outputs.any_changed == 'true'
run: go build
- name: Run go format
if: steps.changed-files.outputs.any_changed == 'true'
run: go fmt && git diff --exit-code
eslint-backend:
name: "ESLint: Backend"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend/back/
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed files
uses: tj-actions/changed-files@v39
id: changed-files
with:
files: 'backend/back/**/*'
- name: Setup node
uses: actions/setup-node@v3
if: steps.changed-files.outputs.any_changed == 'true'
with:
node-version: 18
cache: yarn
cache-dependency-path: "backend/back/yarn.lock"
- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn install --frozen-lockfile --ignore-scripts
- name: Run eslint
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn lint > eslint-results
- name: Get eslint results
uses: actions/upload-artifact@v3
if: failure()
with:
name: eslint-back-results
path: backend/back/eslint-results
retention-days: 5
unit-tests-backend:
name: "Unit tests: Backend"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend/back/
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed files
uses: tj-actions/changed-files@v39
id: changed-files
with:
files: 'backend/back/**/*'
- name: Setup node
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache-dependency-path: "backend/back/yarn.lock"
- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn install --frozen-lockfile
- name: Run unit tests
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn test > unit-tests-results
- name: Get unit tests results
uses: actions/upload-artifact@v3
if: failure()
with:
name: unit-tests-back-results
path: backend/back/unit-tests-results
retention-days: 5
eslint-web:
name: "ESLint: Web"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend/web/
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed files
uses: tj-actions/changed-files@v39
id: changed-files
with:
files: 'frontend/web/**/*'
- name: Setup node
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache-dependency-path: "frontend/web/yarn.lock"
- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn install --frozen-lockfile --ignore-scripts
- name: Run eslint
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn lint > eslint-results
- name: Get eslint results
uses: actions/upload-artifact@v3
if: failure()
with:
name: eslint-web-results
path: frontend/web/eslint-results
retention-days: 5
end-to-end-tests-web:
name: "Cypress E2E: Web"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend/web/
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed files
uses: tj-actions/changed-files@v39
id: changed-files
with:
files: 'frontend/web/**/*'
- name: Setup node
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache-dependency-path: "frontend/web/yarn.lock"
- name: Run cypress tests
if: steps.changed-files.outputs.any_changed == 'true'
uses: cypress-io/github-action@v6
env:
CYPRESS_HOST: ${{ secrets.CYPRESS_API_URL }}
with:
working-directory: ./frontend/web
build: yarn build
start: yarn start
wait-on: "http://localhost:3000"
- name: Get screenshots
if: failure()
uses: actions/upload-artifact@v3
with:
name: cypress-screenshots
path: frontend/web/cypress/screenshots
retention-days: 5
- name: Get videos
if: failure()
uses: actions/upload-artifact@v3
with:
name: cypress-videos
path: frontend/web/cypress/videos
retention-days: 5
check-mobile:
name: "Mobile: Analyze code & run tests"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend/mobile/
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed files
uses: tj-actions/changed-files@v39
id: changed-files
with:
files: 'frontend/mobile/**/*'
- name: Setup Java
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Setup Flutter
if: steps.changed-files.outputs.any_changed == 'true'
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.4"
channel: stable
cache: true
- name: Create dummy env file
if: steps.changed-files.outputs.any_changed == 'true'
run: touch .env
- name: Check formatting
if: steps.changed-files.outputs.any_changed == 'true'
run: dart format --set-exit-if-changed .
- name: Analyze code
if: steps.changed-files.outputs.any_changed == 'true'
run: flutter analyze
- name: Run tests
if: steps.changed-files.outputs.any_changed == 'true'
run: flutter test
push-to-mirror:
name: Push to Epitech repository
runs-on: ubuntu-latest
environment: Epitech repository
steps:
- name: Repository checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cloning to mirror
uses: pixta-dev/repository-mirroring-action@v1
with:
target_repo_url:
${{ env.MIRROR_URL }}
ssh_private_key:
${{ secrets.SSH_KEY }}
needs:
- build-supervisor
- eslint-backend
- unit-tests-backend
- eslint-web
- end-to-end-tests-web
- check-mobile