This is an automated email from the ASF dual-hosted git repository. dklco pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit 2eaa177d6e26a6069fda02d6cf005966f78298e2 Author: Dan Klco <[email protected]> AuthorDate: Fri May 10 15:33:58 2019 -0400 Adding a docker configuration for validating and running builds --- release-validator/Dockerfile | 11 +++++ release-validator/init.sh | 14 ++++++ release-validator/run.sh | 108 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+) diff --git a/release-validator/Dockerfile b/release-validator/Dockerfile new file mode 100644 index 0000000..62a655d --- /dev/null +++ b/release-validator/Dockerfile @@ -0,0 +1,11 @@ +FROM store/oracle/serverjre:8 + +WORKDIR /opt + +ADD init.sh . +RUN /bin/bash init.sh + +EXPOSE 8080 + +ADD run.sh . +ENTRYPOINT /bin/bash run.sh \ No newline at end of file diff --git a/release-validator/init.sh b/release-validator/init.sh new file mode 100644 index 0000000..239e9d9 --- /dev/null +++ b/release-validator/init.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "Installing dependencies..." +yum install -y wget openssl git + +echo "Installing Apache Maven..." +mkdir mvn +curl ftp://ftp.osuosl.org/pub/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz --output mvn.tar.gz +tar xzvf mvn.tar.gz --strip-components=1 -C mvn + +echo "Downloading check script..." +curl 'https://gitbox.apache.org/repos/asf?p=sling-tooling-release.git;a=blob_plain;f=check_staged_release.sh;hb=HEAD' --output check_staged_release.sh + +echo "Initialization completed successfully!" \ No newline at end of file diff --git a/release-validator/run.sh b/release-validator/run.sh new file mode 100644 index 0000000..71bd8f5 --- /dev/null +++ b/release-validator/run.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +mkdir tmp + +echo "Loading PGP Keys..." +curl https://people.apache.org/keys/group/sling.asc --output sling.asc || exit 1 +gpg --import sling.asc || exit 1 + +echo "Validating release..." +/bin/bash check_staged_release.sh ${RELEASE_VERSION} tmp || exit 1 + +HAS_BUNDLE=false +for RELEASE_FOLDER in tmp/${RELEASE_VERSION}/org/apache/sling/* +do + echo "Running build for $RELEASE_FOLDER" + + echo "Resolving Maven Variables..." + MVN_PACKAGING=$(mvn/bin/mvn -q -Dexec.executable=echo -Dexec.args='${project.packaging}' --non-recursive exec:exec -f $RELEASE_FOLDER/**/*.pom) + MVN_VERSION=$(mvn/bin/mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec -f $RELEASE_FOLDER/**/*.pom) + MVN_ARTIFACT_ID=$(mvn/bin/mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' --non-recursive exec:exec -f $RELEASE_FOLDER/**/*.pom) + REPO="sling-${MVN_ARTIFACT_ID//\./-}" + + echo "Checking out code at ${MVN_VERSION}..." + git clone https://github.com/apache/$REPO.git || exit 1 + cd $REPO + git checkout $MVN_ARTIFACT_ID-$MVN_VERSION || exit 1 + + echo "Building project..." + ../mvn/bin/mvn clean install || exit 1 + + if [ "$MVN_PACKAGING" == "bundle" ] + then + HAS_BUNDLE=true + fi + + cd .. +done + + +if [ "$HAS_BUNDLE" = true ]; +then + echo "Installing bundle..." + + mkdir run + + echo "Downloading Sling Starter..." + mvn/bin/mvn -q dependency:get -DremoteRepositories=https://repository.apache.org/content/groups/snapshots -DgroupId=org.apache.sling -DartifactId=org.apache.sling.starter -Dversion=LATEST -Dtransitive=false + mvn/bin/mvn -q dependency:copy -Dartifact=org.apache.sling:org.apache.sling.starter:LATEST -DoutputDirectory=run + + echo "Starting Sling Starter..." + + mkdir -p sling/logs + ( + ( + java -server -Xmx1024m -XX:MaxPermSize=256M -Djava.awt.headless=true -jar run/*.jar -p 8080 & + echo $! > app.pid + ) >> sling/logs/stdout.log 2>&1 + ) & + + echo "Waiting for Sling to fully start..." + + while true; do + sleep 30 + RESP=$(curl -s http://localhost:8080/starter/index.html) + if [ "$RESP" == *"Do not remove this comment, used for Starter integration tests"* ] + then + echo "Sling Starter started!" + else + echo "Not yet started..." + break + fi + done + + echo "Installing bundles..." + for RELEASE_FOLDER in tmp/${RELEASE_VERSION}/org/apache/sling/* + do + + MVN_PACKAGING=$(mvn/bin/mvn -q -Dexec.executable=echo -Dexec.args='${project.packaging}' --non-recursive exec:exec -f $RELEASE_FOLDER/**/*.pom) + if [ "$MVN_PACKAGING" = "bundle" ] ; then + echo "Installing bundle ${RELEASE_FOLDER}..." + + MVN_VERSION=$(mvn/bin/mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec -f $RELEASE_FOLDER/**/*.pom) + MVN_ARTIFACT_ID=$(mvn/bin/mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' --non-recursive exec:exec -f $RELEASE_FOLDER/**/*.pom) + REPO="sling-${MVN_ARTIFACT_ID//\./-}" + + curl -u admin:admin -F action=install -F bundlestartlevel=20 -F bundlefile=@"$REPO/target/$MVN_ARTIFACT_ID-$MVN_VERSION.jar" http://127.0.0.1:8080/system/console/bundles || exit 1 + else + echo "Ignoring non-bundle ${RELEASE_FOLDER}..." + fi + done + + echo "Release ${RELEASE_VERSION} verified successfully!" + + if [ "$KEEP_RUNNING" == "true" ] + then + echo "Leaving Sling Starter running for 10 minutes for testing..." + + printf "Run the following command to see the URL to connect to the Sling Starter under the PORT parameter:\n" + printf "\tdocker ps | grep sling-check-release" + + sleep 10m + fi +else + + echo "Packaging is $MVN_PACKAGING, not bundle" + + echo "Release ${RELEASE_VERSION} verified successfully!" +fi \ No newline at end of file
