From 9e83e74ac639c5bdb0ba3b9e885ca20aa71d4db3 Mon Sep 17 00:00:00 2001 From: Gilbert Kwan Date: Wed, 24 Jul 2024 14:09:51 -0400 Subject: [PATCH] enable daily build test (#78) * Create dailyBuild.sh * Create dockerImageTest.sh * Update dailyBuild.sh * Update testApp.sh * Update testApp.sh * Update testApp.sh * Update testApp.sh * Create triggerConversion.yml --- .github/workflows/triggerConversion.yml | 31 +++++++++++++++++++++++++ scripts/dailyBuild.sh | 24 +++++++++++++++++++ scripts/dockerImageTest.sh | 25 ++++++++++++++++++++ scripts/testApp.sh | 3 +++ 4 files changed, 83 insertions(+) create mode 100644 .github/workflows/triggerConversion.yml create mode 100644 scripts/dailyBuild.sh create mode 100644 scripts/dockerImageTest.sh diff --git a/.github/workflows/triggerConversion.yml b/.github/workflows/triggerConversion.yml new file mode 100644 index 0000000..ac44f45 --- /dev/null +++ b/.github/workflows/triggerConversion.yml @@ -0,0 +1,31 @@ +name: Rebuild cloud-hosted guide + +# Controls when the action will run. Triggers the workflow on push +# events but only for the master branch +on: + push: + branches: + - 'prod' + - 'staging' + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "post" + post: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + # Uses the secrets from the organisation for credentials + - uses: actions/checkout@v2 + + - name: Invoke workflow in another repo with inputs + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: GuideConverterV3 + repo: OpenLiberty/cloud-hosted-guides + token: ${{ secrets.GUIDECONVERSIONTOOL_PASSWORD }} + inputs: '{ "branch": "${{ github.ref }}", "guide_name": "${{ github.event.repository.name }}" }' + ref: "refs/heads/prod" diff --git a/scripts/dailyBuild.sh b/scripts/dailyBuild.sh new file mode 100644 index 0000000..76e00a0 --- /dev/null +++ b/scripts/dailyBuild.sh @@ -0,0 +1,24 @@ +#!/bin/bash +while getopts t:d:b:u: flag; +do + case "${flag}" in + t) DATE="${OPTARG}";; + d) DRIVER="${OPTARG}";; + b) BUILD="${OPTARG}";; + u) DOCKER_USERNAME="${OPTARG}";; + *) echo "Invalid option";; + esac +done + +echo "Testing daily build image" + +sed -i "\#liberty-maven-plugin#ahttps://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/nightly/$DATE/$DRIVER" system/pom.xml query/pom.xml +cat system/pom.xml query/pom.xml + +if [[ "$DOCKER_USERNAME" != "" ]]; then + sed -i "s;FROM icr.io/appcafe/open-liberty:kernel-slim-java11-openj9-ubi;FROM $DOCKER_USERNAME/olguides:$BUILD;g" system/Dockerfile query/Dockerfile + sed -i "s;RUN features.sh;#RUN features.sh;g" system/Dockerfile query/Dockerfile + cat system/Dockerfile query/Dockerfile +fi + +../scripts/testApp.sh diff --git a/scripts/dockerImageTest.sh b/scripts/dockerImageTest.sh new file mode 100644 index 0000000..e6ead2a --- /dev/null +++ b/scripts/dockerImageTest.sh @@ -0,0 +1,25 @@ +#!/bin/bash +while getopts t:d:b:u: flag; +do + case "${flag}" in + t) DATE="${OPTARG}";; + d) DRIVER="${OPTARG}";; + *) echo "Invalid option";; + esac +done + +echo "Testing daily Docker image" + +sed -i "\#liberty-maven-plugin#ahttps://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/nightly/$DATE/$DRIVER" system/pom.xml query/pom.xml +cat system/pom.xml query/pom.xml + +sed -i "s;FROM icr.io/appcafe/open-liberty:kernel-slim-java11-openj9-ubi;FROM cp.stg.icr.io/cp/olc/open-liberty-daily:full-java11-openj9-ubi;g" system/Dockerfile query/Dockerfile +sed -i "s;RUN features.sh;#RUN features.sh;g" system/Dockerfile query/Dockerfile +cat system/Dockerfile query/Dockerfile + +echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin cp.stg.icr.io +docker pull "cp.stg.icr.io/cp/olc/open-liberty-daily:full-java11-openj9-ubi" +echo "build level:" +docker inspect --format "{{ index .Config.Labels \"org.opencontainers.image.revision\"}}" cp.stg.icr.io/cp/olc/open-liberty-daily:full-java11-openj9-ubi + +../scripts/testApp.sh diff --git a/scripts/testApp.sh b/scripts/testApp.sh index e881e3d..947c441 100755 --- a/scripts/testApp.sh +++ b/scripts/testApp.sh @@ -61,6 +61,9 @@ docker run -d --network=$NETWORK --name query -p 9085:9085 query:1.0-SNAPSHOT sleep 30 +docker logs system | grep Launching +docker logs query | grep Launching + curl http://localhost:9085/query/systems/system queryStatus="$(curl --write-out "%{http_code}\n" --silent --output /dev/null "http://localhost:9085/query/systems/system")"