From 214fe8ae7c432d5a720eca4a0fb8e4fc6024d026 Mon Sep 17 00:00:00 2001 From: Siva Naik Date: Mon, 1 Apr 2024 12:07:45 +0530 Subject: [PATCH 1/3] Feat: added build pipeline, version upgrade --- .github/workflows/build.yaml | 61 ++++++++++++++++++++++++++++++ .github/workflows/docker-image.yml | 46 +++++++++++----------- 2 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..06f5b99 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,61 @@ +name: build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + compile: + runs-on: ubuntu-latest + name: Running Java ${{ matrix.java }} compile + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Compile code + run: mvn clean compile + build: + runs-on: ubuntu-latest + name: build + needs: compile + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Build with Maven + run: mvn clean -B package --file pom.xml -Dmaven.test.skip=true + test: + runs-on: ubuntu-latest + name: run tests + needs: compile + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Run unit tests + run: mvn clean test + coverage: + runs-on: ubuntu-latest + name: coverage + needs: compile + steps: + - name: coverage with maven + uses: actions/checkout@v2 + with: + java-version: 11 + - name: build and coverage + run: mvn clean -B verify --no-transfer-progress \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 6cea1a8..9fd3e44 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,4 +1,4 @@ -# This github workflow will automatically update docker image tags of gis-depl in the datakaveri/iudx-deployment repository files, whenever docker image is pushed to ghcr.io/datakaveri/gis-depl .Based on tag it will update the master/latest branch (if its 5.0.0-alpha-) or 4.5.0 stable branch (if its 4.5.0-) +# This github workflow will automatically update docker image tags of gis-depl in the datakaveri/iudx-deployment repository files, whenever docker image is pushed to ghcr.io/datakaveri/gis-depl .Based on tag it will update the master/latest branch (if its 5.5.1-alpha-) or 5.5.0 stable branch (if its 5.5.0-) name: Update GIS docker image tags # This trigger will run the workflow whenever a new package is published to the registry @@ -27,26 +27,26 @@ jobs: env: GH_TOKEN: ${{ secrets.JENKINS_UPDATE}} run: | - # Get the latest version of 4.5.0 and 5.0.0-alpha tags from the container registry using GitHub API - export newtag4_5_0=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 4.5.0 | sed -e 's/^"//' -e 's/"$//'))` - export newtag5_0_0=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.0.0-alpha | sed -e 's/^"//' -e 's/"$//'))` + # Get the latest version of 5.5.0 and 5.5.1-alpha tags from the container registry using GitHub API + export newtag5_5_0=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.5.0 | sed -e 's/^"//' -e 's/"$//'))` + export newtag5_5_1=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.5.1-alpha | sed -e 's/^"//' -e 's/"$//'))` # Get the old tags from the YAML files - export oldtag5_0_0=`yq -r .services.gis.image Docker-Swarm-deployment/single-node/gis/gis-stack.yaml | cut -d : -f 2` - git checkout 4.5.0 - export oldtag4_5_0=$(yq -r .services.gis.image Docker-Swarm-deployment/single-node/gis/gis-stack.yaml | cut -d : -f 2) + export oldtag5_5_1=`yq -r .services.gis.image Docker-Swarm-deployment/single-node/gis/gis-stack.yaml | cut -d : -f 2` + git checkout 5.5.0 + export oldtag5_5_0=$(yq -r .services.gis.image Docker-Swarm-deployment/single-node/gis/gis-stack.yaml | cut -d : -f 2) # Set Git user git config --global user.name 'jenkins-datakaveri' git config --global user.email "96175780+jenkins-datakaveri@users.noreply.github.com" # Update the YAML files and create a new branch for each tag update - if [ "$newtag4_5_0" != "$oldtag4_5_0" ] + if [ "$newtag5_5_0" != "$oldtag5_5_0" ] then - git checkout -b gis-4.5.0-automatic-updates/$newtag4_5_0 + git checkout -b gis-5.5.0-automatic-updates/$newtag5_5_0 - # Uses sed to find and replace $oldtag4_5_0 with $newtag4_5_0 in Docker-Swarm-deployment/single-node/gis/gis-stack.yaml file - sed -i s/$oldtag4_5_0/$newtag4_5_0/g Docker-Swarm-deployment/single-node/gis/gis-stack.yaml + # Uses sed to find and replace $oldtag5_5_0 with $newtag5_5_0 in Docker-Swarm-deployment/single-node/gis/gis-stack.yaml file + sed -i s/$oldtag5_5_0/$newtag5_5_0/g Docker-Swarm-deployment/single-node/gis/gis-stack.yaml # Exports the current version of the application from K8s-deployment/Charts/gis-interface/Chart.yaml file export oldappversion=`yq -r .version K8s-deployment/Charts/gis-interface/Chart.yaml` @@ -56,22 +56,22 @@ jobs: # Uses sed to find and replace $oldappversion with $newappversion in K8s-deployment/Charts/gis-interface/Chart.yaml and K8s-deployment/Charts/gis-interface/values.yaml files sed -i s/$oldappversion/$newappversion/g K8s-deployment/Charts/gis-interface/Chart.yaml - sed -i s/$oldtag4_5_0/$newtag4_5_0/g K8s-deployment/Charts/gis-interface/values.yaml + sed -i s/$oldtag5_5_0/$newtag5_5_0/g K8s-deployment/Charts/gis-interface/values.yaml git add Docker-Swarm-deployment/single-node/gis/gis-stack.yaml K8s-deployment/Charts/gis-interface/values.yaml K8s-deployment/Charts/gis-interface/Chart.yaml - git commit --allow-empty -m "updated GIS docker image tag to $newtag4_5_0" - git push --set-upstream origin gis-4.5.0-automatic-updates/$newtag4_5_0 + git commit --allow-empty -m "updated GIS docker image tag to $newtag5_5_0" + git push --set-upstream origin gis-5.5.0-automatic-updates/$newtag5_5_0 - # Creates a new pull request on the datakaveri/iudx-deployment repository with the base branch 4.5.0 - gh pr create -R datakaveri/iudx-deployment --base 4.5.0 --fill + # Creates a new pull request on the datakaveri/iudx-deployment repository with the base branch 5.5.0 + gh pr create -R datakaveri/iudx-deployment --base 5.5.0 --fill fi - if [ "$newtag5_0_0" != "$oldtag5_0_0" ] + if [ "$newtag5_5_1" != "$oldtag5_5_1" ] then git checkout master - git checkout -b gis-automatic-updates/$newtag5_0_0 + git checkout -b gis-automatic-updates/$newtag5_5_1 - # Uses sed to find and replace $oldtag5_0_0 with $newtag5_0_0 in Docker-Swarm-deployment/single-node/gis/gis-stack.yaml file - sed -i s/$oldtag5_0_0/$newtag5_0_0/g Docker-Swarm-deployment/single-node/gis/gis-stack.yaml + # Uses sed to find and replace $oldtag5_5_1 with $newtag5_5_1 in Docker-Swarm-deployment/single-node/gis/gis-stack.yaml file + sed -i s/$oldtag5_5_1/$newtag5_5_1/g Docker-Swarm-deployment/single-node/gis/gis-stack.yaml # Exports the current version of the application from K8s-deployment/Charts/gis-interface/Chart.yaml file export oldappversion=`yq -r .version K8s-deployment/Charts/gis-interface/Chart.yaml` @@ -79,10 +79,10 @@ jobs: # Uses sed to find and replace $oldappversion with $newappversion in K8s-deployment/Charts/gis-interface/Chart.yaml and K8s-deployment/Charts/gis-interface/values.yaml files export newappversion=`yq -r .version K8s-deployment/Charts/gis-interface/Chart.yaml | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}' ` sed -i s/$oldappversion/$newappversion/g K8s-deployment/Charts/gis-interface/Chart.yaml - sed -i s/$oldtag5_0_0/$newtag5_0_0/g K8s-deployment/Charts/gis-interface/values.yaml + sed -i s/$oldtag5_5_1/$newtag5_5_1/g K8s-deployment/Charts/gis-interface/values.yaml git add Docker-Swarm-deployment/single-node/gis/gis-stack.yaml K8s-deployment/Charts/gis-interface/values.yaml K8s-deployment/Charts/gis-interface/Chart.yaml - git commit --allow-empty -m "updated GIS docker image tag to $newtag5_0_0" - git push --set-upstream origin gis-automatic-updates/$newtag5_0_0 + git commit --allow-empty -m "updated GIS docker image tag to $newtag5_5_1" + git push --set-upstream origin gis-automatic-updates/$newtag5_5_1 # Creates a new pull request on the datakaveri/iudx-deployment repository with the base branch master gh pr create -R datakaveri/iudx-deployment --base master --fill fi From 6a19b581fbf1fbd37c997bbafc94d98b3a7ec668 Mon Sep 17 00:00:00 2001 From: Siva Naik <60335740+sivanaikk@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:02:15 +0530 Subject: [PATCH 2/3] Update .github/workflows/docker-image.yml Co-authored-by: karun-singh <66350877+karun-singh@users.noreply.github.com> --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 9fd3e44..015772e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -28,7 +28,7 @@ jobs: GH_TOKEN: ${{ secrets.JENKINS_UPDATE}} run: | # Get the latest version of 5.5.0 and 5.5.1-alpha tags from the container registry using GitHub API - export newtag5_5_0=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.5.0 | sed -e 's/^"//' -e 's/"$//'))` + export newtag5_5_0=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.5.0 | grep -v alpha | sed -e 's/^"//' -e 's/"$//'))` export newtag5_5_1=`(head -n 1 <(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/gis-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.5.1-alpha | sed -e 's/^"//' -e 's/"$//'))` # Get the old tags from the YAML files From 60899843c6a2f2b859be6369d8ab003d25854680 Mon Sep 17 00:00:00 2001 From: Siva Naik Date: Tue, 2 Apr 2024 14:53:31 +0530 Subject: [PATCH 3/3] removed: build file --- .github/workflows/build.yaml | 61 ------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 06f5b99..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,61 +0,0 @@ -name: build - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - compile: - runs-on: ubuntu-latest - name: Running Java ${{ matrix.java }} compile - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Cache - uses: actions/cache@v2 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Compile code - run: mvn clean compile - build: - runs-on: ubuntu-latest - name: build - needs: compile - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Build with Maven - run: mvn clean -B package --file pom.xml -Dmaven.test.skip=true - test: - runs-on: ubuntu-latest - name: run tests - needs: compile - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Run unit tests - run: mvn clean test - coverage: - runs-on: ubuntu-latest - name: coverage - needs: compile - steps: - - name: coverage with maven - uses: actions/checkout@v2 - with: - java-version: 11 - - name: build and coverage - run: mvn clean -B verify --no-transfer-progress \ No newline at end of file