forked from PorfirioTramontana/HookBasedProcess
-
Notifications
You must be signed in to change notification settings - Fork 0
310 lines (280 loc) · 12.9 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# This is a basic workflow to help you get started with Actions
name: Github Actions Maven Build Example
# Controls when the workflow will run
on:
release:
types: [published]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
environment:
name: envForGithubActions
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Step 1 - Checkout main branch from GitHub
uses: actions/checkout@v2
# Runs a single command using the runners shell
- name: Step 2 - Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Step 2.2 - Visualizzare tag corrente
run: |
echo "Vediamo il tag corrente:"
echo "${GITHUB_REF#refs/tags/}"
echo "${GITHUB_REF#refs/heads/}"
echo "Vediamo se si potrebbe capire automaticamente che si usano gli hooks"
echo "Stampa a video degli utlimi 5 caratteri del tag della release corrente"
varTemp=$(echo "${GITHUB_REF#refs/tags/}" | tail -c 6)
echo "$varTemp"
echo "Vediamo qual è l'id dell'attuale commit"
echo "$GITHUB_SHA"
echo "Vediamo path WEB DRIVER"
echo "${{ secrets.PATH_REPOSITORY }}/chromedriver_v94_linux64/chromedriver"
- name: Step 3 - Installare Node versione 10 in Ubuntu
run: |
sudo apt update
sudo apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash
sudo apt install nodejs
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo n 10.18.0
echo "Versione di node: "
node -v
echo "Versione di npm: "
npm -v
npm install
echo "Provo ad INSTALLARE bcrypt"
npm install bcrypt
npm fund
echo "vedi se ha fatto bene o no"
- name: Step 4 - Unzip test-hooks ed installazione dentro test-guard di npm
run: |
ls -a
unzip test-hooks.zip
cd test-hooks
ls -a
cd test-guard
ls -a
echo "Versione di node: "
node -v
echo "Versione di npm: "
npm -v
echo "Provo ad installare con npm install"
npm install
ls -a
npm audit fix
echo "Provo ad INSTALLARE bcrypt"
npm install bcrypt
npm fund
echo "vedi se ha fatto bene o no"
- name: Step 5 - Instrumenta l'applicazione iniettando gli Hooks
run: |
cd test-hooks
cd test-guard
ls -a
echo "Visualizzazione file ftl prima dell injection! "
echo "Visualizza versione di node"
node -v
echo "... Cancellazione e successivo aggiornamento di node_modules ..."
rm -rf node_modules/
npm update
echo "entra nel if solamente se si intendono utilizzare gli Hooks nel progetto"
varTemp=$(echo "${GITHUB_REF#refs/tags/}" | tail -c 6)
echo "varTemp"
if [ "$varTemp" == "Hooks" ]; then
echo "Sono entrato nel if"
echo "INJECTION adesso..."
echo "Visualizza versione di node"
node -v
node main.js inject-hooks ${{ secrets.DIR_FILE_FE }} --grammar ${{ secrets.GRAMMAR_TYPE }}
echo "Visualizzazione file ftl dopo l'injection!!! "
git config --global user.email "${{ secrets.EMAIL_ACCOUNT_GITHUB }}"
git config --global user.name "${{ secrets.NOME_ACCOUNT_GITHUB }}"
git config --global user.password "${{ secrets.PASSWORD_ACCOUNT_GITHUB }}"
git status
echo "Andiamo ad effettuare il push dei file iniettati"
git add ${{ secrets.DIR_FILE_FE }}
cd ${{ secrets.PATH_REPOSITORY }}
echo "`date +%Y-%m-%d_%H-%M-%S`" > timeCommit.txt
git add timeCommit.txt
echo "File aggiunti!"
git commit -m "Commit dal file yml dei file iniettati"
git tag --list
echo "Andiamo ad aggiungere, se non ci era già, il tag corrente"
git tag --force ${GITHUB_REF#refs/tags/}
echo "Vediamo la nuova lista di tag:"
git tag --list
git push -u origin ${GITHUB_REF#refs/tags/} --force
echo "Push effettuato"
fi
echo "Fuori dal if"
- name: Step 6 - Creazione directory Test Suite
run: |
ls -a
if [ ! -d "${{ secrets.PATH_REPOSITORY }}/TestSuite" ]; then
echo "Vedi se sono dentro l'if numero 1"
sudo mkdir TestSuite
fi
echo "Vediamo se ha creato la cartella"
ls -a
cd TestSuite
ls -a
if [ ! -d "${{ secrets.PATH_REPOSITORY }}/TestSuite/TestHTML" ]; then
echo "Vedi se sono dentro l'if numero 2"
sudo mkdir TestHTML
fi
- name: Step 7 - Pulizia directory per split test html
run: |
ls -a
echo "Rechiamoci nella directory TestHTML"
cd TestSuite/TestHTML
echo "se esite già, cancella la cartella ReportSplitter"
if [ -d "ReportSplitter" ]; then
echo "La cartella esiste già"
sudo rm -rf ReportSplitter
echo "cartella cancellata"
fi
echo "Prova a creare cartella"
sudo mkdir ReportSplitter
echo "cartella creata"
- name: Step 8 - Esecuzione script per lo split dei test html
run: |
ls -a
echo "Rechiamoci nella directory dove si trova lo script test-script-splitter"
cd test-hooks/test-guard
ls -a
echo "Proviamo ad eseguire lo script test-script-splitter"
sudo bash -c 'node test-script-splitter.js --suites ${{ secrets.PATH_REPOSITORY }}/TestSuite/TestHTML --dest ${{ secrets.PATH_REPOSITORY }}/TestSuite/TestHTML/ReportSplitter/ReportSplit --num ${{ secrets.NUMERO_SPLIT }}'
echo "Script eseguito"
cd ${{ secrets.PATH_REPOSITORY }}/TestSuite/TestHTML/ReportSplitter
echo "Vediamo se ha generato le n cartelle ReportSplit"
ls -a
echo "Vediamo cosa c'è dentro ReportSplit0"
cd ReportSplit0
ls -a
- name: Step 9 - SEZIONE BACK-END - Esegui Applicazione Spring Boot tramite jar
run: |
cd ${{ secrets.PATH_REPOSITORY }}
bash startBackEnd.sh &
- name: Step 10 - SEZIONE FRONT-END - Esegui Applicazione FE tramite nmp
run: |
cd ${{ secrets.PATH_REPOSITORY }}
bash startFrontEnd.sh &
- name: Step 11 - Install Chrome Headless
run: |
sudo apt-get update
sudo apt-get upgrade
sudo apt-get -u dist-upgrade
sudo apt-get install -y libappindicator1 fonts-liberation
sudo apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-scalable
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get -f install
google-chrome-stable --headless --disable-gpu
- name: Step 12 - Install Chrome-Driver for test junit
run: |
wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip
echo "Vedo se si trova il punto zip"
ls -a
echo "Provo ad unzippare chormedriver_linux64.zip"
unzip chromedriver_linux64.zip
sudo mv chromedriver ${{ secrets.PATH_REPOSITORY }}/chromedriver_v94_linux64/chromedriver
sudo chown root:root ${{ secrets.PATH_REPOSITORY }}/chromedriver_v94_linux64/chromedriver
sudo chmod +x ${{ secrets.PATH_REPOSITORY }}/chromedriver_v94_linux64/chromedriver
echo "Vediamo il nome della cartella unzippata"
ls -a
echo "Vediamo se ha scaricato il driver"
cd chromedriver_v94_linux64
echo "Contenuto della cartella chromedriver_v94_linux64"
ls -a
- name: Step 13 - Eseguire test maven
run: |
cd ${{ secrets.PATH_REPOSITORY }}/project-test-headless
sudo bash -c 'mvn test site &'
sleep ${{ secrets.MIN_EXE_TEST }}m
- name: Step 14 - Visualizzare report test
run: |
cd ${{ secrets.PATH_REPOSITORY }}/project-test-headless/target/surefire-reports
ls -a
echo "Visualizziamo adesso tutti i report txt ottenuti dalle nostre test suite"
cat *.txt
echo "Fine visualizzazione report!!!"
- name: Step 15 - Spostamento report in directory corretta
run: |
cd ${{ secrets.PATH_REPOSITORY }}/project-test-headless/target
echo "Visualizziamo se c'è la cartella surefire-reports"
ls -a
echo "Rinominare la cartella surefire-reports in nome del tag della release creata"
sudo mv surefire-reports ${GITHUB_REF#refs/tags/}
echo "Vediamo se la ha rinominata:"
ls -a
sudo cp -r ${GITHUB_REF#refs/tags/} ${{ secrets.PATH_REPOSITORY }}/TestSuite
- name: Step 16 - Push dei report
run: |
echo "Vediamo quali cartelle ci sono nella directory di partenza"
ls -a
git config --global user.email "${{ secrets.EMAIL_ACCOUNT_GITHUB }}"
git config --global user.name "${{ secrets.NOME_ACCOUNT_GITHUB }}"
git config --global user.password "${{ secrets.PASSWORD_ACCOUNT_GITHUB }}"
git status
echo "Andiamo ad aggiungere la cartella dei report"
git add ${{ secrets.PATH_REPOSITORY }}/TestSuite
echo "Cartella aggiunta!"
git commit -m "Eseguendo un primo commit dal file yml"
git tag --list
echo "Andiamo ad aggiungere, se non ci era già, il tag corrente"
git tag --force ${GITHUB_REF#refs/tags/}
echo "Vediamo la nuova lista di tag:"
git tag --list
git push -u origin ${GITHUB_REF#refs/tags/} --force
echo "Push effettuato"
- name: Step 17 - Unzip progetto "Miglioramento report test"
run: |
ls
echo "Unzip del progetto"
unzip miglioramentoReportTest.zip
echo "Progetto zippato"
ls
- name: Step 18 - Esecuzione progetto "Miglioramento report test"
run: |
echo "Andiamo nella directory dove si trova il file jar eseguibile"
cd miglioramentoReportTest/target
ls -a
echo "Proviamo ad eseguire il file jar, passandogli come args[0] la directory dei report da analizzare e come args[1] il nome del report complessivo xls da generare"
java -jar miglioramentoReportTest-0.0.1-jarReportTest.jar ${{ secrets.PATH_REPOSITORY }}/TestSuite/${GITHUB_REF#refs/tags/} tabellaReportTest
echo "File jar eseguito!!!"
echo "Vediamo il file xls di report unificato se c'è"
ls -a
echo "Vediamo il contenuto del file xls di report unificato!!!"
cat tabellaReportTest.xls
- name: Step 19 - Spostamento report xls in cartella dei report txt
run: |
cd miglioramentoReportTest/target
sudo cp tabellaReportTest.xls ${{ secrets.PATH_REPOSITORY }}/TestSuite/${GITHUB_REF#refs/tags/}
- name: Step 20 - Commit del report xls
run: |
echo "Vediamo quali cartelle ci sono nella directory di partenza"
ls -a
git config --global user.email "${{ secrets.EMAIL_ACCOUNT_GITHUB }}"
git config --global user.name "${{ secrets.NOME_ACCOUNT_GITHUB }}"
git config --global user.password "${{ secrets.PASSWORD_ACCOUNT_GITHUB }}"
git status
echo "Andiamo ad aggiungere la cartella dei report"
git add ${{ secrets.PATH_REPOSITORY }}/TestSuite
echo "Cartella aggiunta!"
git commit -m "Eseguendo un secondo commit dal file yml"
git tag --list
echo "Andiamo ad aggiungere, se non ci era già, il tag corrente"
git tag --force ${GITHUB_REF#refs/tags/}
echo "Vediamo la nuova lista di tag:"
git tag --list
git push -u origin ${GITHUB_REF#refs/tags/} --force
echo "Push effettuato"