Skip to content

run lighthouse tests after deploying to staging env #68

run lighthouse tests after deploying to staging env

run lighthouse tests after deploying to staging env #68

Workflow file for this run

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# we can build and run tests in a single step or do it in multiple steps...
# the "package" phase on maven implicitly will download dependencies, build classes, run unit tests, and package classes
name: CI with Maven
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
types: [opened, synchronize]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '17', '21' ]
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Build and run unit tests
run: mvn -B package --file pom.xml
- name: Run integration tests
run: mvn -B integration-test verify --file pom.xml
- name: Add code coverage information to PR
id: jacoco-pr
uses: madrapps/jacoco-report@v1.7.1
if: github.event_name == 'pull_request'
with:
paths: |
${{ github.workspace }}/**/target/site/jacoco-merged-test-coverage-report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 80
min-coverage-changed-files: 80
- name: Push results to Xray on Jira Cloud
if: always()
env:
XRAYCLOUD_CLIENT_ID: ${{ secrets.XRAYCLOUD_CLIENT_ID }}
XRAYCLOUD_CLIENT_SECRET: ${{ secrets.XRAYCLOUD_CLIENT_SECRET }}
XRAYCLOUD_TEST_PLAN_KEY: ${{ vars.XRAYCLOUD_TEST_PLAN_KEY }}
REVISON: ${{ github.ref_name}}
TEST_ENVIRONMENT: java${{ matrix.java }}
run: mvn -Dxray.clientId=${{ env.XRAYCLOUD_CLIENT_ID }} -Dxray.clientSecret=${{ env.XRAYCLOUD_CLIENT_SECRET }} -Dxray.testEnvironment=${{ env.TEST_ENVIRONMENT }} -Dxray.testPlanKey=${{ env.XRAYCLOUD_TEST_PLAN_KEY }} -Dxray.revision=${{ env.REVISON }} xray:import-results
deploy-staging:
runs-on: ubuntu-latest
needs: build
permissions:
deployments: write
steps:
- uses: JorgeLNJunior/render-deploy@v1.4.5
with:
service_id: ${{ secrets.RENDER_SERVICE_ID_STAGING }}
api_key: ${{ secrets.RENDER_API_KEY }}
wait_deploy: true
github_deployment: true
deployment_environment: 'staging'
github_token: ${{ secrets.GITHUB_TOKEN }}
k6-check:
runs-on: ubuntu-latest
needs: deploy-staging
permissions:
contents: read
steps:
- uses: actions/checkout@v2
- uses: grafana/setup-k6-action@v1
- uses: grafana/run-k6-action@v1
env:
K6_API_URL: ${{ vars.STAGING_URL }}
with:
path: |
./src/test/k6/*.js
lighthouse-check:
needs: deploy-staging
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- run: mkdir /tmp/artifacts
- name: Run Lighthouse
uses: foo-software/lighthouse-check-action@master
id: lighthouseCheck
with:
accessToken: ${{ secrets.GITHUB_TOKEN }}
outputDirectory: /tmp/artifacts
urls: '${{ vars.STAGING_URL}}'
prCommentEnabled: true
prCommentSaveOld: true
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: Lighthouse reports
path: /tmp/artifacts
- name: Handle Lighthouse Check results
uses: foo-software/lighthouse-check-status-action@master
with:
lighthouseCheckResults: ${{steps.lighthouseCheck.outputs.lighthouseCheckResults }}
minAccessibilityScore: "95"
minBestPracticesScore: "95"
minPerformanceScore: "78"
minProgressiveWebAppScore: "90"
minSeoScore: "90"