Create Lighthouse Audit #11
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: '18' | |
SERVER_URL: localhost:8000 | |
WAIT_TIME: 30 | |
REPORT_PATH: ./lighthouse-report-${{ github.run_id }}.html | |
CACHE_DIR: /var/tools/maven-cache | |
BUILT_MODULES: "" | |
jobs: | |
build: | |
name: Build Modules | |
runs-on: ubuntu-latest | |
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 build -t build-portal-modules -f build/Dockerfile . | |
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: Ensure Artifact Directories Exist | |
run: mkdir -p **/target/ | |
- 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: | |
CACHE_DIR: /var/tools/maven-cache | |
steps: | |
- name: Cleanup | |
run: | | |
docker system prune -f | |
rm -rf /var/tools/maven-cache || true | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-output | |
- name: Install Groovy | |
run: | | |
sudo apt update | |
sudo apt install -y groovy | |
- name: Load Common Utils | |
run: | | |
groovy build/common/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 ${{ env.CACHE_DIR }}:/home/build/ \ | |
-v ${{ github.workspace }}:/workspace \ | |
-w /workspace \ | |
deploy-modules-to-engine sh -c ' | |
ENGINE_URL=${{ env.SERVER_URL }} | |
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 -f ${{ env.SERVER_URL }}/health > /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: Ensure Lighthouse Report Directory | |
run: mkdir -p ${{ env.REPORT_PATH }} | |
- 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 }} |