From a50cf28863b5c981b8b85af2a1a7452c66e54fed Mon Sep 17 00:00:00 2001 From: shubham_G <88794020+shubham17998@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:02:47 +0530 Subject: [PATCH 1/2] [DSD-5366] Updated push-trigger.yml Signed-off-by: shubham_G <88794020+shubham17998@users.noreply.github.com> --- .github/workflows/push-trigger.yml | 110 +++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml index 4c84f3433b9..0cfdbf0b1c1 100644 --- a/.github/workflows/push-trigger.yml +++ b/.github/workflows/push-trigger.yml @@ -89,3 +89,113 @@ jobs: OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} GPG_SECRET: ${{ secrets.GPG_SECRET }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + build-maven-apitest-auth: + uses: mosip/kattu/.github/workflows/maven-build.yml@master-java21 + with: + SERVICE_LOCATION: ./apitest + BUILD_ARTIFACT: apitest-auth + secrets: + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_SECRET: ${{ secrets.GPG_SECRET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + publish_to_nexus_apitest_auth: + if: "${{ !contains(github.ref, 'master') && github.event_name != 'pull_request' && github.event_name != 'release' && github.event_name != 'prerelease' && github.event_name != 'publish' }}" + needs: build-maven-apitest-auth + uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master-java21 + with: + SERVICE_LOCATION: ./apitest + secrets: + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} + OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_SECRET: ${{ secrets.GPG_SECRET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + build-apitest-auth-local: + needs: build-maven-apitest-auth + runs-on: ubuntu-latest + env: + NAMESPACE: ${{ secrets.dev_namespace_docker_hub }} + SERVICE_NAME: apitest-auth + SERVICE_LOCATION: apitest + BUILD_ARTIFACT: apitest-auth-local + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '21' + server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + - name: Setup the settings file for ossrh server + run: echo " ossrh ${{secrets.ossrh_user}} ${{secrets.ossrh_secret}} ossrh true gpg2 ${{secrets.gpg_secret}} allow-snapshots true snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true releases-repo https://oss.sonatype.org/service/local/staging/deploy/maven2 true false sonar . https://sonarcloud.io false " > $GITHUB_WORKSPACE/settings.xml + - name: Build Automationtests with Maven + run: | + cd ${{ env.SERVICE_LOCATION}} + mvn clean package -s $GITHUB_WORKSPACE/settings.xml + - name: Copy configuration files to target directory. + run: | + cp -r ${{ env.SERVICE_LOCATION}}/target/classes/config ${{ env.SERVICE_LOCATION}}/target/config + cp -r ${{ env.SERVICE_LOCATION}}/testNgXmlFiles ${{ env.SERVICE_LOCATION}}/target/testNgXmlFiles + - name: Ready the springboot artifacts + if: ${{ !contains(github.ref, 'master') || !contains(github.ref, 'main') }} + run: | + ## FIND JARS & COPY ONLY EXECUTABLE JARs STORED UNDER TARGET DIRECTORY + find ${{ env.SERVICE_LOCATION }} -path '*/target/*' -exec zip ${{ env.BUILD_ARTIFACT }}.zip {} + + - name: Upload the springboot jars + if: ${{ !contains(github.ref, 'master') || !contains(github.ref, 'main') }} + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_ARTIFACT }} + path: ${{ env.BUILD_ARTIFACT }}.zip + - uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,message,author,commit,workflow,job # selectable (default: repo,message) + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required + if: failure() # Pick up events even if the job fails or is canceled. + + build-dockers_apitest_auth: + needs: build-apitest-auth-local + strategy: + matrix: + include: + - SERVICE_LOCATION: 'apitest' + SERVICE_NAME: 'apitest-auth' + BUILD_ARTIFACT: 'apitest-auth-local' + ONLY_DOCKER: true + fail-fast: false + name: ${{ matrix.SERVICE_NAME }} + uses: mosip/kattu/.github/workflows/docker-build.yml@master-java21 + with: + SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }} + SERVICE_NAME: ${{ matrix.SERVICE_NAME }} + BUILD_ARTIFACT: ${{ matrix.BUILD_ARTIFACT }} + ONLY_DOCKER: ${{ matrix.ONLY_DOCKER }} + secrets: + DEV_NAMESPACE_DOCKER_HUB: ${{ secrets.DEV_NAMESPACE_DOCKER_HUB }} + ACTOR_DOCKER_HUB: ${{ secrets.ACTOR_DOCKER_HUB }} + RELEASE_DOCKER_HUB: ${{ secrets.RELEASE_DOCKER_HUB }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + sonar_analysis_apitest_auth: + needs: build-maven-apitest-auth + if: "${{ github.event_name != 'pull_request' }}" + uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21 + with: + SERVICE_LOCATION: ./apitest + secrets: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + ORG_KEY: ${{ secrets.ORG_KEY }} + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_SECRET: ${{ secrets.GPG_SECRET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} From b9dc29dc94a1040b0f47380f85360fa4f33b7b3f Mon Sep 17 00:00:00 2001 From: shubham_G <88794020+shubham17998@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:07:58 +0530 Subject: [PATCH 2/2] [DSD-5366] Updated Dockerfile Signed-off-by: shubham_G <88794020+shubham17998@users.noreply.github.com> --- apitest/Dockerfile | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/apitest/Dockerfile b/apitest/Dockerfile index 287c09bd25c..fdc056e090b 100644 --- a/apitest/Dockerfile +++ b/apitest/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM mosipdev/openjdk-21-jre:latest ARG SOURCE ARG COMMIT_HASH @@ -23,15 +23,6 @@ ARG container_user_gid=1001 ARG KUBECTL_VERSION=1.22.9 -# install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip jq \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \ -&& chmod +x kubectl \ -&& mv kubectl /usr/local/bin/ - # set working directory for the user WORKDIR /home/${container_user} @@ -41,14 +32,17 @@ ADD ./apitest/target/ $work_dir ADD entrypoint.sh $work_dir/entrypoint.sh -RUN chmod +x $work_dir/entrypoint.sh - -#ADD ./testNgXmlFiles/ $work_dir/testNgXmlFiles/ - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} /usr/local/openjdk-11/lib/security/cacerts - -RUN chmod 644 /usr/local/openjdk-11/lib/security/cacerts +# install packages and create user +RUN apt-get -y update \ +&& apt-get install -y unzip jq curl \ +&& groupadd -g ${container_user_gid} ${container_user_group} \ +&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} \ +&& curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \ +&& mkdir -p /home/${container_user} \ +&& chmod +x kubectl $work_dir/entrypoint.sh \ +&& mv kubectl /usr/local/bin/ \ +&& chown -R ${container_user}:${container_user} /home/${container_user} /etc/ssl/certs/java/cacerts \ +&& chmod 644 /etc/ssl/certs/java/cacerts # select container user for all tasks USER ${container_user_uid}:${container_user_gid}