diff --git a/.github/workflows/analyse-pr.yml b/.github/workflows/analyse-pr.yml index 1904681dcddc..be5b0cfd7c02 100644 --- a/.github/workflows/analyse-pr.yml +++ b/.github/workflows/analyse-pr.yml @@ -5,16 +5,7 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.DHIS2_BOT_SONARCLOUD_TOKEN }} on: - push: - branches: - - master - - "2.3[1-9]" - - "2.4[0-9]" - pull_request: - branches: - - master - - "2.3[1-9]" - - "2.4[0-9]" + workflow_dispatch: # Only manual trigger, no automatic triggers concurrency: group: ${{ github.workflow}}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml index 2b5160a7641c..ceff9d497a4a 100644 --- a/.github/workflows/check-formatting.yml +++ b/.github/workflows/check-formatting.yml @@ -3,7 +3,8 @@ env: # This is to make sure Maven don't timeout fetching dependencies. See: https://github.com/actions/virtual-environments/issues/1499 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=125 -on: [ pull_request ] +on: + workflow_dispatch: # Only manual trigger, no automatic triggers jobs: check-formatting: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4a773b03c8cf..74ed72de4bfd 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,9 +9,7 @@ env: 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=125 on: - pull_request: - branches: - - master + workflow_dispatch: # Only manual trigger, no automatic triggers schedule: - cron: "0 12 * * *" concurrency: diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 686e56efa7de..91853fd7b8cb 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -1,7 +1,7 @@ name: Dependabot auto-merge on: - pull_request: + workflow_dispatch: # Only manual trigger, no automatic triggers permissions: pull-requests: write diff --git a/.github/workflows/deploy-instance.yml b/.github/workflows/deploy-instance.yml index b98eee3d18fc..a6c292ebbbc9 100644 --- a/.github/workflows/deploy-instance.yml +++ b/.github/workflows/deploy-instance.yml @@ -1,8 +1,7 @@ name: Deploy instance on: - pull_request: - types: [opened, reopened, labeled, synchronize] + workflow_dispatch: # Only manual trigger, no automatic triggers # Cancel previous runs of the same workflow and PR number or branch/tag concurrency: diff --git a/.github/workflows/destroy-instance.yml b/.github/workflows/destroy-instance.yml index 8aed59617645..bae6d9f0433b 100644 --- a/.github/workflows/destroy-instance.yml +++ b/.github/workflows/destroy-instance.yml @@ -1,8 +1,7 @@ name: Destroy instance on: - pull_request: - types: [closed, unlabeled] + workflow_dispatch: # Only manual trigger, no automatic triggers # Cancel previous runs of the same workflow and PR number or branch/tag concurrency: diff --git a/.github/workflows/run-api-analytics-tests.yml b/.github/workflows/run-api-analytics-tests.yml index d6887243e769..3313075ac254 100644 --- a/.github/workflows/run-api-analytics-tests.yml +++ b/.github/workflows/run-api-analytics-tests.yml @@ -4,8 +4,7 @@ env: 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=125 on: - pull_request: - types: [opened, labeled, synchronize] + workflow_dispatch: # Only manual trigger, no automatic triggers schedule: - cron: "16 1 * * *" # Run at 01:16 AM concurrency: diff --git a/.github/workflows/run-api-tests.yml b/.github/workflows/run-api-tests.yml index c244585a27f2..0bcb848ef36b 100644 --- a/.github/workflows/run-api-tests.yml +++ b/.github/workflows/run-api-tests.yml @@ -4,10 +4,7 @@ env: 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 on: - push: - branches: - - master - pull_request: + workflow_dispatch: # Only manual trigger, no automatic triggers concurrency: group: ${{ github.workflow}}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4226b4bb46e0..99cc58bd7121 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -3,10 +3,7 @@ env: # This is to make sure Maven don't timeout fetching dependencies. See: https://github.com/actions/virtual-environments/issues/1499 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=125 on: - push: - branches: - - master - pull_request: + workflow_dispatch: # Only manual trigger, no automatic triggers concurrency: group: ${{ github.workflow}}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/update-instance-manager.yml b/.github/workflows/update-instance-manager.yml new file mode 100644 index 000000000000..90b4368ece08 --- /dev/null +++ b/.github/workflows/update-instance-manager.yml @@ -0,0 +1,42 @@ +name: Update instance manager + +on: + pull_request: +# For this to work, this workflow needs to be on master https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_run +# workflow_run: +# workflows: ["Check formatting"] +# types: +# - completed + +jobs: + update-instance-manager: + runs-on: ubuntu-latest + env: + GIT_COMMIT: ${{ github.sha }} # Declare GIT_COMMIT, to be used on the entire job + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + # Set up Maven + - name: Set up Maven + run: | + sudo apt-get install maven + echo "On branch: $GITHUB_HEAD_REF" + echo "Git commit: $GIT_COMMIT" + + # Run Maven build + - name: Build with Maven + run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --update-snapshots --file ./dhis-2/pom.xml -DskipTests + + #curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O + - name: Sync war + run: | + echo "Syncing WAR ..." + echo "Version: ${GITHUB_REF#refs/heads/}" + chmod +x ./dhis-2/gha-copy-war-s3.sh + ./dhis-2/gha-copy-war-s3.sh dev $GITHUB_HEAD_REF \ No newline at end of file diff --git a/dhis-2/gha-copy-war-s3.sh b/dhis-2/gha-copy-war-s3.sh new file mode 100644 index 000000000000..1747e18abb19 --- /dev/null +++ b/dhis-2/gha-copy-war-s3.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash + +# This script is used in the pipelines for all the supported dhis2-core branches, including +# master and 4 major versions before that and for all the build types - dev, canary, eos and stable. + +set -euo pipefail + +BUILD_DATE=$(date -I'date') + +IS_PATCH_VERSION=0 + +VERSIONS_JSON="https://releases.dhis2.org/v1/versions/stable.json" + +BUCKET="s3://releases.dhis2.org" + +S3_CMD="aws s3 cp --metadata git-commit=$GIT_COMMIT --no-progress" + +S3_DESTINATIONS=() + +RELEASE_TYPE="$1" + +if [[ -z "$1" ]]; then + echo "Error: Release type is required." + exit 1 +fi + +RELEASE_VERSION="$2" + +if [[ -z "$2" ]]; then + echo "Error: Release version is required." + exit 1 +fi + +MAJOR_VERSION=$(cut -d '.' -f 2 <<< "$RELEASE_VERSION") + +echo "Release version: $RELEASE_VERSION" +echo "Major version: $MAJOR_VERSION" +if [[ "$RELEASE_VERSION" == "master" || $MAJOR_VERSION -ge 42 ]]; then + WAR_LOCATION="${WORKSPACE}/dhis-2/dhis-web-server/target/dhis.war" +else + WAR_LOCATION="${WORKSPACE}/dhis-2/dhis-web/dhis-web-portal/target/dhis.war" +fi + +if [[ ! -f "$WAR_LOCATION" ]]; then + echo "Error: WAR file not found." + exit 1 +fi + +case $RELEASE_TYPE in + "canary") + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/$RELEASE_TYPE/dhis2-$RELEASE_TYPE-$RELEASE_VERSION.war") + + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/$RELEASE_TYPE/dhis2-$RELEASE_TYPE-$RELEASE_VERSION-$BUILD_DATE.war") + ;; + + "dev") + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/$RELEASE_TYPE/dhis2-$RELEASE_TYPE-$RELEASE_VERSION.war") + + if [[ "$RELEASE_VERSION" == "master" ]]; then + RELEASE_VERSION="dev" + fi + + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/dhis.war") + ;; + + "eos") + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/dhis2-stable-$RELEASE_VERSION-$RELEASE_TYPE.war") + ;; + + "stable") + if [[ "$RELEASE_VERSION" =~ ^patch\/.* ]]; then + IS_PATCH_VERSION=1 + RELEASE_VERSION=${RELEASE_VERSION#"patch/"} + fi + + SHORT_VERSION=$(cut -d '.' -f 1,2 <<< "$RELEASE_VERSION") + + PATCH_VERSION=$(cut -d '.' -f 3 <<< "$RELEASE_VERSION") + + # Add an extra destination in S3 for the new semantic version schema without leading "2." + IFS=. read -ra RELEASE_VERSION_SEGMENTS <<< "$RELEASE_VERSION" + + NEW_RELEASE_VERSION=$(cut -d '.' -f 2- <<< "$RELEASE_VERSION") + NEW_SHORT_VERSION=$(cut -d '.' -f 2 <<< "$RELEASE_VERSION") + + if [[ "$IS_PATCH_VERSION" -eq 1 ]]; then + RELEASE_VERSION+="-rc" + # for release candidates, also add a version with the git hash + S3_DESTINATIONS+=("$BUCKET/$SHORT_VERSION/dhis2-$RELEASE_TYPE-$RELEASE_VERSION-${GIT_COMMIT:0:7}.war") + fi + + S3_DESTINATIONS+=("$BUCKET/$SHORT_VERSION/dhis2-$RELEASE_TYPE-$RELEASE_VERSION.war") + S3_DESTINATIONS+=("$BUCKET/$SHORT_VERSION/$RELEASE_VERSION/dhis.war") + + LATEST_PATCH_VERSION=$( + curl -fsSL "$VERSIONS_JSON" | + jq -r --arg VERSION "$SHORT_VERSION" '.versions[] | select(.name == $VERSION ) | .latestPatchVersion' + ) + + if [[ "$IS_PATCH_VERSION" -eq 0 && -n "${LATEST_PATCH_VERSION-}" && "$PATCH_VERSION" -ge "$LATEST_PATCH_VERSION" ]]; then + S3_DESTINATIONS+=("$BUCKET/$SHORT_VERSION/dhis2-$RELEASE_TYPE-latest.war") + S3_DESTINATIONS+=("$BUCKET/$NEW_SHORT_VERSION/dhis2-$RELEASE_TYPE-latest.war") + fi + + + if [[ ${#RELEASE_VERSION_SEGMENTS[@]} -lt 4 ]]; then + NEW_RELEASE_VERSION+=".0" + fi + + if [[ "$IS_PATCH_VERSION" -eq 1 ]]; then + NEW_RELEASE_VERSION+="-rc" + # for release candidates, also add a version with the git hash + S3_DESTINATIONS+=("$BUCKET/$NEW_SHORT_VERSION/dhis2-$RELEASE_TYPE-$NEW_RELEASE_VERSION-${GIT_COMMIT:0:7}.war") + fi + + S3_DESTINATIONS+=("$BUCKET/$NEW_SHORT_VERSION/dhis2-$RELEASE_TYPE-$NEW_RELEASE_VERSION.war") + + ;; + + *) + echo "Error: Unknown Release type." + exit 1 + ;; +esac + +for destination in "${S3_DESTINATIONS[@]}" +do + #echo "$WAR_LOCATION" "$destination" + $S3_CMD "$WAR_LOCATION" "$destination" +done diff --git a/jenkinsfiles/dev b/jenkinsfiles/dev index f0edbc42c007..0c72f07a94d5 100644 --- a/jenkinsfiles/dev +++ b/jenkinsfiles/dev @@ -48,7 +48,7 @@ pipeline { } } - stage('Run api tests') { +/* stage('Run api tests') { environment { RP_UUID = credentials('report-portal-access-uuid') RP_ENABLE = 'true' @@ -100,15 +100,18 @@ pipeline { } } } - } + }*/ stage('Sync WAR') { steps { implementIoBuildStarted(buildName: "${STAGE_NAME}") echo 'Syncing WAR ...' - sh 'curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O' - sh 'chmod +x copy-war-s3.sh' - sh './copy-war-s3.sh dev ${GIT_BRANCH}' + //sh 'curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O' + //sh 'chmod +x copy-war-s3.sh' + //sh './copy-war-s3.sh dev ${GIT_BRANCH}' + + sh 'chmod +x ./dhis-2/gha-copy-war-s3.sh' + sh './dhis-2/gha-copy-war-s3.sh dev $GIT_BRANCH' } post { @@ -118,7 +121,7 @@ pipeline { } } - stage('Publish image') { +/* stage('Publish image') { environment { // THIS MUST be kept in sync with the jib.from.image in ../dhis-2/dhis-web-server/pom.xml BASE_IMAGE = "tomcat:10.1.30-jre17" @@ -197,7 +200,7 @@ pipeline { } } } - } + }*/ } post {