perf: project program stage data elements in preheat #52012
This file contains hidden or 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: Run api tests | |
| env: | |
| # This is to make sure Maven don't timeout fetching dependencies. See: https://github.com/actions/virtual-environments/issues/1499 | |
| MAVEN_OPTS: -Xmx1024m -Xms1024m -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125 | |
| # PR → quiet (unless ci-verbose label), push/schedule → info, workflow_dispatch → user choice | |
| MAVEN_ARGS: ${{ (inputs.maven_log == 'debug' && '-X') || (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci-verbose') && '-q') || (inputs.maven_log == 'quiet' && '-q') || '' }} | |
| # Controls log4j2 suppression of expected test errors. ci-verbose label sets to error to show them. | |
| TEST_LOG_SUPPRESSED_LEVEL: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-verbose') && 'error') || (inputs.maven_log == 'debug' && 'error') || 'off' }} | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| maven_log: | |
| description: "Maven log verbosity" | |
| required: false | |
| default: "quiet" | |
| type: choice | |
| options: | |
| - quiet | |
| - info | |
| - debug | |
| concurrency: | |
| group: ${{ github.workflow}}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| api-test: | |
| env: | |
| # We only publish to Dockerhub on PRs from https://github.com/dhis2/dhis2-core. PRs from forks or dependabot cannot access secrets. | |
| DOCKERHUB_PUSH: ${{ github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} | |
| CORE_IMAGE_NAME: "dhis2/core-pr:${{ github.event_name == 'pull_request' && github.event.number || 'local' }}" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: 17 | |
| distribution: temurin | |
| cache: maven | |
| - name: Login to Docker Hub | |
| if: ${{ env.DOCKERHUB_PUSH == 'true' }} | |
| uses: docker/login-action@v4.6.0 | |
| with: | |
| username: ${{ secrets.DHIS2_BOT_DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DHIS2_BOT_DOCKER_HUB_PASSWORD }} | |
| - name: Build container image | |
| run: | | |
| if [ "$DOCKERHUB_PUSH" = "true" ]; then | |
| # build and publish multi-arch images using Jib. Image is used for api tests in | |
| # this workflow and can be pulled from Dockerhub by devs to run locally, ... | |
| mvn clean verify --threads 2C --batch-mode --no-transfer-progress \ | |
| -DskipTests -Dpackaging.type=jar -Dmdep.analyze.skip --update-snapshots --file dhis-2/pom.xml \ | |
| --projects dhis-web-server --also-make --activate-profiles embedded,jibBuild \ | |
| -Djib.to.image=$CORE_IMAGE_NAME -Djib.container.labels=DHIS2_BUILD_REVISION=${{github.event.pull_request.head.sha}},DHIS2_BUILD_BRANCH=${{github.head_ref}} | |
| else | |
| # only build image for running api tests in this workflow i.e. master, 2.39, ... | |
| mvn clean verify --threads 2C --batch-mode --no-transfer-progress \ | |
| -DskipTests -Dpackaging.type=jar -Dmdep.analyze.skip --update-snapshots --file dhis-2/pom.xml \ | |
| --projects dhis-web-server --also-make --activate-profiles embedded,jibDockerBuild \ | |
| -Djib.to.image=$CORE_IMAGE_NAME | |
| fi | |
| - name: Run tests | |
| run: | | |
| cd dhis-2/dhis-test-e2e | |
| SELENIUM_IMAGE=selenium/standalone-chrome:latest DHIS2_IMAGE=$CORE_IMAGE_NAME docker compose -f docker-compose.yml -f docker-compose.e2e.yml up --remove-orphans --exit-code-from test | |
| # Informational only: scan the run's Postgres csvlog for N+1 query hot spots and | |
| # publish an HTML report. Never affects the test result or fails the build. | |
| - name: Generate N+1 query report | |
| if: always() | |
| continue-on-error: true | |
| run: | | |
| cd dhis-2/dhis-test-e2e | |
| COMPOSE="docker compose -f docker-compose.yml -f docker-compose.e2e.yml" | |
| mkdir -p n1watch/pglog | |
| # Pull the csvlog + request-id map out of the (stopped) containers. | |
| $COMPOSE cp db:/var/lib/postgresql/data/log/. n1watch/pglog/ || true | |
| $COMPOSE cp test:/target/request-id-map.json n1watch/request-id-map.json || true | |
| # Download the prebuilt n1watch binary (no Go toolchain / compile needed). `|| true` | |
| # on each command so this informational step can never fail the build. | |
| curl -sSfL -o n1watch/bin \ | |
| https://github.com/david-mackessy/n1watch/releases/latest/download/n1watch-linux-amd64 && chmod +x n1watch/bin || true | |
| n1watch/bin -report \ | |
| -dir n1watch/pglog -format html -out n1watch/n1report-e2e.html \ | |
| -group-keys controller,method -trace-key request_id \ | |
| -trace-map n1watch/request-id-map.json -trace-tags setup,teardown \ | |
| -notify=false || true | |
| - name: Upload N+1 report | |
| if: always() | |
| continue-on-error: true | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: n1watch-report | |
| path: dhis-2/dhis-test-e2e/n1watch/n1report-e2e.html | |
| if-no-files-found: ignore | |
| - name: Upload logs | |
| if: failure() | |
| run: | | |
| cd dhis-2/dhis-test-e2e | |
| docker compose logs web > ~/logs.txt | |
| - uses: actions/upload-artifact@v7 | |
| if: failure() | |
| with: | |
| name: "tomcat_logs" | |
| path: "~/logs.txt" | |
| send-slack-message: | |
| runs-on: ubuntu-latest | |
| if: | | |
| always() && | |
| contains(needs.*.result, 'failure') && | |
| github.ref == 'refs/heads/master' | |
| needs: [api-test] | |
| steps: | |
| - uses: rtCamp/action-slack-notify@v2 | |
| env: | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_BACKEND_WEBHOOK }} | |
| SLACK_CHANNEL: "team-backend" | |
| SLACK_MESSAGE: "Latest e2e test run on master failed and needs investigation :detective-duck:. \n Commit message: ${{ github.event.head_commit.message }}" | |
| SLACK_COLOR: "#ff0000" |