From 8f7eaa70c6f032f25fbfa616aaf893da183d0bf7 Mon Sep 17 00:00:00 2001 From: teleivo Date: Tue, 22 Oct 2024 14:38:06 +0200 Subject: [PATCH] ci: expect node.js on build machine --- .github/workflows/codeql-analysis.yml | 12 +-- .github/workflows/run-tests.yml | 19 ++--- CONTRIBUTING.md | 1 + dhis-2/build-nocompr.sh | 4 +- dhis-2/dhis-test-coverage/pom.xml | 2 +- dhis-2/dhis-web/dhis-web-apps/pom.xml | 67 ++++++++------- dhis-2/pom.xml | 116 ++++++++++---------------- dhis-2/run-api.sh | 2 +- docker-compose.yml | 23 +++-- jenkinsfiles/canary | 8 +- jenkinsfiles/dev | 4 +- jenkinsfiles/eos | 4 +- jenkinsfiles/stable | 4 +- 13 files changed, 122 insertions(+), 144 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 134471cbcd16..32a92de598a0 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,10 +13,10 @@ on: branches: - master schedule: - - cron: '0 12 * * *' + - cron: "0 12 * * *" concurrency: - group: ${{ github.workflow}}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true jobs: analyze: name: Analyze @@ -27,7 +27,7 @@ jobs: matrix: # Override automatic language detection by changing the below list # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: [ 'java' ] + language: ["java"] # Learn more... # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection @@ -58,9 +58,9 @@ jobs: config-file: ./.github/codeql/codeql-config.yml - name: Build core - run: mvn clean install -f ./dhis-2/pom.xml --batch-mode --no-transfer-progress -Pdev -DskipTests=true -Dmaven.javadoc.skip=true -V + run: mvn clean install -f ./dhis-2/pom.xml --batch-mode --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true -V - name: Build web - run: mvn clean install -f ./dhis-2/dhis-web/pom.xml --batch-mode --no-transfer-progress -Pdev -DskipTests=true -Dmaven.javadoc.skip=true -V + run: mvn clean install -f ./dhis-2/dhis-web/pom.xml --batch-mode --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true -V - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d32870d207c4..ab081c70fac2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -8,8 +8,8 @@ on: - master pull_request: concurrency: - group: ${{ github.workflow}}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true jobs: unit-test: runs-on: ubuntu-latest @@ -21,8 +21,8 @@ jobs: java-version: 11 distribution: temurin cache: maven - - name: Test core # NOTE: dhis-2/pom.xml needs to be installed as built artifacts are needed by dhis-web - run: mvn clean install --threads 2C --batch-mode --no-transfer-progress --update-snapshots -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty + - name: Run unit tests # NOTE: dhis-2/pom.xml needs to be installed as built artifacts are needed by dhis-web + run: mvn clean install --threads 2C --batch-mode --no-transfer-progress --update-snapshots -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty --activate-profiles unit-test timeout-minutes: 30 - name: Report coverage to codecov uses: codecov/codecov-action@v3 @@ -69,7 +69,7 @@ jobs: distribution: temurin cache: maven - name: Run integration tests - run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -Pintegration -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty + run: mvn clean test --threads 2C --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty --activate-profiles integration-test timeout-minutes: 30 - uses: actions/upload-artifact@v4 name: Upload test logs on failure @@ -120,7 +120,7 @@ jobs: distribution: temurin cache: maven - name: Run integration h2 tests - run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -PintegrationH2 -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty + run: mvn clean test --threads 2C --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-embedded-jetty --activate-profiles integration-h2-test timeout-minutes: 30 - uses: actions/upload-artifact@v4 name: Upload test logs on failure @@ -167,12 +167,11 @@ jobs: contains(needs.*.result, 'failure') && github.ref == 'refs/heads/master' - needs: [ unit-test, integration-test, integration-h2-test ] + needs: [unit-test, integration-test, integration-h2-test] steps: - uses: rtCamp/action-slack-notify@v2 env: SLACK_WEBHOOK: ${{ secrets.SLACK_BACKEND_WEBHOOK }} - SLACK_CHANNEL: 'team-backend' + SLACK_CHANNEL: "team-backend" SLACK_MESSAGE: "Latest test run on master failed and needs investigation :detective-duck:. \n Commit message: ${{ github.event.head_commit.message }}" - SLACK_COLOR: '#ff0000' - + SLACK_COLOR: "#ff0000" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b0004c0496e4..2c5733ebc588 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,6 +10,7 @@ You'll need the following software to run DHIS2 on your machine: - Java 8 - Maven +- Node.js at least v20 (used to bundle web apps) - Tomcat ## Fork diff --git a/dhis-2/build-nocompr.sh b/dhis-2/build-nocompr.sh index ab6cffdb9e33..a0bc174db0aa 100755 --- a/dhis-2/build-nocompr.sh +++ b/dhis-2/build-nocompr.sh @@ -3,5 +3,5 @@ # Requires maven to be on the classpath # Invokes the dev profile which skips tests and disables compression of war artifacts for a speedy build -mvn clean install --batch-mode --no-transfer-progress -Pdev -mvn clean install --batch-mode --no-transfer-progress -Pdev -f dhis-web/pom.xml -U +mvn clean install --batch-mode --no-transfer-progress +mvn clean install --batch-mode --no-transfer-progress -f dhis-web/pom.xml -U diff --git a/dhis-2/dhis-test-coverage/pom.xml b/dhis-2/dhis-test-coverage/pom.xml index 266f674de1a0..627de70d563e 100644 --- a/dhis-2/dhis-test-coverage/pom.xml +++ b/dhis-2/dhis-test-coverage/pom.xml @@ -201,7 +201,7 @@ report-aggregate - verify + test diff --git a/dhis-2/dhis-web/dhis-web-apps/pom.xml b/dhis-2/dhis-web/dhis-web-apps/pom.xml index 1cb5e6445775..6f4a47fe8345 100644 --- a/dhis-2/dhis-web/dhis-web-apps/pom.xml +++ b/dhis-2/dhis-web/dhis-web-apps/pom.xml @@ -18,56 +18,55 @@ dhis-web-apps - + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + + dhis-web-apps/template.html + + true + + + + + + - com.github.eirslett - frontend-maven-plugin - 1.6 + org.codehaus.mojo + exec-maven-plugin - target + npm + + run + bundle-apps + ${project.build.directory} - ${project.artifactId} + dhis-web-apps ./apps-to-bundle.json master - - - install node and npm - - install-node-and-npm - - generate-resources - - v16.13.2 - - - - - npm install - - npm - - generate-resources - - - clone apps + bundle-apps - npm + exec - generate-resources - - run bundle-apps - + prepare-package - - + + org.apache.maven.plugins + maven-war-plugin + diff --git a/dhis-2/pom.xml b/dhis-2/pom.xml index 0500c354fe0d..e886cfed6fd1 100644 --- a/dhis-2/pom.xml +++ b/dhis-2/pom.xml @@ -7,11 +7,19 @@ pom DHIS 2 - The District Health Information System 2 deals with - aggregating and reporting statistical health data. The goal is to allow users to analyze - and use this data to guide local action. The system is based around an goals of empowering - users, by allowing them to decide what to register and report data for. - http://dhis2.org + DHIS2 is a free and open-source software platform for collecting, managing, + analyzing, and sharing data. It supports online and offline data capture via web and mobile + devices, and includes built-in features for data validation and visualization. The generic DHIS2 + data model supports both routine aggregate/statistical data collection and individual/event + data, and can be applied to use cases in any sector, allowing decentralized access to data + throughout an organizational hierarchy. DHIS2 is fully customizable through the user interface + without the need for coding skills, and can be extended with custom applications, scripts, and + integrations. Each DHIS2 instance and the data stored within it are locally owned and managed. + + DHIS2 is designed and developed by the HISP Centre at University of Oslo, with the goal of + strengthening governance systems in low- and middle-income countries. It is shared as a Digital + Public Good. + https://dhis2.org UiO @@ -64,7 +72,7 @@ - ${project.basedir}/src/main/java @@ -79,10 +87,6 @@ https://sonarcloud.io -Xmx2024m --illegal-access=permit - - false - @@ -229,6 +233,7 @@ 3.1.2 3.11.0 + 3.4.1 3.3.1 3.0.0-M7 3.5.0 @@ -1642,8 +1647,8 @@ ${mockito.version} test - org.mockito @@ -1899,6 +1904,16 @@ maven-surefire-plugin ${maven-surefire-plugin.version} + + org.apache.maven.plugins + maven-surefire-report-plugin + ${maven-surefire-plugin.version} + + + org.codehaus.mojo + exec-maven-plugin + ${maven-exec-plugin.version} + org.apache.maven.plugins maven-failsafe-plugin @@ -2110,6 +2125,18 @@ jasperreports.version=${jasperreports.version} org.jacoco jacoco-maven-plugin ${jacoco-maven-plugin.version} + + + ${skipTests} + + + + prepare-agent + + prepare-agent + + + @@ -2228,14 +2255,6 @@ jasperreports.version=${jasperreports.version} org.jacoco jacoco-maven-plugin - - - prepare-agent - - prepare-agent - - - + - default - - true - + unit-test @@ -2295,10 +2310,9 @@ jasperreports.version=${jasperreports.version} - + - integration + integration-test @@ -2321,10 +2335,9 @@ jasperreports.version=${jasperreports.version} - + - integrationH2 + integration-h2-test @@ -2346,43 +2359,6 @@ jasperreports.version=${jasperreports.version} - - - dev - - true - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - false - @{argLine} ${surefireArgLine} - integration,integrationH2 - - - - org.zeroturnaround - jrebel-maven-plugin - ${jrebel-x-maven-plugin.version} - - - generate-rebel-xml - - generate - - process-resources - - - - - - - - javadoc @@ -2410,7 +2386,5 @@ jasperreports.version=${jasperreports.version} - - diff --git a/dhis-2/run-api.sh b/dhis-2/run-api.sh index c782ece73107..7dfb664016d7 100755 --- a/dhis-2/run-api.sh +++ b/dhis-2/run-api.sh @@ -50,7 +50,7 @@ fi mvn clean install \ -f "$(dirname "$0")/pom.xml" \ --batch-mode \ - -Pdev -T 100C \ + -T 100C \ -DskipTests -Dmaven.test.skip=true -Dmaven.site.skip=true -Dmaven.javadoc.skip=true java \ -Ddhis2.home=$DHIS2_HOME \ diff --git a/docker-compose.yml b/docker-compose.yml index 1fc682b635ae..9b4abb835556 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,13 +11,14 @@ services: - ./docker/dhis.conf:/opt/dhis2/dhis.conf:ro - ./docker/log4j2.xml:/opt/dhis2/log4j2.xml:ro environment: - JAVA_OPTS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8081 \ - -Dlog4j2.configurationFile=/opt/dhis2/log4j2.xml - -Dcom.sun.management.jmxremote \ - -Dcom.sun.management.jmxremote.port=9010 \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.ssl=false" + JAVA_OPTS: + "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8081 \ + -Dlog4j2.configurationFile=/opt/dhis2/log4j2.xml + -Dcom.sun.management.jmxremote \ + -Dcom.sun.management.jmxremote.port=9010 \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.ssl=false" depends_on: db: condition: service_healthy @@ -34,7 +35,11 @@ services: POSTGRES_PASSWORD: &postgres_password dhis PGPASSWORD: *postgres_password # needed by psql in healthcheck healthcheck: - test: [ "CMD-SHELL", "psql --no-password --quiet --username $$POSTGRES_USER postgres://127.0.0.1/$$POSTGRES_DB -p 5432 --command \"SELECT 'ok'\" > /dev/null" ] + test: + [ + "CMD-SHELL", + 'psql --no-password --quiet --username $$POSTGRES_USER postgres://127.0.0.1/$$POSTGRES_DB -p 5432 --command "SELECT ''ok''" > /dev/null', + ] start_period: 120s interval: 1s timeout: 3s @@ -53,4 +58,4 @@ services: - db-dump:/opt/dump volumes: - db-dump: { } + db-dump: {} diff --git a/jenkinsfiles/canary b/jenkinsfiles/canary index 441c89145936..c8a7625acdc3 100644 --- a/jenkinsfiles/canary +++ b/jenkinsfiles/canary @@ -30,14 +30,14 @@ pipeline { def formatted = "${today.format('yyyyMMdd')}" def source = "dhis2/core-dev:${branch}" def target = "dhis2/core-canary:${branch}" - + sh "docker pull ${source}" sh "docker tag ${source} ${target}" sh "docker tag ${source} ${target}-${formatted}" withDockerRegistry([credentialsId: "docker-hub-credentials", url: ""]) { sh "docker push ${target}" sh "docker push ${target}-${formatted}" - } + } } } } @@ -47,8 +47,8 @@ pipeline { echo 'Building DHIS2 ...' script { withMaven(options: [artifactsPublisher(disabled: true)]) { - sh 'mvn -X -T 4 --batch-mode --no-transfer-progress clean install -f dhis-2/pom.xml -P -default --update-snapshots -pl -dhis-web-embedded-jetty,-dhis-test-coverage' - sh 'mvn -X -T 4 --batch-mode --no-transfer-progress package -f dhis-2/dhis-web/pom.xml -P -default --update-snapshots' + sh 'mvn -X -T 4 --batch-mode --no-transfer-progress clean install -f dhis-2/pom.xml --update-snapshots -pl -dhis-web-embedded-jetty,-dhis-test-coverage' + sh 'mvn -X -T 4 --batch-mode --no-transfer-progress package -f dhis-2/dhis-web/pom.xml --update-snapshots' } } } diff --git a/jenkinsfiles/dev b/jenkinsfiles/dev index 194029620217..62abae2ddd73 100644 --- a/jenkinsfiles/dev +++ b/jenkinsfiles/dev @@ -37,8 +37,8 @@ pipeline { gitHelper.setCommitStatus("${env.DHIS2_COMMIT_SHA}", "${env.DHIS2_REPO_URL}") withMaven(options: [artifactsPublisher(disabled: true)]) { - sh 'mvn -X -T 4 --batch-mode --no-transfer-progress clean install -f dhis-2/pom.xml -P -default --update-snapshots -pl -dhis-web-embedded-jetty,-dhis-test-coverage' - sh 'mvn -X -T 4 --batch-mode --no-transfer-progress install -f dhis-2/dhis-web/pom.xml -P -default --update-snapshots' + sh 'mvn -X -T 4 --batch-mode --no-transfer-progress clean install -f dhis-2/pom.xml --update-snapshots -pl -dhis-web-embedded-jetty,-dhis-test-coverage' + sh 'mvn -X -T 4 --batch-mode --no-transfer-progress install -f dhis-2/dhis-web/pom.xml --update-snapshots' } } } diff --git a/jenkinsfiles/eos b/jenkinsfiles/eos index 8f8df6a3ed21..39b54797b841 100644 --- a/jenkinsfiles/eos +++ b/jenkinsfiles/eos @@ -26,8 +26,8 @@ pipeline { echo 'Building DHIS2 ...' script { withMaven(options: [artifactsPublisher(disabled: true)]) { - sh 'mvn -X -T 4 --batch-mode --no-transfer-progress clean install -f dhis-2/pom.xml -P -default --update-snapshots -pl -dhis-web-embedded-jetty,-dhis-test-coverage' - sh 'mvn -X -T 4 --batch-mode --no-transfer-progress package -f dhis-2/dhis-web/pom.xml -P -default --update-snapshots' + sh 'mvn -X -T 4 --batch-mode --no-transfer-progress clean install -f dhis-2/pom.xml --update-snapshots -pl -dhis-web-embedded-jetty,-dhis-test-coverage' + sh 'mvn -X -T 4 --batch-mode --no-transfer-progress package -f dhis-2/dhis-web/pom.xml --update-snapshots' } } } diff --git a/jenkinsfiles/stable b/jenkinsfiles/stable index d3151bff7de7..5176eca67807 100644 --- a/jenkinsfiles/stable +++ b/jenkinsfiles/stable @@ -35,8 +35,8 @@ pipeline { echo 'Building DHIS2 ...' script { withMaven(options: [artifactsPublisher(disabled: true)]) { - sh 'mvn -X -T 4 --batch-mode --no-transfer-progress clean install -f dhis-2/pom.xml -P -default --update-snapshots -pl -dhis-web-embedded-jetty,-dhis-test-coverage' - sh 'mvn -X -T 4 --batch-mode --no-transfer-progress install -f dhis-2/dhis-web/pom.xml -P -default --update-snapshots' + sh 'mvn -X -T 4 --batch-mode --no-transfer-progress clean install -f dhis-2/pom.xml --update-snapshots -pl -dhis-web-embedded-jetty,-dhis-test-coverage' + sh 'mvn -X -T 4 --batch-mode --no-transfer-progress install -f dhis-2/dhis-web/pom.xml --update-snapshots' } } }