-
Notifications
You must be signed in to change notification settings - Fork 3
119 lines (98 loc) · 3.78 KB
/
build_test.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
name: Build and SonarQube Analysis
on:
pull_request:
branches:
# - dev # when working with a development seat of sonarServer
- main
push:
branches:
# - dev # when working with a development seat of sonarServer
- main
jobs:
build-and-test:
runs-on: macos-latest
env:
PORT: 4201
APP_PORT: 4200
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set Up Node.js
uses: actions/setup-node@v3
with:
node-version: 20.16.0
- name: Install Dependencies
run: |
echo "\nInstalling dependencies\n\n"
npm ci
- name: Run Translation Validation
run: |
echo "\nRunning translation validation\n\n"
cd tests/translation && npx ts-node translation-validation.ts
- name: Build the Client
run: |
echo "\nBuilding the client\n\n"
cd client && npm run build
- name: Run Server Tests
run: |
echo "\nRunning server tests\n\n"
cd server && npm test
- name: Run Client Tests
run: |
echo "\nRunning client tests\n\n"
cd client && npm test
# #e2e Tests
# TODO uncomment once testcafe works with chrome latest
# - name: Start Angular server
# run: npm run prod &
# - name: Wait for Angular server to start
# run: |
# until curl --output /dev/null --silent --head --fail http://localhost:4200; do
# echo 'Waiting for Angular server...'
# sleep 5
# done
# - name: Run E2E Tests
# run: |
# echo "\nRunning e2e tests\n\n"
# cd tests/e2e && node clean_screenshots && node test_runner
# - name: Run Screenshot Diff Tests
# run: |
# echo "\nRunning screenshot diff tests\n\n"
# cd tests/e2e && npx testcafe-blink-diff screenshots --compare accepted:tested --open --threshold 0.003
- name: Install SonarScanner
run: |
curl -sSLo sonar-scanner-cli.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610-macosx-aarch64.zip
unzip -q sonar-scanner-cli.zip -d $HOME/sonar-scanner
echo "$HOME/sonar-scanner/sonar-scanner-6.2.1.4610-macosx-aarch64/bin" >> $GITHUB_PATH
- name: Run SonarScanner
run: |
sonar-scanner \
-Dsonar.projectKey=TheGameKnave_angular-boilerplate \
-Dsonar.organization=thegameknave \
-Dsonar.host.url=https://sonarcloud.io
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Wait for Quality Gate
run: |
TASK_ID=$(cat .scannerwork/report-task.txt | grep ceTaskId | cut -d= -f2)
echo "Fetching task status... for $TASK_ID"
curl -s -u "${{ secrets.SONAR_TOKEN }}:" "https://sonarcloud.io/api/ce/task?id=$TASK_ID" -o task.json
echo "Task API Response:"
cat task.json
STATUS=$(grep -o '"status":"[^"]*"' task.json | cut -d: -f2 | tr -d '"')
if [[ "$STATUS" != "SUCCESS" ]]; then
echo "Analysis did not complete successfully!"
exit 1
fi
echo "Fetching Quality Gate status..."
ANALYSIS_ID=$(grep -o '"analysisId":"[^"]*"' task.json | cut -d: -f2 | tr -d '"')
curl -s -u "${{ secrets.SONAR_TOKEN }}:" "https://sonarcloud.io/api/qualitygates/project_status?analysisId=$ANALYSIS_ID" -o gate.json
echo "Quality Gate API Response:"
cat gate.json
GATE_STATUS=$(jq -r '.projectStatus.status' gate.json)
if [[ "$GATE_STATUS" != "OK" ]]; then
echo "Quality Gate failed!"
exit 1
fi
echo "Quality Gate passed successfully!"
shell: bash