Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Validates that the local environment is ready to commence release process. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | |
| 8 | GERRIT_USER=${GERRIT_USER:-$USER} |
Brian O'Connor | 156c480 | 2016-03-02 15:50:38 -0800 | [diff] [blame] | 9 | WIKI_USER=${WIKI_USER:-$USER} |
Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 10 | |
| 11 | set -e |
| 12 | |
Thomas Vachuska | 6891884 | 2016-03-04 10:38:55 -0800 | [diff] [blame] | 13 | # Tests availability of the specified tools |
| 14 | function testTool { |
| 15 | trap "echo 'FAILED'" ERR |
| 16 | printf "Checking $1 availability... " |
| 17 | which -s $1 |
| 18 | echo "OK" |
| 19 | } |
| 20 | |
| 21 | # Tests availability of gerrit |
| 22 | function testGerritTool { |
| 23 | trap "echo 'FAILED'" ERR |
| 24 | printf "Checking gerrit... " |
| 25 | git review --version 2>/dev/null |
| 26 | echo "OK" |
| 27 | } |
| 28 | |
| 29 | # Tests availability of GPG or GPG2 |
| 30 | function testGpgTool { |
| 31 | trap "echo 'FAILED'" ERR |
| 32 | printf "Checking gpg or gpg2... " |
| 33 | which -s gpg || which -s gpg2 |
| 34 | echo "OK" |
| 35 | } |
| 36 | |
| 37 | # Tests Java version |
| 38 | function testJavaVersion { |
| 39 | trap "echo 'FAILED'" ERR |
| 40 | printf "Checking Java version... " |
| 41 | v=$(javac -version 2>&1 | grep 1.8.0_ | sed -e 's/.*1.8.0_\([0-9]*\).*/\1/g') |
Brian O'Connor | a317872 | 2016-03-10 15:44:27 -0800 | [diff] [blame] | 42 | test "$v" -ge 73 |
Thomas Vachuska | 6891884 | 2016-03-04 10:38:55 -0800 | [diff] [blame] | 43 | echo "OK" |
| 44 | } |
| 45 | |
| 46 | # Tests availability of the required tools |
| 47 | function testToolchain { |
| 48 | for tool in bash python git java javac mvn tar; do |
| 49 | testTool $tool; |
| 50 | done |
| 51 | testGerritTool |
| 52 | testGpgTool |
| 53 | testJavaVersion |
| 54 | } |
| 55 | |
| 56 | # Tests that the specified artifact dependency is not a snapshot version |
| 57 | function testArtifactDependency { |
| 58 | trap "echo 'FAILED'" ERR |
| 59 | printf "Checking $1 dependency... " |
| 60 | grep "<$1.version>.*</$1.version>" $ONOS_ROOT/pom.xml | grep -q SNAPSHOT && false |
| 61 | echo "OK" |
| 62 | } |
| 63 | |
| 64 | # Tests that the ONOS-base is not a snapshot version |
| 65 | function testOnosBase { |
| 66 | trap "echo 'FAILED'" ERR |
| 67 | printf "Checking onos-base dependency... " |
| 68 | grep -A1 "onos-base" $ONOS_ROOT/pom.xml | grep -q SNAPSHOT && false |
| 69 | echo "OK" |
| 70 | } |
| 71 | |
| 72 | # Tests that the root pom does not contain any snapshot dependencies |
| 73 | # on anxillary artifacts, e.g. openflowj, copycat |
| 74 | function testSnapshotDependencies { |
| 75 | testOnosBase |
| 76 | for artifact in onos-build-conf onos-maven-plugin openflowj atomix copycat; do |
| 77 | testArtifactDependency $artifact |
| 78 | done |
| 79 | } |
| 80 | |
Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 81 | # Test access to Gerrit (Administrator) |
| 82 | function testGerritAccess { |
| 83 | trap "echo 'FAILED'" ERR |
Brian O'Connor | 156c480 | 2016-03-02 15:50:38 -0800 | [diff] [blame] | 84 | printf "Checking Gerrit ONOS Release group access... " |
| 85 | ssh -p 29418 gerrit.onosproject.org gerrit ls-members "ONOS\ Release"\ |
| 86 | --recursive | grep -q $GERRIT_USER |
Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 87 | echo "OK" |
| 88 | } |
| 89 | |
| 90 | # Test access to wiki.onosproject.org |
| 91 | function testWikiAccess { |
| 92 | trap "echo 'FAILED'" ERR |
| 93 | printf "Checking Wiki access... " |
Brian O'Connor | 156c480 | 2016-03-02 15:50:38 -0800 | [diff] [blame] | 94 | ssh $WIKI_USER@wiki.onosproject.org "test -w /var/www/api/index.html" |
Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 95 | echo "OK" |
| 96 | } |
| 97 | |
| 98 | # Test access to EC2 |
| 99 | function testEC2Access { |
| 100 | aux=$(mktemp) |
| 101 | trap "cat $aux; rm -f $aux; echo 'FAILED'" ERR |
| 102 | printf "Checking EC2 access... " |
Ray Milkey | d6e2e44 | 2016-11-30 10:15:23 -0800 | [diff] [blame] | 103 | : "${AWS_ACCESS_KEY_ID:?AWS_ACCESS_KEY_ID must be set}" |
| 104 | : "${AWS_SECRET_ACCESS_KEY:?AWS_SECRET_ACCESS_KEY must be set}" |
| 105 | |
Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 106 | uploadToS3.py -v 1>$aux 2>&1 |
| 107 | rm -f $aux |
| 108 | echo "OK" |
| 109 | } |
| 110 | |
| 111 | # Sonatype account must be created & ~/.m2/settings.xml must be configured |
| 112 | # Test by "releasing" a fake project setup for that purpose to validate access. |
Brian O'Connor | d89bfd0 | 2016-11-22 15:39:49 -0800 | [diff] [blame] | 113 | function testSonatypeAccessMvn { |
Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 114 | aux=$(mktemp) |
| 115 | trap "cat $aux; rm -f $aux; echo 'FAILED'" ERR |
Brian O'Connor | d89bfd0 | 2016-11-22 15:39:49 -0800 | [diff] [blame] | 116 | printf "Checking Sonatype access via Maven... " |
Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 117 | pushd $ONOS_ROOT/tools/build/release-test >/dev/null |
| 118 | # TODO: Figure out how to supress the GPG note |
| 119 | mvn -Prelease clean deploy org.sonatype.plugins:nexus-staging-maven-plugin:drop \ |
| 120 | 1>$aux 2>&1 </dev/null |
| 121 | mvn clean >/dev/null |
| 122 | rm -f $aux |
| 123 | popd >/dev/null |
| 124 | echo "OK" |
| 125 | } |
| 126 | |
Brian O'Connor | d89bfd0 | 2016-11-22 15:39:49 -0800 | [diff] [blame] | 127 | function testSonatypeAccessRest { |
Ray Milkey | d6e2e44 | 2016-11-30 10:15:23 -0800 | [diff] [blame] | 128 | : "${SONATYPE_USER:?SONATYPE_USER must be set}" |
| 129 | : "${SONATYPE_PASSWORD:?SONATYPE_PASSWORD must be set}" |
Brian O'Connor | d89bfd0 | 2016-11-22 15:39:49 -0800 | [diff] [blame] | 130 | export ONOS_VERSION=1.2.3 |
| 131 | printf "Checking Sonatype access via REST... " |
| 132 | pushd $ONOS_ROOT/tools/build/release-test >/dev/null |
| 133 | #FIXME this won't work on Linux |
| 134 | md5 pom.xml > pom.xml.md5 |
| 135 | shasum pom.xml > pom.xml.sha1 |
| 136 | gpg --detach-sign --output pom.xml.asc pom.xml |
| 137 | # Upload the files to staging |
| 138 | curl -s -u$SONATYPE_USER:$SONATYPE_PASSWORD --upload-file pom.xml \ |
| 139 | https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-api/$ONOS_VERSION/onos-api-$ONOS_VERSION.pom |
| 140 | curl -s -u$SONATYPE_USER:$SONATYPE_PASSWORD --upload-file pom.xml.md5 \ |
| 141 | https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-api/$ONOS_VERSION/onos-api-$ONOS_VERSION.pom.md5 |
| 142 | curl -s -u$SONATYPE_USER:$SONATYPE_PASSWORD --upload-file pom.xml.sha1 \ |
| 143 | https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-api/$ONOS_VERSION/onos-api-$ONOS_VERSION.pom.sha1 |
| 144 | curl -s -u$SONATYPE_USER:$SONATYPE_PASSWORD --upload-file pom.xml.asc \ |
| 145 | https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-api/$ONOS_VERSION/onos-api-$ONOS_VERSION.pom.asc |
| 146 | rm pom.xml.md5 pom.xml.sha1 pom.xml.asc |
| 147 | onos-close-staging -d >/dev/null |
| 148 | popd >/dev/null |
| 149 | unset ONOS_VERSION |
| 150 | echo "OK" |
| 151 | } |
| 152 | |
Ray Milkey | 8e4acbf | 2016-11-21 17:30:59 -0800 | [diff] [blame] | 153 | # .buckconfig.local must exist and the sonatype credentials must be set up |
| 154 | function testBuckconfigLocal() { |
| 155 | printf "Checking local buck config..." |
| 156 | if [ ! -f $ONOS_ROOT/.buckconfig.local ]; then |
| 157 | echo ".buckconfig.local not found" |
| 158 | return 1 |
| 159 | fi |
| 160 | |
| 161 | trap "echo [publish] must be specified" ERR |
| 162 | grep -q "^\[publish\]" $ONOS_ROOT/.buckconfig.local |
| 163 | |
| 164 | trap "echo maven_url must be specified" ERR |
| 165 | grep -q "maven_url" $ONOS_ROOT/.buckconfig.local |
| 166 | |
| 167 | trap "echo maven_user must be specified" ERR |
| 168 | grep -q "maven_user" $ONOS_ROOT/.buckconfig.local |
| 169 | |
| 170 | trap "echo maven_password must be specified" ERR |
| 171 | grep -q "maven_password" $ONOS_ROOT/.buckconfig.local |
| 172 | |
| 173 | trap "echo pgp_keyring must be specified" ERR |
| 174 | grep -q "pgp_keyring" $ONOS_ROOT/.buckconfig.local |
| 175 | |
| 176 | echo "OK" |
| 177 | } |
| 178 | |
| 179 | testBuckconfigLocal |
Thomas Vachuska | 6891884 | 2016-03-04 10:38:55 -0800 | [diff] [blame] | 180 | testToolchain |
| 181 | testSnapshotDependencies |
Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 182 | testGerritAccess |
| 183 | testWikiAccess |
| 184 | testEC2Access |
Brian O'Connor | d89bfd0 | 2016-11-22 15:39:49 -0800 | [diff] [blame] | 185 | testSonatypeAccessMvn |
| 186 | testSonatypeAccessRest |
Thomas Vachuska | 4702a26 | 2016-03-02 15:31:52 -0800 | [diff] [blame] | 187 | |
| 188 | echo "Ready to commence release process!" |