-
Notifications
You must be signed in to change notification settings - Fork 3
194 lines (174 loc) · 6.73 KB
/
lighthouse-report.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
name: Lighthouse Audit
run-name: Create Lighthouse Audit For LTS 10
on:
pull_request:
branches:
- master
- release/*
env:
ENGINE_DIR: $GITHUB_WORKSPACE/ivy/engine/nightly-10
ENGINE_URL: https://developer.axonivy.com/permalink/nightly-10/axonivy-engine.zip
WAIT_TIME: 60
SERVER_URL: http://localhost:8080
REPORT_PATH: $GITHUB_WORKSPACE/lighthouse-report
REPORT_DIR: $GITHUB_WORKSPACE/lighthouse-reports
jobs:
LightHouseAudit:
runs-on: ubuntu-latest
name: Lighthouse Audit - ${{ github.head_ref || github.ref_name }}
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set Up Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.8.8
- name: Export Environment Variables
run: |
echo "export IVY_JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "export JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "export PATH=$JAVA_HOME/bin:$PATH" >> $GITHUB_ENV
- name: Set Up and Verify Directories
run: |
ENGINE_DIR="${GITHUB_WORKSPACE}/ivy/engine/nightly-10"
mkdir -p $ENGINE_DIR
sudo chown -R $USER:$USER $ENGINE_DIR
echo "ENGINE_DIR=$ENGINE_DIR" >> $GITHUB_ENV
- name: Download Engine
run: |
cd $ENGINE_DIR
wget $ENGINE_URL -O axonivy-engine.zip
unzip -o axonivy-engine.zip -d .
rm axonivy-engine.zip
- name: Verify Engine Directory
run: |
if [ ! -d "$ENGINE_DIR" ]; then
echo "Engine directory does not exist"
exit 1
fi
- name: Start Axon Ivy Engine
run: |
cd "${ENGINE_DIR}/bin"
chmod +x ./AxonIvyEngine
nohup ./AxonIvyEngine > engine.log 2>&1 &
echo $! > engine.pid
for ((i=1; i<=${{ env.WAIT_TIME }}; i++)); do
if curl -s -f http://localhost:8080/demo-portal > /dev/null; then
exit 0
fi
sleep 1
done
cat engine.log
exit 1
env:
IVY_JAVA_HOME: ${{ env.JAVA_HOME }}
JAVA_HOME: ${{ env.JAVA_HOME }}
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${{ env.JAVA_HOME }}/bin:$PATH
- name: Build Portal Modules
run: |
modules=(
"AxonIvyPortal/portal-components"
"AxonIvyPortal/portal"
"AxonIvyPortal/AxonIvyExpress"
"AxonIvyPortal/PortalKitTestHelper"
"Showcase/portal-user-examples"
"Showcase/portal-developer-examples"
"Showcase/InternalSupport"
"Showcase/portal-components-examples"
"AxonIvyPortal/PortalApp"
"Showcase/portal-demo-app"
)
for module in "${modules[@]}"; do
mvn clean install -f $module/pom.xml -Divy.engine.directory=$ENGINE_DIR
done
- name: Deploy Portal Modules
run: |
DEPLOYMENT=$ENGINE_DIR/system/demo-applications/demo-portal
rm -rf $DEPLOYMENT/*
cp Showcase/portal-demo-app/target/*.zip $DEPLOYMENT
cp Showcase/portal-developer-examples/target/*.iar $DEPLOYMENT
cp Showcase/portal-components-examples/target/*.iar $DEPLOYMENT
- name: Wait for Server Health Check
run: |
for ((i=1; i<=${{ env.WAIT_TIME }}; i++)); do
if curl -s -f http://localhost:8080/demo-portal/pro/portal/1549F58C18A6C562/DashboardPage.ivp?dashboardId=1 > /dev/null; then
exit 0
fi
sleep 1
done
cat engine.log
exit 1
- name: Install Chrome Dependencies
run: |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install -y google-chrome-stable xvfb x11-xserver-utils
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y x11-utils
npm init -y
npm install lighthouse puppeteer @actions/core
- name: Create Report Directory
run: |
mkdir -p lighthouse-reports
echo "REPORT_DIR=$(pwd)/lighthouse-reports" >> $GITHUB_ENV
echo "REPORT_PATH=$(pwd)/lighthouse-reports/report.html" >> $GITHUB_ENV
- name: Set Up Virtual Display
run: |
Xvfb :99 -screen 0 1920x1080x24 -ac &
sleep 3
export DISPLAY=:99
- name: Run Puppeteer Script
run: |
cd AxonIvyPortal/portal-selenium-test/lighthouse
npm install
node puppeteer-script.mjs
- name: Upload Report
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: lighthouse-report
path: |
AxonIvyPortal/portal-selenium-test/lighthouse/lighthouse-report.html
AxonIvyPortal/portal-selenium-test/lighthouse/lighthouse-reports/report.json
- name: Generate HTML Summary
run: |
cd AxonIvyPortal/portal-selenium-test/lighthouse
HTML_REPORT=""
if [ -f "lighthouse-report.html" ]; then
HTML_REPORT="lighthouse-report.html"
elif [ -f "lighthouse-reports/lighthouse-report.html" ]; then
HTML_REPORT="lighthouse-reports/lighthouse-report.html"
fi
if [ -n "$HTML_REPORT" ]; then
node -e "
const core = require('@actions/core');
const fs = require('fs');
const results = JSON.parse(fs.readFileSync('lighthouse-reports/report.json', 'utf8'));
const summary = core.summary.addHeading('🚦 Audit Results');
Object.entries(results.categories).forEach(([key, value]) => {
summary.addRaw(\`### \${value.title}\n📊 Score: \${Math.floor(value.score * 100)}%\n\n\`);
});
summary.addSeparator().addLink('📋 Download Full Report',
'https://github.com/' + process.env.GITHUB_REPOSITORY +
'/actions/runs/' + process.env.GITHUB_RUN_ID + '/artifacts/' + ${{ steps.upload-artifact.outputs.artifact-id }}).write();
"
else
exit 1
fi
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}