-
Notifications
You must be signed in to change notification settings - Fork 3
118 lines (100 loc) · 4.09 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
name: lighthouse-report
run-name: Create Lighthouse Audit
on:
push:
branches:
- feature/IVYPORTAL-17377-Create-pipeline-to-run-Lighthouse-report
pull_request:
branches:
- master
env: # Define reusable environment variables
JAVA_VERSION: '21'
NODE_VERSION: '16'
SERVER_URL: localhost:8000
WAIT_TIME: 30 # Time to wait for server to be ready
REPORT_PATH: ./lighthouse-report.html
MAVEN_CACHE: /var/tools/maven-cache
jobs:
lighthouse-audit: # Renamed job for clarity
runs-on: ubuntu-latest
steps:
- name: checkout to master
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
ref: 'master'
- name: Setup Java & Maven dependency caching
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
- name: Setup Node.js and Install Lighthouse CLI
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- run: npm install -g lighthouse
- name: Set up docker and Maven
run: |
sudo apt-get update
sudo apt-get install -y maven
docker --version
mvn --version
- name: Build Modules
run: |
DOCKER_IMAGE="build-portal-modules"
DOCKERFILE_PATH="build/Dockerfile"
MODULES="AxonIvyPortal/portal-components AxonIvyPortal/portal AxonIvyPortal/PortalKitTestHelper Showcase/portal-user-examples Showcase/portal-developer-examples Showcase/InternalSupport Showcase/portal-components-examples"
MAVEN_CMD="mvn clean install -f"
docker build -t $DOCKER_IMAGE -f $DOCKERFILE_PATH .
docker run -v ${{ env.MAVEN_CACHE }}:/home/build/ $DOCKER_IMAGE bash -c "
function get_changed_modules() {
echo \$(git diff --name-only \$GITHUB_SHA \$GITHUB_SHA~1)
}
function build_modules() {
local modules=\"$MODULES\"
local changed_modules=\$(get_changed_modules)
local modules_to_build=''
for module in \$modules; do
if [[ \$changed_modules == *\$module* || '${{ inputs.modulesMustBeBuilt }}' == *\${module##*/}* ]]; then
$MAVEN_CMD \$module/pom.xml
modules_to_build=\"\$modules_to_build \$module\"
fi
done
echo \"Built modules: \$modules_to_build\"
}
build_modules
"
- name: Deploy Modules
run: |
maven_cache="${{ env.MAVEN_CACHE }}"
server_url="${{ env.SERVER_URL }}"
docker_image="deploy-modules-to-engine"
docker_file="build/Dockerfile"
# Build Docker image
docker build -t $docker_image -f $docker_file .
# Run deployment script inside Docker container
docker run -v "$maven_cache:/home/build/" $docker_image bash -c "
# Extract Maven build plugin version
plugin_version=\$(mvn help:evaluate -Dexpression=build.plugin.version -q -DforceStdout -f AxonIvyPortal/portal-components/pom.xml)
# Deploy each module to the engine
for module in \$built_modules; do
mvn com.axonivy.ivy.ci:project-build-plugin:\$plugin_version:deploy-to-engine -f \$module/pom.xml \
-Divy.deploy.server.id=engine-cockpit \
-Divy.deploy.engine.app=Portal \
-Divy.deploy.method=HTTP \
-Divy.deploy.engine.url=\$server_url \
-Divy.test.engine=MODIFY_EXISTING \
-Divy.deploy.test.users=true
done
"
- name: Start Application
run: docker-compose up -d
- name: Wait for Server to Start
run: sleep ${{ env.WAIT_TIME }}
- name: Execute Lighthouse Audit
run: lighthouse ${{ env.SERVER_URL }} --output=json --output=html --output-path=${{ env.REPORT_PATH }}
- name: Upload Audit Report
uses: actions/upload-artifact@v3
with:
name: lighthouse-report
path: ${{ env.REPORT_PATH }}