Create Lighthouse Audit #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
JAVA_VERSION: '21' | |
NODE_VERSION: '16' | |
SERVER_URL: localhost:8000 | |
WAIT_TIME: 30 | |
REPORT_PATH: ./lighthouse-report.html | |
MAVEN_CACHE: /var/tools/maven-cache | |
jobs: | |
build: | |
name: Build Modules | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_CACHE_DIR: /var/tools/maven-cache | |
GIT_COMMIT: ${{ github.sha }} | |
BUILT_MODULES: "" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Build Docker Image for Portal Modules | |
run: docker build -t build-portal-modules -f build/Dockerfile . | |
- name: Build Maven Modules Inside Docker | |
run: | | |
docker run --rm \ | |
-v $DOCKER_CACHE_DIR:/home/build/ \ | |
-v ${{ github.workspace }}:/workspace \ | |
-w /workspace \ | |
build-portal-modules sh -c ' | |
MODULES="AxonIvyPortal/portal-components AxonIvyPortal/portal AxonIvyPortal/PortalKitTestHelper Showcase/portal-user-examples Showcase/portal-developer-examples Showcase/InternalSupport Showcase/portal-components-examples" | |
BUILT_MODULES="" | |
for MODULE in $MODULES; do | |
mvn clean install -f ${MODULE}/pom.xml | |
BUILT_MODULES="$BUILT_MODULES $MODULE" | |
done | |
echo "BUILT_MODULES=$BUILT_MODULES" >> $GITHUB_ENV | |
' | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-output | |
path: '**/*/target/*.iar' | |
deploy: | |
name: Deploy Modules | |
runs-on: ubuntu-latest | |
needs: build | |
env: | |
DOCKER_CACHE_DIR: /var/tools/maven-cache | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-output | |
- name: Load Common Utils | |
run: | | |
echo "Loading common utils" | |
# Simulate loading 'utils.groovy' | |
- name: Build Docker Image for Deployment | |
run: docker build -t deploy-modules-to-engine -f build/Dockerfile . | |
- name: Deploy Maven Modules Inside Docker | |
run: | | |
docker run --rm \ | |
-v $DOCKER_CACHE_DIR:/home/build/ \ | |
-v ${{ github.workspace }}:/workspace \ | |
-w /workspace \ | |
deploy-modules-to-engine sh -c ' | |
ENGINE_URL="http://jenkins-master:8000" | |
BUILD_PLUGIN_VERSION=$(mvn help:evaluate -Dexpression=build.plugin.version -f AxonIvyPortal/portal-components/pom.xml -q -DforceStdout) | |
for MODULE in $BUILT_MODULES; do | |
mvn com.axonivy.ivy.ci:project-build-plugin:${BUILD_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=${ENGINE_URL} \ | |
-Divy.test.engine=MODIFY_EXISTING \ | |
-Divy.deploy.test.users=true | |
done | |
' | |
lighthouse-audit: | |
name: Lighthouse Audit | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Lighthouse | |
run: npm install -g lighthouse | |
- name: Wait for Server to Be Ready | |
run: | | |
for i in $(seq 1 ${{ env.WAIT_TIME }}); do | |
if curl -s ${{ env.SERVER_URL }} > /dev/null; then | |
echo "Server is ready" | |
exit 0 | |
else | |
echo "Waiting for server..." | |
sleep 1 | |
fi | |
done | |
echo "Server did not start in time" && exit 1 | |
- 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 }} |