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/09/06 15:57:17 UTC

[sling-org-apache-sling-committer-cli] branch bash-validate created (now b5e6dd2)

This is an automated email from the ASF dual-hosted git repository.

dklco pushed a change to branch bash-validate
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git.


      at b5e6dd2  Adding the check-release and support for non-Java actions

This branch includes the following new commits:

     new b5e6dd2  Adding the check-release and support for non-Java actions

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-org-apache-sling-committer-cli] 01/01: Adding the check-release and support for non-Java actions

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch bash-validate
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git

commit b5e6dd21c8b7ad7731cd562f1572ae221a9661fa
Author: Dan Klco <dk...@apache.org>
AuthorDate: Fri Sep 6 11:57:02 2019 -0400

    Adding the check-release and support for non-Java actions
---
 Dockerfile                                         |  5 +-
 docker-env.sample                                  | 17 -----
 .../resources/scripts/actions/check-release.sh     | 87 ++++++++++++++++++++++
 .../actions/check-release/000-check-signatures.sh  | 78 +++++++++++++++++++
 .../actions/check-release/001-check-ci-status.sh   | 55 ++++++++++++++
 .../scripts/{launcher.sh => actions/default.sh}    |  0
 src/main/resources/scripts/launcher.sh             | 30 ++------
 7 files changed, 232 insertions(+), 40 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 48d4d4e..47057c8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -19,6 +19,7 @@ COPY --from=builder /opt/jre /opt/jre
 
 # Generate class data sharing
 RUN /opt/jre/bin/java -Xshare:dump
+RUN apk add --no-cache wget openssl git libxml2-utils jq curl gnupg
 
 # escaping required to properly handle arguments with spaces
 ENTRYPOINT ["/usr/share/sling-cli/bin/launcher.sh"]
@@ -28,7 +29,9 @@ ADD target/lib /usr/share/sling-cli/launcher
 # Add launcher script
 ADD target/classes/scripts /usr/share/sling-cli/bin
 # workaround for MRESOURCES-236
