Skip to content

Commit

Permalink
Merge branch 'master' into DHIS2-18001
Browse files Browse the repository at this point in the history
  • Loading branch information
enricocolasante committed Sep 25, 2024
2 parents e8e6820 + cc71e1b commit 64d2ee0
Show file tree
Hide file tree
Showing 82 changed files with 469 additions and 1,485 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

dhis-2/*.sh @dhis2/devops

dhis-2/dhis-web-apps/apps-to-bundle.json @dhis2/devops
dhis-2/dhis-web-server/** @dhis2/devops

docker/** @dhis2/devops

Expand Down
12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ updates:
- dependency-name: "org.apache.struts:*" # will be removed from core (significant work involved in upgrade with the risk of regressions)
versions:
- ">= 3.0"
- dependency-name: "org.eclipse.jetty:*" # Jetty 11 moved some code to a different package, updated the Servlet version which requires more work
versions:
- ">= 11.0"
- dependency-name: "org.springframework:*" # Spring framework 6 requires minimum JDK 17 so it will require more effort/time until we update it
versions:
- ">= 6.0"
Expand Down Expand Up @@ -120,9 +117,6 @@ updates:
- dependency-name: "org.apache.struts:*" # will be removed from core (significant work involved in upgrade with the risk of regressions)
versions:
- ">= 3.0"
- dependency-name: "org.eclipse.jetty:*" # Jetty 11 moved some code to a different package, updated the Servlet version which requires more work
versions:
- ">= 11.0"
- dependency-name: "org.springframework:*" # Spring framework 6 requires minimum JDK 17 so it will require more effort/time until we update it
versions:
- ">= 6.0"
Expand Down Expand Up @@ -219,9 +213,6 @@ updates:
- dependency-name: "org.apache.struts:*" # will be removed from core (significant work involved in upgrade with the risk of regressions)
versions:
- ">= 3.0"
- dependency-name: "org.eclipse.jetty:*" # Jetty 11 moved some code to a different package, updated the Servlet version which requires more work
versions:
- ">= 11.0"
- dependency-name: "org.springframework:*" # Spring framework 6 requires minimum JDK 17 so it will require more effort/time until we update it
versions:
- ">= 6.0"
Expand Down Expand Up @@ -309,9 +300,6 @@ updates:
- dependency-name: "org.apache.struts:*" # will be removed from core (significant work involved in upgrade with the risk of regressions)
versions:
- ">= 3.0"
- dependency-name: "org.eclipse.jetty:*" # Jetty 11 moved some code to a different package, updated the Servlet version which requires more work
versions:
- ">= 11.0"
- dependency-name: "org.antlr:antlr4-runtime" # Automatically upgrade ANTLR version can cause issues in rule-engine and antlr-parser libraries
- dependency-name: "org.springframework:*" # Spring framework 6 requires minimum JDK 17 so it will require more effort/time until we update it
versions:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/analyse-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ on:
push:
branches:
- master
- '2.3[1-9]'
- '2.4[0-9]'
- "2.3[1-9]"
- "2.4[0-9]"
pull_request:
branches:
- master
- '2.3[1-9]'
- '2.4[0-9]'
- "2.3[1-9]"
- "2.4[0-9]"
concurrency:
group: ${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true
group: ${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true
jobs:
sonarqube:
runs-on: ubuntu-latest
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/run-api-analytics-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:

on:
pull_request:
types: [ opened, labeled, synchronize ]
types: [opened, labeled, synchronize]
schedule:
- cron: "16 1 * * *" # Run at 01:16 AM
concurrency:
Expand Down Expand Up @@ -39,10 +39,13 @@ jobs:
distribution: temurin
cache: maven

- name: Build core image
- name: Build container image
run: |
mvn clean install --threads 2C --batch-mode --no-transfer-progress -DskipTests -Dmaven.test.skip=true --update-snapshots -f dhis-2/pom.xml -pl -dhis-test-integration,-dhis-test-coverage,-dhis-web-server
mvn clean install -PjibDockerBuild -DactiveProfile=jibDockerBuild --batch-mode --no-transfer-progress -DskipTests -Dmaven.test.skip=true -f ./dhis-2/dhis-web-server/pom.xml -Djib.to.image=$CORE_IMAGE_NAME
# only build image for running api tests in this workflow
mvn clean package --threads 2C --batch-mode --no-transfer-progress \
-DskipTests -Dmaven.test.skip=true --update-snapshots --file dhis-2/pom.xml \
--projects dhis-web-server --also-make --activate-profiles jibDockerBuild \
-Djib.to.image=$CORE_IMAGE_NAME
- name: Get Sierra Leone DB from cache
uses: actions/cache@v4
Expand All @@ -57,9 +60,6 @@ jobs:
mkdir -p ${{ env.SIERRA_LEONE_DB_PATH }}
wget https://databases.dhis2.org/sierra-leone/${{ env.SIERRA_LEONE_DB_VERSION }}/analytics_be/dhis2-db-sierra-leone.sql.gz --no-clobber --directory-prefix ${{ env.SIERRA_LEONE_DB_PATH }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Run tests
run: |
cd dhis-2/dhis-test-e2e
Expand All @@ -78,7 +78,7 @@ jobs:
if: failure()
with:
name: "tomcat_logs"
path: '~/logs.txt'
path: "~/logs.txt"

send-slack-message:
runs-on: ubuntu-latest
Expand All @@ -87,11 +87,11 @@ jobs:
contains(needs.*.result, 'failure') &&
github.ref == 'refs/heads/master'
needs: [ api-analytics-test ]
needs: [api-analytics-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 analytics e2e test run on master failed and needs investigation :detective-duck:. \n Commit message: ${{ github.event.head_commit.message }}"
SLACK_COLOR: '#ff0000'
SLACK_COLOR: "#ff0000"
24 changes: 12 additions & 12 deletions .github/workflows/run-api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ jobs:
username: ${{ secrets.DHIS2_BOT_DOCKER_HUB_USERNAME }}
password: ${{ secrets.DHIS2_BOT_DOCKER_HUB_PASSWORD }}

- name: Build war
run: |
mvn clean install --threads 2C --batch-mode --no-transfer-progress -DskipTests -Dmaven.test.skip=true --update-snapshots -f dhis-2/pom.xml -pl -dhis-test-integration,-dhis-test-coverage,-dhis-web-server
- 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 install -DactiveProfile=PjibBuild --batch-mode --no-transfer-progress -DskipTests -Dmaven.test.skip=true -f dhis-2/dhis-web-server/pom.xml jib:build -PjibBuild \
-Djib.to.image=$CORE_IMAGE_NAME -Djib.container.labels=DHIS2_BUILD_REVISION=${{github.event.pull_request.head.sha}},DHIS2_BUILD_BRANCH=${{github.head_ref}}
mvn clean package --threads 2C --batch-mode --no-transfer-progress \
-DskipTests -Dmaven.test.skip=true --update-snapshots --file dhis-2/pom.xml \
--projects dhis-web-server --also-make --activate-profiles 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 install -PjibDockerBuild -DactiveProfile=jibDockerBuild --batch-mode --no-transfer-progress -DskipTests -Dmaven.test.skip=true -f ./dhis-2/dhis-web-server/pom.xml \
-Djib.to.image=$CORE_IMAGE_NAME
mvn clean package --threads 2C --batch-mode --no-transfer-progress \
-DskipTests -Dmaven.test.skip=true --update-snapshots --file dhis-2/pom.xml \
--projects dhis-web-server --also-make --activate-profiles jibDockerBuild \
-Djib.to.image=$CORE_IMAGE_NAME
fi
- name: Run tests
Expand All @@ -67,7 +67,7 @@ jobs:
if: failure()
with:
name: "tomcat_logs"
path: '~/logs.txt'
path: "~/logs.txt"

send-slack-message:
runs-on: ubuntu-latest
Expand All @@ -76,11 +76,11 @@ jobs:
contains(needs.*.result, 'failure') &&
github.ref == 'refs/heads/master'
needs: [ api-test ]
needs: [api-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 e2e test run on master failed and needs investigation :detective-duck:. \n Commit message: ${{ github.event.head_commit.message }}"
SLACK_COLOR: '#ff0000'
SLACK_COLOR: "#ff0000"
24 changes: 12 additions & 12 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,8 +21,8 @@ jobs:
java-version: 17
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-server,-dhis-web-apps
- name: Test core
run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress --update-snapshots --file ./dhis-2/pom.xml
timeout-minutes: 30
- name: Report coverage to codecov
uses: codecov/codecov-action@v3
Expand All @@ -41,7 +41,7 @@ jobs:
path: coverage.tar
retention-days: 5
- name: Generate surefire aggregate report
run: mvn surefire-report:report-only -Daggregate=true --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-server,-dhis-test-coverage,-dhis-web-apps
run: mvn surefire-report:report-only -Daggregate=true --batch-mode --no-transfer-progress --file ./dhis-2/pom.xml --projects -dhis-test-coverage
# tar due to https://github.com/actions/upload-artifact/blob/3cea5372237819ed00197afe530f5a7ea3e805c8/README.md?plain=1#L254
- name: Tar surefire individual reports
run: find . -name "surefire-reports" -type d -exec find {} -type f -name "*.xml" -printf '%p\0' \; | tar --null --files-from=- -cvf surefire_reports.tar
Expand All @@ -65,7 +65,7 @@ jobs:
distribution: temurin
cache: maven
- name: Run integration tests
run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -Pintegration --update-snapshots -f ./dhis-2/pom.xml -pl -dhis-web-server,-dhis-web-apps
run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -Pintegration --update-snapshots --file ./dhis-2/pom.xml
timeout-minutes: 30
- uses: actions/upload-artifact@v4
name: Upload test logs on failure
Expand All @@ -92,7 +92,7 @@ jobs:
path: coverage.tar
retention-days: 5
- name: Generate surefire aggregate report
run: mvn surefire-report:report-only -Daggregate=true --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-server,-dhis-test-coverage,-dhis-web-apps
run: mvn surefire-report:report-only -Daggregate=true --batch-mode --no-transfer-progress --file ./dhis-2/pom.xml --projects -dhis-test-coverage
# tar due to https://github.com/actions/upload-artifact/blob/3cea5372237819ed00197afe530f5a7ea3e805c8/README.md?plain=1#L254
- name: Tar surefire individual reports
run: find . -name "surefire-reports" -type d -exec find {} -type f -name "*.xml" -printf '%p\0' \; | tar --null --files-from=- -cvf surefire_reports.tar
Expand All @@ -116,7 +116,7 @@ jobs:
distribution: temurin
cache: maven
- name: Run integration h2 tests
run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -PintegrationH2 --update-snapshots -f ./dhis-2/pom.xml -pl -dhis-web-server,-dhis-web-apps
run: mvn clean verify --threads 2C --batch-mode --no-transfer-progress -PintegrationH2 --update-snapshots --file ./dhis-2/pom.xml
timeout-minutes: 30
- uses: actions/upload-artifact@v4
name: Upload test logs on failure
Expand All @@ -143,7 +143,7 @@ jobs:
path: coverage.tar
retention-days: 5
- name: Generate surefire aggregate report
run: mvn surefire-report:report-only -Daggregate=true --batch-mode --no-transfer-progress -f ./dhis-2/pom.xml -pl -dhis-web-server,-dhis-test-coverage,-dhis-web-apps
run: mvn surefire-report:report-only -Daggregate=true --batch-mode --no-transfer-progress --file ./dhis-2/pom.xml --projects -dhis-test-coverage
# tar due to https://github.com/actions/upload-artifact/blob/3cea5372237819ed00197afe530f5a7ea3e805c8/README.md?plain=1#L254
- name: Tar surefire individual reports
run: find . -name "surefire-reports" -type d -exec find {} -type f -name "*.xml" -printf '%p\0' \; | tar --null --files-from=- -cvf surefire_reports.tar
Expand All @@ -163,11 +163,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"
18 changes: 7 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

## Guidelines

Read the contribution [guidelines](https://developers.dhis2.org/community/contribute/).
Read the contribution [guidelines](https://developers.dhis2.org/community/contribute).

## Requirements

You'll need the following software to run DHIS2 on your machine:

- Java 17
- Maven
- Node.js at least v20 (used to bundle web apps)
- Tomcat

## Fork
Expand All @@ -24,14 +25,9 @@ Clone the repository:

Go in the repo and run maven:

cd dhis-2
mvn install
cd dhis-web
mvn install -U
mvn clean package --file dhis-2/pom.xml -DskipTests

Each project in the /dhis-2/dhis-web directory is an individual web module. The dhis-web-server project is an assembly of all the individual web modules.

This should create a ready to use war in /dhis-2/dhis-web-server/target
This should create a ready to use war ./dhis-2/dhis-web-server/target/dhis.war

## Run locally

Expand All @@ -41,7 +37,7 @@ Deploy the war in Tomcat using either the manager or a simple copy to the webapp

Before starting tomcat, you need to create a DHIS2_HOME pointing to a folder on your machine:

export DHIS2_HOME=~/dhis2_home
export DHIS2_HOME=~/dhis2_home

this folder will host the `dhis.conf` file with at minimum your database settings. To start as fast as possible, you can use the H2 in memory database using the following configuration:

Expand All @@ -55,10 +51,10 @@ connection.password =

You can get such a file in your DHIS2_HOME folder with a simple call:

wget -O $DHIS2_HOME/dhis.conf https://gist.githubusercontent.com/vanakenm/87b729fbf78ec52ca4c5da7856c62584/raw/9554680c8ab62d7f2bbecc3847406fa17d551a2e/dhis.conf
wget -O $DHIS2_HOME/dhis.conf https://gist.githubusercontent.com/vanakenm/87b729fbf78ec52ca4c5da7856c62584/raw/9554680c8ab62d7f2bbecc3847406fa17d551a2e/dhis.conf

You can now start tomcat and go to localhost:8080/dhis - get in with admin/district as user/password.

## Alternative - Build and run in Docker

It is possible to build and run DHIS2 with Docker, on any operating system with no dependencies on local Java, Maven, or Tomcat, refer to the [documentation](https://github.com/dhis2/dhis2-core/blob/master/docker/README.md).
It is possible to build and run DHIS2 with Docker, on any operating system with no dependencies on local Java, Maven, or Tomcat, refer to the [documentation](README.md).
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ using versions we for example publish to https://databases.dhis2.org/

## Build process

This repository contains the source code for the server-side component of DHIS 2, which is developed in [Java](https://www.java.com/en/) and built with [Maven](https://maven.apache.org/).
This repository contains the source code for the server-side component of DHIS2, which is developed in [Java](https://www.java.com/en/) and built with [Maven](https://maven.apache.org/).

To build it you must first install the root `POM` file, navigate to the `dhis-web` directory and then build the web `POM` file.

See the [contributing](https://github.com/dhis2/dhis2-core/blob/master/CONTRIBUTING.md) page to learn how to run locally.
See the [contributing](./CONTRIBUTING.md) page to learn how to run locally.

### Docker image

Expand All @@ -115,7 +113,9 @@ It should now be available at `http://localhost:8080`.
To build using a custom tag run

```sh
mvn -DskipTests -Dmaven.test.skip=true -f dhis-2/dhis-web-server/pom.xml jib:dockerBuild -Djib.to.image=dhis2/core-dev:mytag
mvn clean package -DskipTests -Dmaven.test.skip=true --file dhis-2/pom.xml \
--projects dhis-web-server --also-make --activate-profiles jibDockerBuild \
-Djib.to.image=dhis2/core-dev:mytag
```

For more configuration options related to Jib or Docker go to the
Expand Down
3 changes: 1 addition & 2 deletions dhis-2/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
/dhis-web-portal/target/
/dhis-web-server/target/
/dhis-web-reporting/target/
/dhis-web-embedded-jetty/target/

# Datasource local storage ignored files
/.idea/dataSources/
Expand All @@ -54,4 +53,4 @@ http-client.private.env.json
.java-version

# VS Code
.vscode/
.vscode/
9 changes: 4 additions & 5 deletions dhis-2/build-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ BUILD_BRANCH=$(git --git-dir "$DIR/../.git" branch --show-current)
# There might be ways like using https://maven.apache.org/enforcer/enforcer-rules/requireActiveProfile.html
# to prevent that but they would require more work.
ARCH=$(mvn help:system | grep "os\.arch")
JIB_PROFILE=
JIB_PROFILE="jibDockerBuild"
if [[ "$ARCH" == *arm64* || "$ARCH" == *aarch64* ]]; then
JIB_PROFILE="-P jibBuildArmOnly"
JIB_PROFILE="$JIB_PROFILE,jibBuildArmOnly"
fi

echo "Building dhis2-core and Docker image..."

export MAVEN_OPTS="-Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25"
mvn clean install --threads 2C -DskipTests -Dmaven.test.skip=true -f "${DIR}/pom.xml" -pl -dhis-test-integration,-dhis-test-coverage,-dhis-web-server
mvn clean install -PjibDockerBuild -DactiveProfile=jibDockerBuild -DskipTests -Dmaven.test.skip=true -f "${DIR}/dhis-web-server/pom.xml" $JIB_PROFILE \
-Djib.container.labels=DHIS2_BUILD_REVISION="${BUILD_REVISION}",DHIS2_BUILD_BRANCH="${BUILD_BRANCH}"
mvn clean package --threads 2C -DskipTests -Dmaven.test.skip=true --file "${DIR}/pom.xml" --projects dhis-web-server --also-make \
--activate-profiles "$JIB_PROFILE" -Djib.container.labels=DHIS2_BUILD_REVISION="${BUILD_REVISION}",DHIS2_BUILD_BRANCH="${BUILD_BRANCH}"

if test -z "$D2CLUSTER"; then
echo "No cluster name specified, skipping deploy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private PersistenceReport commit(TrackerImportParams params, TrackerBundle track
@IndirectTransactional
public ImportReport importTracker(
TrackerImportParams params, TrackerObjects trackerObjects, JobProgress jobProgress) {
User user = trackerUserService.getUser(params.getUserId());
User user = trackerUserService.getCurrentUser();

jobProgress.startingStage("Running PreHeat");
TrackerBundle trackerBundle =
Expand Down
Loading

0 comments on commit 64d2ee0

Please sign in to comment.