You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2019/08/22 14:49:06 UTC

[sling-whiteboard] branch master updated: Updating to new structure recommended by robert

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


The following commit(s) were added to refs/heads/master by this push:
     new d5878be  Updating to new structure recommended by robert
     new 3505117  Merge branch 'master' of github.com:apache/sling-whiteboard
d5878be is described below

commit d5878be0bd2850053f05eb4224a678e595e5da68
Author: Dan Klco <dk...@apache.org>
AuthorDate: Thu Aug 22 10:48:47 2019 -0400

    Updating to new structure recommended by robert
---
 release-validator/Dockerfile                       |   7 +-
 .../checks-available/000-check-signatures          |  67 ++++++
 .../checks-available/001-check-ci-status           |  39 ++++
 release-validator/init.sh                          |  11 +-
 release-validator/run.sh                           | 224 +++------------------
 5 files changed, 146 insertions(+), 202 deletions(-)

diff --git a/release-validator/Dockerfile b/release-validator/Dockerfile
index 27582b9..72fc4af 100644
--- a/release-validator/Dockerfile
+++ b/release-validator/Dockerfile
@@ -5,10 +5,11 @@ WORKDIR /opt
 ADD init.sh .
 RUN /bin/bash init.sh
 
-EXPOSE 8080
-
 ADD run.sh .
 CMD  /bin/bash run.sh
 
+ADD checks-available /opt/checks-available
+ADD checks-enabled /opt/checks-enabled
+
 ENTRYPOINT ["/bin/bash","run.sh"]
-CMD ["0"]
\ No newline at end of file
+CMD ["0" "1"]
diff --git a/release-validator/checks-available/000-check-signatures b/release-validator/checks-available/000-check-signatures
new file mode 100755
index 0000000..4145b81
--- /dev/null
+++ b/release-validator/checks-available/000-check-signatures
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+echo "################################################################################"
+echo "                           LOAD GPG KEYS                                        "
+echo "################################################################################"
+
+curl https://people.apache.org/keys/group/sling.asc --output /tmp/sling.asc
+if [ "$?" != "0" ]; then
+  echo "Failed to download Sling GPG Keys"
+  exit 1;
+fi
+gpg --import /tmp/sling.asc
+if [ "$?" != "0" ]; then
+  echo "Failed to load Sling GPG Keys"
+  exit 1;
+fi
+
+echo "################################################################################"
+echo "                          CHECK SIGNATURES AND DIGESTS                          "
+echo "################################################################################"
+
+RESULT=0
+for i in `find "$RELEASE_FOLDER" -type f | grep -v '\.\(asc\|sha1\|md5\)$'`
+do
+  f=`echo $i | sed 's/\.asc$//'`
+  echo "$f"
+  if [ ! -f "$f.asc" ]; then
+    CHKSUM="----";
+  else
+    gpg --verify $f.asc 2>/dev/null
+    if [ "$?" = "0" ]; then
+      CHKSUM="GOOD";
+    else
+      CHKSUM="BAD!!!!!!!!";
+      RESULT=2
+    fi
+  fi
+  echo "gpg:  ${CHKSUM}"
+
+ for tp in md5 sha1
+ do
+   if [ ! -f "$f.$tp" ]
+   then
+     CHKSUM="----"
+   else
+     A="`cat $f.$tp 2>/dev/null`"
+     B="`openssl $tp < $f 2>/dev/null | sed 's/.*= *//' `"
+     if [ "$A" = "$B" ]; then
+       CHKSUM="GOOD (`cat $f.$tp`)";
+     else
+       CHKSUM="BAD!! : $A not equal to $B";
+       RESULT=3
+     fi
+   fi
+   echo "$tp : ${CHKSUM}"
+ done
+
+done
+
+if [ -z "${CHKSUM}" ]; then
+  echo "WARNING: no files found!";
+  RESULT=4
+fi
+
+echo "################################################################################"
+
+exit $RESULT
diff --git a/release-validator/checks-available/001-check-ci-status b/release-validator/checks-available/001-check-ci-status
new file mode 100755
index 0000000..4d2612a
--- /dev/null
+++ b/release-validator/checks-available/001-check-ci-status
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+
+pom_files=$(find $RELEASE_FOLDER -name '*.pom')
+
+failed=0
+unknown=0
+for pom_file in ${pom_files}; do
+    artifactId=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='artifactId']/text()" ${pom_file})
+    version=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" ${pom_file})
+    repo_name="${artifactId//\./-}"
+    if [[ $repo_name != sling-* ]]; then
+        repo_name="sling-${repo_name}"
+    fi
+    echo -n "Status for ${artifactId} ${version}: "
+    status=$(curl --silent -H 'Accept: application/vnd.github.v3+json' \
+        "https://api.github.com/repos/apache/${repo_name}/commits/${artifactId}-${version}/status" | \
+        jq --raw-output '.state')
+    echo $status
+    case $status in
+        "pending")
+            unknown=1
+            ;;
+        "failure")
+            failed=1
+            ;;
+    esac
+    echo "See https://github.com/apache/${repo_name}/commits/${artifactId}-${version} for details"
+done
+
+if [ $failed -eq 1 ]; then
+    exit 1
+fi
+
+if [ $unknown -eq 1 ]; then
+    exit 129
+fi
+
+exit 0
diff --git a/release-validator/init.sh b/release-validator/init.sh
index 48729a7..4c5d3ec 100644
--- a/release-validator/init.sh
+++ b/release-validator/init.sh
@@ -2,16 +2,18 @@
 
 echo "Installing dependencies..."
 yum install epel-release -y
