Create Lighthouse Audit #12
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 | |
DOCKER_CACHE_DIR: /var/tools/maven-cache | |
MODULES: | | |
AxonIvyPortal/portal-components AxonIvyPortal/portal AxonIvyPortal/PortalKitTestHelper \ | |
Showcase/portal-user-examples Showcase/portal-developer-examples Showcase/InternalSupport \ | |
Showcase/portal-components-examples | |
ENGINE_URL: localhost:8000 | |
jobs: | |
build: | |
name: Build Modules | |
runs-on: ubuntu-latest | |
env: | |
GIT_COMMIT: ${{ github.sha }} | |
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 | |
id: build-maven | |
run: | | |
docker run --rm \ | |
-v ${{ env.DOCKER_CACHE_DIR }}:/home/build/ \ | |
-v ${{ github.workspace }}:/workspace \ | |
-w /workspace \ | |
build-portal-modules sh -c ' | |
BUILT_MODULES="" | |
for MODULE in ${{ env.MODULES }}; do | |
mvn clean install -f ${MODULE}/pom.xml | |
BUILT_MODULES="$BUILT_MODULES $MODULE" | |
done | |
echo "::set-output name=built_modules::$BUILT_MODULES" | |
' | |
- 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: | |
BUILT_MODULES: ${{ needs.build.outputs.built_modules }} | |
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 utilities (e.g., groovy scripts)" # Placeholder for actual logic | |
- 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 ${{ env.DOCKER_CACHE_DIR }}:/home/build/ \ | |
-v ${{ github.workspace }}:/workspace \ | |
-w /workspace \ | |
deploy-modules-to-engine sh -c ' | |
BUILD_PLUGIN_VERSION=$(mvn help:evaluate -Dexpression=build.plugin.version -f AxonIvyPortal/portal-components/pom.xml -q -DforceStdout) | |
for MODULE in ${{ env.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=${{ env.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=1; i<=${{ env.WAIT_TIME }}; i++)); do | |
if curl -s ${{ env.SERVER_URL }} > /dev/null; then | |
echo "Server is ready" | |
exit 0 | |
fi | |
echo "Waiting for server..." | |
sleep 1 | |
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 }} |