-RUN chmod a+x /usr/share/sling-cli/bin/*
+RUN chmod a+x /usr/share/sling-cli/bin/* \
+    /usr/share/sling-cli/bin/actions/* \
+    /usr/share/sling-cli/bin/actions/check-release/*
 # Add config files
 ADD target/classes/conf /usr/share/sling-cli/conf
 # Add all bundles
diff --git a/docker-env.sample b/docker-env.sample
deleted file mode 100644
index 12e39be..0000000
--- a/docker-env.sample
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one or more contributor license
-# agreements. See the NOTICE file distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file to you under the Apache License,
-# Version 2.0 (the "License"); you may not use this file except in compliance with the
-# License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software distributed under the
-# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific language governing permissions
-# and limitations under the License.
-# ----------------------------------------------------------------------------------------
-ASF_USERNAME=changeme
-ASF_PASSWORD=changeme
-
-JIRA_USERNAME=changeme
-JIRA_PASSWORD=changeme
\ No newline at end of file
diff --git a/src/main/resources/scripts/actions/check-release.sh b/src/main/resources/scripts/actions/check-release.sh
new file mode 100755
index 0000000..3d3a9ba
--- /dev/null
+++ b/src/main/resources/scripts/actions/check-release.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+# agreements. See the NOTICE file distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file to you under the Apache License,
+# Version 2.0 (the "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software distributed under the
+# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific language governing permissions
+# and limitations under the License.
+# ----------------------------------------------------------------------------------------
+
+prints() {
+  if [ "$2" == "info" ]; then
+    COLOR="96m";
+  elif [ "$2" == "success" ]; then
+    COLOR="92m";
+  elif [ "$2" == "error" ]; then
+    COLOR="91m";
+  else
+    COLOR="0m";
+  fi
+  STARTCOLOR="\e[$COLOR";
+  ENDCOLOR="\e[0m";
+  printf "\n\n$STARTCOLOR%b$ENDCOLOR" "$1\n";
+}
+
+try() {
+  "$@"
+  local EXIT_CODE=$?
+
+  if [[ $EXIT_CODE -ne 0 ]]; then
+    echo "Exit code: $EXIT_CODE"
+    prints "Failed to execute command: $@" "error"
+    exit 1
+  fi
+}
+
+# Set variables
+export CHECKS=${2:-000-check-signatures,001-check-ci-status}
+export RELEASE_ID=$1
+export RELEASE_FOLDER="/tmp/release"
+export BASE="/usr/share/sling-cli/bin/actions/check-release"
+
+# Set the Maven repo so that we can pull the other release artifacts in a multi-artifact release
+mkdir ~/.m2
+cat > ~/.m2/settings.xml <<EOF
+<settings>
+ <profiles>
+   <profile>
+     <id>staging</id>
+     <repositories>
+       <repository>
+         <id>staging-repo</id>
+         <name>your custom repo</name>
+         <url>https://repository.apache.org/content/repositories/orgapachesling-$RELEASE_ID</url>
+       </repository>
+     </repositories>
+   </profile>
+ </profiles>
+ <activeProfiles>
+   <activeProfile>staging</activeProfile>
+  </activeProfiles>
+</settings>
+EOF
+
+# Start of the release process
+prints "Starting Validation for Apache Sling Release #$RELEASE_ID" "info"
+
+mkdir ${RELEASE_FOLDER} 2>/dev/null
+
+# Download the release artifacts
+prints "Downloading release artifacts" "info"
+try wget -e "robots=off" -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/"
+
+# Execute the checks
+for CHECK in $(echo $CHECKS | tr "," "\n")
+do
+  prints "Executing $CHECK" "info"
+  try $BASE/$CHECK.sh
+  prints "Check $CHECK executed successfully!" "success"
+done
+
+prints "All checks successful!" "success"
diff --git a/src/main/resources/scripts/actions/check-release/000-check-signatures.sh b/src/main/resources/scripts/actions/check-release/000-check-signatures.sh
new file mode 100644
index 0000000..37ed447
--- /dev/null
+++ b/src/main/resources/scripts/actions/check-release/000-check-signatures.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+# agreements. See the NOTICE file distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file to you under the Apache License,
+# Version 2.0 (the "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software distributed under the
+# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific language governing permissions
+# and limitations under the License.
+# ----------------------------------------------------------------------------------------
+
+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/src/main/resources/scripts/actions/check-release/001-check-ci-status.sh b/src/main/resources/scripts/actions/check-release/001-check-ci-status.sh
new file mode 100644
index 0000000..0d48a42
--- /dev/null
+++ b/src/main/resources/scripts/actions/check-release/001-check-ci-status.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+# agreements. See the NOTICE file distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file to you under the Apache License,
+# Version 2.0 (the "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software distributed under the
+# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the specific language governing permissions
+# and limitations under the License.
+# ----------------------------------------------------------------------------------------
+
+pom_files=$(find $RELEASE_FOLDER -name '*.pom')
+
+failed=0
+unknown=0
+
+echo ""
+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: ${artifactId} ${version}: "
+  resp=$(curl --silent -H 'Accept: application/vnd.github.v3+json' \
+      "https://api.github.com/repos/apache/${repo_name}/commits/${artifactId}-${version}/status")
+  status=$(echo $resp | jq --raw-output '.state')
+  echo $status
+  case $status in
+    "pending")
+      unknown=1
+      ;;
+    "failure")
+      failed=1
+      ;;
+  esac
+  if [[ $status != "success" ]]; then
+    echo "See https://github.com/apache/${repo_name}/commits/${artifactId}-${version} for details"
+    echo $resp | jq -r '.statuses[] | "Additional Information: \"" + .description + "\" See: " + .target_url'
+  fi
+  echo ""
+done
+
+if [ $failed -eq 1 ]; then
+  exit 1
+fi
+
+if [ $unknown -eq 1 ]; then
+  exit 129
+fi
+
+exit 0
diff --git a/src/main/resources/scripts/launcher.sh b/src/main/resources/scripts/actions/default.sh
similarity index 100%
copy from src/main/resources/scripts/launcher.sh
copy to src/main/resources/scripts/actions/default.sh
diff --git a/src/main/resources/scripts/launcher.sh b/src/main/resources/scripts/launcher.sh
index e5094b5..f4ca55e 100755
--- a/src/main/resources/scripts/launcher.sh
+++ b/src/main/resources/scripts/launcher.sh
@@ -11,26 +11,12 @@
 # and limitations under the License.
 # ----------------------------------------------------------------------------------------
 
-# TODO - contribute '-q' flag to launcher OR allow passthrough of org.slf4j.simpleLogger system properties
+BASE="/usr/share/sling-cli/bin/actions"
 
-
-# funky syntax needed to properly preserve arguments with whitespace
-ARGS_PROP="exec.args=$@"
-
-# Use exec to become pid 1, see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
-exec /opt/jre/bin/java \
-    --add-opens=java.base/java.lang=ALL-UNNAMED \
-    --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED \
-    --add-opens=java.base/java.net=ALL-UNNAMED \
-    --add-opens=java.base/java.security=ALL-UNNAMED \
-    -Xshare:on \
-    -Dorg.slf4j.simpleLogger.logFile=/dev/null \
-    -Dlogback.configurationFile=file:/usr/share/sling-cli/conf/logback-default.xml \
-    -jar /usr/share/sling-cli/launcher/org.apache.sling.feature.launcher.jar \
-    -f /usr/share/sling-cli/sling-cli.feature \
-    -c /usr/share/sling-cli/artifacts \
-    -D "$ARGS_PROP" \
-    -V "asf.username=${ASF_USERNAME}" \
-    -V "asf.password=${ASF_PASSWORD}" \
-    -V "jira.username=${JIRA_USERNAME}" \
-    -V "jira.password=${JIRA_PASSWORD}"
\ No newline at end of file
+echo $@
+if test -f "$BASE/$1.sh"; then
+    echo "Invoking Action $1..."
+    $BASE/$1.sh ${@:14}
+else 
+    $BASE/default.sh $@
+fi
\ No newline at end of file