-yum install -y wget openssl git jq which
+yum install -y wget openssl git xmllint jq
 
 echo "Installing Java..."
 yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
 
+yum clean all
+
 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 /tmp/mvn.tar.gz
 tar xzvf /tmp/mvn.tar.gz --strip-components=1 -C mvn
-ln -s /
+rm /tmp/mvn.tar.gz
 
 echo "Configuring Java Environment Variables..."
 echo export JAVA_HOME="/etc/alternatives/java_sdk_openjdk" >/etc/profile.d/javaenv.sh
@@ -21,7 +23,4 @@ echo "export PATH=$PATH:$JAVA_HOME:${M2_HOME}/bin" >> /etc/profile.d/javaenv.sh
 
 chmod 0755 /etc/profile.d/javaenv.sh
 
-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
+echo "Initialization completed successfully!"
diff --git a/release-validator/run.sh b/release-validator/run.sh
index 07fc737..5cf0399 100644
--- a/release-validator/run.sh
+++ b/release-validator/run.sh
@@ -7,7 +7,7 @@ prints() {
     COLOR="92m";
   elif [ "$2" == "error" ]; then
     COLOR="91m";
-  else 
+  else
     COLOR="0m";
   fi
   STARTCOLOR="\e[$COLOR";
@@ -15,181 +15,23 @@ prints() {
   printf "\n\n$STARTCOLOR%b$ENDCOLOR" "$1\n";
 }
 
-try() { 
+try() {
   "$@"
   local EXIT_CODE=$?
 
   if [[ $EXIT_CODE -ne 0 ]]; then
+    echo "Exit code: $EXIT_CODE"
     prints "Failed to execute command: $@" "error"
     exit 1
   fi
 }
 
-# Downloads the Sling PGP Keys and validates the release artifacts
-validate_signatures () {
-  prints "Validating signatures..." "info"
-
-  mkdir release
-  
-  echo "Loading PGP Keys..."
-  try curl https://people.apache.org/keys/group/sling.asc --output sling.asc
-  try gpg --import sling.asc
-
-  prints "Validating release signatures..." "info"
-  CHECK_RESULT=$(/bin/bash check_staged_release.sh $RELEASE_ID release)
-  printf "\n$CHECK_RESULT\n"
-  if [[ "$CHECK_RESULT" == *"BAD"* ]]; then
-    prints "Check(s) Failed!" "error"
-    exit 1
-  elif [[ "$CHECK_RESULT" = *"no files found"* ]]; then
-    prints "Staging repository ${RELEASE_ID} not found!" "error"
-    exit 1
-  else
-    prints "Release signatures validated successful!" "success"
-  fi
-}
-
-# Build the release artifacts using Apache Maven
-build_releases () {
-  for RELEASE_FOLDER in release/${RELEASE_ID}/org/apache/sling/*
-  do
-    if [[ -f $RELEASE_FOLDER ]]; then
-      continue
-    fi
-    prints "Running build for $RELEASE_FOLDER" "info"
-
-    echo "Resolving Maven Variables..."
-    MVN_PACKAGING=$($MVN_EXEC -q -Dexec.executable=echo  -Dexec.args='${project.packaging}' --non-recursive  exec:exec -f $RELEASE_FOLDER/**/*.pom)
-    MVN_VERSION=$($MVN_EXEC -q -Dexec.executable=echo  -Dexec.args='${project.version}' --non-recursive  exec:exec -f $RELEASE_FOLDER/**/*.pom)
-    MVN_ARTIFACT_ID=$($MVN_EXEC -q -Dexec.executable=echo  -Dexec.args='${project.artifactId}' --non-recursive  exec:exec -f $RELEASE_FOLDER/**/*.pom)
-    REPO=$($MVN_EXEC -q -Dexec.executable=echo  -Dexec.args='${project.scm.developerConnection}' --non-recursive  exec:exec -f $RELEASE_FOLDER/**/*.pom)
-    REPO=${REPO/scm:git:/}
-
-    if [[ $REPO != *.git ]]; then
-      prints "Skipping sub-module ${MVN_ARTIFACT_ID}..." "info"
-      continue
-    fi
-    printf "Resolved Variables:\n\tArtifact ID: $MVN_ARTIFACT_ID\n\tPackaging: $MVN_PACKAGING\n\tSCM Repository: $REPO\n\tVersion: $MVN_VERSION\n"
-
-    prints "Checking out code from $REPO..." "info"
-    try git clone "$REPO" "build/$MVN_ARTIFACT_ID"
-    cd build/$MVN_ARTIFACT_ID
-    try git checkout $MVN_ARTIFACT_ID-$MVN_VERSION
-
-    prints "Building $MVN_ARTIFACT_ID..." "info"
-    try $MVN_EXEC clean install
-
-    if [[ "$MVN_PACKAGING" == "bundle" ]]; then
-      echo "Found bundle artifact..."
-      HAS_BUNDLE=true
-    fi
-
-    cd /opt
-  done
-  prints "Build(s) Successful!" "success"
-}
-
-# Starts up Apache Sling using the Integration Testing project
-start_sling () {
-  echo "Downloading latest Sling Starter..."
-  try $MVN_EXEC -q -U dependency:copy -Dartifact=org.apache.sling:org.apache.sling.starter:LATEST -DoutputDirectory=run
-  
-  prints "Starting Sling Starter..." "info"
-  mkdir -p run/sling/logs
-  (
-    (
-      java -jar run/org.apache.sling.starter-*.jar -c run/sling &
-      echo $! > run/app.pid
-    ) >> run/sling/logs/stdout.log 2>&1
-  ) &
-  
-  echo "Waiting for Sling to fully start..."
-
-  STARTED=false
-  ATTEMPT=0
-  while [ $ATTEMPT -lt 10 ]; do
-    sleep 60
-    RESP=$(curl -s http://localhost:8080/starter/index.html)
-    if [[ "$RESP" == *"Do not remove this comment, used for Starter integration tests"* ]]; then
-      prints "Sling Starter started!" "success"
-      let STARTED=true
-      break
-    else
-      echo "Not yet started..."
-    fi
-    let ATTEMPT=ATTEMPT+1 
-  done
-  
-  if [[ $STARTED = false ]]; then
-    prints "Sling failed to start!" "error"
-    exit 1
-  fi
-}
-
-install_bundles () {
-  BUNDLE_SUCCESS=true
-  prints "Installing bundles..." "info"
-  for RELEASE_FOLDER in release/${RELEASE_ID}/org/apache/sling/*
-  do
-    if [[ -f $RELEASE_FOLDER ]]; then
-      continue
-    fi
-    echo "Checking release folder ${RELEASE_FOLDER}..."
-    
-    MVN_PACKAGING=$($MVN_EXEC -q -Dexec.executable=echo  -Dexec.args='${project.packaging}' --non-recursive  exec:exec -f $RELEASE_FOLDER/**/*.pom)
-    if [[ "$MVN_PACKAGING" = "bundle" ]]; then
-    
-      MVN_VERSION=$($MVN_EXEC -q -Dexec.executable=echo  -Dexec.args='${project.version}' --non-recursive  exec:exec -f $RELEASE_FOLDER/**/*.pom)
-      MVN_ARTIFACT_ID=$($MVN_EXEC -q -Dexec.executable=echo  -Dexec.args='${project.artifactId}' --non-recursive  exec:exec -f $RELEASE_FOLDER/**/*.pom)
-      REPO="sling-${MVN_ARTIFACT_ID//\./-}"
-      ARTIFACT="/opt/build/${MVN_ARTIFACT_ID}/target/${MVN_ARTIFACT_ID}-${MVN_VERSION}.jar"
-      
-      if [ ! -f "${ARTIFACT}" ]; then
-        prints "Skipping ${RELEASE_FOLDER} not find expected artifact: ${ARTIFACT}" "error"
-        continue
-      fi
-      
-      prints "Installing / starting bundle ${ARTIFACT}..." "info"
-      try curl -u admin:admin -F action=install -F bundlestart=true -F refreshPackages=true -F bundlestartlevel=20 -F bundlefile=@"${ARTIFACT}" http://127.0.0.1:8080/system/console/bundles
-      
-      STATE=""
-      ATTEMPT=0
-      while [ $ATTEMPT -lt 12 ]; do
-        sleep 10
-        BUNDLE_RESPONSE=$(curl -s -u admin:admin http://127.0.0.1:8080/system/console/bundles/$MVN_ARTIFACT_ID.json)
-        STATE=$(echo $BUNDLE_RESPONSE | jq -r '.data[0].state')
-        IMPORTS_IN_ERROR=$(echo $BUNDLE_RESPONSE | jq -r '.data[0].props[] | select(.key == "Imported Packages").value[] | select( contains("ERROR") )')
-        if [[ "$STATE" == "Active" ]]; then
-          prints "Bundle $MVN_ARTIFACT_ID started successfully!" "success"
-          break
-        else
-          echo "Bundle is currently in state $STATE, waiting to see if it starts..."
-        fi
-        let ATTEMPT=ATTEMPT+1
-      done
-      
-      if [[ "$STATE" != "Active" ]]; then
-        prints "Failed to start $MVN_ARTIFACT_ID, current state: $STATE" "error"
-        printf "Imports in error state:\n$IMPORTS_IN_ERROR\n\n"
-        BUNDLE_SUCCESS=false
-      fi
-    else
-      echo "Ignoring non-bundle ${RELEASE_FOLDER}..."
-    fi
-  done
-  
-  if [[ $BUNDLE_SUCCESS == true ]]; then
-    prints "All bundes in release #${RELEASE_ID} installed successfully!" "success"
-  else 
-    prints "Some bundles failed to start" "error"
-  fi
-}
-
 # Set variables
-MVN_EXEC=/opt/mvn/bin/mvn
+export CHECKS=${2:-000-check-signatures,001-check-ci-status}
+export MVN_EXEC=/opt/mvn/bin/mvn
 /etc/profile.d/javaenv.sh
-RELEASE_ID=$1
-HAS_BUNDLE=false
+export RELEASE_ID=$1
+export RELEASE_FOLDER=/opt/release
 
 # Set the Maven repo so that we can pull the other release artifacts in a multi-artifact release
 mkdir ~/.m2
@@ -216,31 +58,27 @@ EOF
 # Start of the release process
 prints "Starting Validation for Apache Sling Release #$RELEASE_ID" "info"
 
-validate_signatures
-
-build_releases
-
-if [ "$HAS_BUNDLE" = true ]; then
-  prints "Bundles found, starting Apache Sling Starter..." "info"
-  
-  start_sling
-  
-  install_bundles
-  
-  prints "Release #$RELEASE_ID verified successfully!" "success"
-  
-  if [ "$KEEP_RUNNING" == "true" ]
-  then
-  	echo "Leaving Sling Starter running for ${RUN_TIMEOUT:=10m} 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 ${RUN_TIMEOUT}
-  fi
-  
-else
-  echo "No bundles found in built artifacts..."
-  prints "Release #$RELEASE_ID verified successfully!" "success"
-fi
-
+mkdir ${RELEASE_FOLDER} 2>/dev/null
+
+# Download the release artifacts
+prints "Downloading release artifacts" "info"
+try wget -e "robots=off" --wait 1 -nv -r -np "--reject=html,index.html.tmp" \
+  "--follow-tags=" -P "$RELEASE_FOLDER" -nH "--cut-dirs=3" \
+  "https://repository.apache.org/content/repositories/orgapachesling-${RELEASE_ID}/org/apache/sling/"
+
+# Link the selected checks into the enabled folder
+for CHECK in $(echo $CHECKS | tr "," "\n")
+do
+  echo "Enabling check $CHECK"
+  try ln -s /opt/checks-available/$CHECK /opt/checks-enabled/$CHECK
+done
+
+# Execute the checks in checks-enabled
+for CHECK in /opt/checks-enabled/*
+do
+  prints "Executing $CHECK" "info"
+  try $CHECK
+  prints "Check $CHECK executed successfully!" "success"
+done
+
+prints "All checks successful!" "success"