|
| 1 | +name: "Validate Apache Release" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_version: |
| 7 | + required: true |
| 8 | + default: '1.0.0' |
| 9 | + |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - 'release-*' |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - 'release-*' |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + env: |
| 21 | + SCRIPT_PATH: hugegraph-dist/scripts/ |
| 22 | + URL_PREFIX: https://dist.apache.org/repos/dist/dev/incubator/hugegraph/ |
| 23 | + USER: 'imbajin' |
| 24 | + # TODO: parse version from the running branch name & also adapt the input version |
| 25 | + RELEASE_VERSION: '' |
| 26 | + steps: |
| 27 | + - name: Checkout source |
| 28 | + uses: actions/checkout@v3 |
| 29 | + - name: Install JDK ${{ matrix.java_version }} |
| 30 | + uses: actions/setup-java@v3 |
| 31 | + with: |
| 32 | + java-version: ${{ matrix.java_version }} |
| 33 | + distribution: 'adopt' |
| 34 | + - name: Cache Maven packages |
| 35 | + uses: actions/cache@v3 |
| 36 | + with: |
| 37 | + path: ~/.m2 |
| 38 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 39 | + restore-keys: ${{ runner.os }}-m2 |
| 40 | + - name: Get Yarn path |
| 41 | + id: yarn-cache-dir-path |
| 42 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 43 | + - name: Cache Yarn packages |
| 44 | + uses: actions/cache@v3 |
| 45 | + # use id to check `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 46 | + id: yarn-cache |
| 47 | + with: |
| 48 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 49 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 50 | + restore-keys: | |
| 51 | + ${{ runner.os }}-yarn- |
| 52 | +
|
| 53 | + - name: 1. Download SVN Sources |
| 54 | + run: | |
| 55 | + rm -rf dist/${{ inputs.release_version }} |
| 56 | + svn co ${URL_PREFIX}/${{ inputs.release_version }} dist/${{ inputs.release_version }} |
| 57 | + cd dist/${{ inputs.release_version }} || exit |
| 58 | +
|
| 59 | + - name: 2. Check Environment & Import Public Keys |
| 60 | + run: | |
| 61 | + cd dist/${{ inputs.release_version }} |
| 62 | + shasum --version 1>/dev/null || exit |
| 63 | + gpg --version 1>/dev/null || exit |
| 64 | + |
| 65 | + wget https://downloads.apache.org/incubator/hugegraph/KEYS || exit |
| 66 | + echo "Import KEYS:" && gpg --import KEYS |
| 67 | + |
| 68 | + echo -e "5\ny\n" | gpg --batch --command-fd 0 --edit-key $USER trust |
| 69 | + |
| 70 | + echo "trust all pk" |
| 71 | + for key in $(gpg --no-tty --list-keys --with-colons | awk -F: '/^pub/ {print $5}'); |
| 72 | + do |
| 73 | + echo -e "5\ny\n" | gpg --batch --command-fd 0 --edit-key "$key" trust |
| 74 | + done |
| 75 | + |
| 76 | + - name: 3. Check SHA512 & GPG Signature |
| 77 | + run: | |
| 78 | + cd dist/${{ inputs.release_version }} |
| 79 | + for i in *.tar.gz; do |
| 80 | + echo "$i" |
| 81 | + shasum -a 512 --check "$i".sha512 || exit |
| 82 | + eval gpg "${GPG_OPT}" --verify "$i".asc "$i" || exit |
| 83 | + done |
| 84 | +
|
| 85 | + - name: 4. Validate Source Packages |
| 86 | + run: | |
| 87 | + cd dist/${{ inputs.release_version }} && ls -lh ./*.tar.gz |
| 88 | + for i in *src.tar.gz; do |
| 89 | + echo "$i" |
| 90 | + # 4.0 check the directory name include "incubating" |
| 91 | + if [[ ! "$i" =~ "incubating" ]]; then |
| 92 | + echo "The package name should include incubating" && exit 1 |
| 93 | + fi |
| 94 | + tar xzvf "$i" || exit |
| 95 | + cd "$(basename "$i" .tar.gz)" || exit |
| 96 | +
|
| 97 | + # 4.1 check the directory include "NOTICE" and "LICENSE" and "DISCLAIMER" file |
| 98 | + if [[ ! -f "LICENSE" ]]; then |
| 99 | + echo "The package should include LICENSE file" && exit 1 |
| 100 | + fi |
| 101 | + if [[ ! -f "NOTICE" ]]; then |
| 102 | + echo "The package should include NOTICE file" && exit 1 |
| 103 | + fi |
| 104 | + if [[ ! -f "DISCLAIMER" ]]; then |
| 105 | + echo "The package should include DISCLAIMER file" && exit 1 |
| 106 | + fi |
| 107 | +
|
| 108 | + # 4.2 ensure doesn't contains empty directory or file |
| 109 | + COUNT=$(find . -type d -empty | wc -l) |
| 110 | + if [[ $COUNT -ne 0 ]]; then |
| 111 | + find . -type d -empty |
| 112 | + echo "The package should not include empty directory, but get $COUNT" # TODO: && exit 1 |
| 113 | + fi |
| 114 | + |
| 115 | + # 4.3 ensure any file should less than 900kb & not include binary file |
| 116 | + COUNT=$(find . -type f -size +900k | wc -l) |
| 117 | + if [[ $COUNT -ne 0 ]]; then |
| 118 | + find . -type f -size +900k |
| 119 | + echo "The package should not include file larger than 900kb, but get $COUNT" |
| 120 | + fi |
| 121 | + COUNT=$(find . -type f | perl -lne 'print if -B' | wc -l) |
| 122 | + if [[ $COUNT -ne 0 ]]; then |
| 123 | + find . -type f | perl -lne 'print if -B' |
| 124 | + echo "The package should not include binary file, but get $COUNT" |
| 125 | + fi |
| 126 | + |
| 127 | + # 4.4 test compile the packages |
| 128 | + if [[ $JAVA_VERSION == 8 && "$i" =~ "computer" ]]; then |
| 129 | + cd .. && echo "skip computer module in java8" |
| 130 | + continue |
| 131 | + fi |
| 132 | + mvn package -DskipTests -ntp && ls -lh |
| 133 | + cd .. || exit |
| 134 | + done |
| 135 | +
|
| 136 | + - name: 5. Run Compiled Packages In Server |
| 137 | + run: | |
| 138 | + cd dist/${{ inputs.release_version }} && ls -lh |
| 139 | + cd ./*hugegraph-incubating*src/*hugegraph*${{ inputs.release_version }} || exit |
| 140 | + bin/init-store.sh && sleep 1 |
| 141 | + bin/start-hugegraph.sh && ls ../../ |
| 142 | + cd ../../ || exit |
| 143 | +
|
| 144 | + - name: 6. Run Compiled Packages In ToolChain (Loader & Tool & Hubble) |
| 145 | + run: | |
| 146 | + cd dist/${{ inputs.release_version }} |
| 147 | + cd ./*toolchain*src || exit |
| 148 | + ls -lh |
| 149 | + cd ./*toolchain*${{ inputs.release_version }} || exit |
| 150 | + ls -lh |
| 151 | +
|
| 152 | + # 6.1 load some data first |
| 153 | + echo "test loader" |
| 154 | + cd ./*loader*${{ inputs.release_version }} || exit |
| 155 | + bin/hugegraph-loader.sh -f ./example/file/struct.json -s ./example/file/schema.groovy \ |
| 156 | + -g hugegraph || exit |
| 157 | + cd .. || exit |
| 158 | +
|
| 159 | + # 6.2 try some gremlin query & api in tool |
| 160 | + echo "test tool" |
| 161 | + cd ./*tool*${{ inputs.release_version }} || exit |
| 162 | + bin/hugegraph gremlin-execute --script 'g.V().count()' || exit |
| 163 | + bin/hugegraph task-list || exit |
| 164 | + bin/hugegraph backup -t all --directory ./backup-test || exit |
| 165 | + cd .. || exit |
| 166 | + |
| 167 | + # 6.3 start hubble and connect to server |
| 168 | + echo "test hubble" |
| 169 | + cd ./*hubble*${{ inputs.release_version }} || exit |
| 170 | + cat conf/hugegraph-hubble.properties && bin/start-hubble.sh |
| 171 | + cd ../../../ || exit |
| 172 | + rm -rf ./*src* && ls -lh |
| 173 | +
|
| 174 | + - name: 7. Validate Binary Packages |
| 175 | + run: | |
| 176 | + cd dist/${{ inputs.release_version }} |
| 177 | + for i in *.tar.gz; do |
| 178 | + echo "$i" |
| 179 | + # 7.0 check the directory name include "incubating" |
| 180 | + if [[ ! "$i" =~ "incubating" ]]; then |
| 181 | + echo "The package name should include incubating" && exit 1 |
| 182 | + fi |
| 183 | + tar xzvf "$i" || exit |
| 184 | +
|
| 185 | + # 7.1 check root dir include "NOTICE"/"LICENSE"/"DISCLAIMER" files & "release-docs" dir |
| 186 | + cd "$(basename "$i" .tar.gz)" && ls -lh || exit |
| 187 | + if [[ ! -f "LICENSE" ]]; then |
| 188 | + echo "The package should include LICENSE file" && exit 1 |
| 189 | + fi |
| 190 | + if [[ ! -f "NOTICE" ]]; then |
| 191 | + echo "The package should include NOTICE file" && exit 1 |
| 192 | + fi |
| 193 | + if [[ ! -f "DISCLAIMER" ]]; then |
| 194 | + echo "The package should include DISCLAIMER file" && exit 1 |
| 195 | + fi |
| 196 | + if [[ ! -d "release-docs" ]]; then |
| 197 | + echo "The package should include release-docs dir" && exit 1 |
| 198 | + fi |
| 199 | + |
| 200 | + # 7.2 ensure doesn't contains empty directory or file |
| 201 | + COUNT=$(find . -type d -empty | wc -l) |
| 202 | + if [[ $COUNT -ne 0 ]]; then |
| 203 | + find . -type d -empty |
| 204 | + echo "The package shouldn't include empty directory, but get $COUNT" # TODO: && exit 1 |
| 205 | + fi |
| 206 | +
|
| 207 | + cd - || exit |
| 208 | + done |
| 209 | +
|
| 210 | + - name: 8. Validate Binary Packages(Start Server) |
| 211 | + run: | |
| 212 | + cd dist/${{ inputs.release_version }} |
| 213 | + cd ./*hugegraph-incubating*${{ inputs.release_version }} || exit |
| 214 | + bin/init-store.sh && sleep 1 |
| 215 | + # kill the HugeGraphServer process by jps |
| 216 | + jps | grep HugeGraphServer | awk '{print $1}' | xargs kill -9 |
| 217 | + bin/start-hugegraph.sh && ls ../ |
| 218 | + cd - || exit |
| 219 | +
|
| 220 | + - name: 9. Validate Binary Packages(Start ToolChain(Loader/Tool/Hubble)) |
| 221 | + run: | |
| 222 | + cd dist/${{ inputs.release_version }} |
| 223 | + cd ./*toolchain*${{ inputs.release_version }} || exit |
| 224 | + ls -lh |
| 225 | +
|
| 226 | + # 9.1 loader some data first |
| 227 | + echo "test loader" |
| 228 | + cd ./*loader*${{ inputs.release_version }} || exit |
| 229 | + bin/hugegraph-loader.sh -f ./example/file/struct.json -s ./example/file/schema.groovy \ |
| 230 | + -g hugegraph || exit |
| 231 | + cd - || exit |
| 232 | +
|
| 233 | + # 9.2 try some gremlin query & api in tool |
| 234 | + echo "test tool" |
| 235 | + cd ./*tool*${{ inputs.release_version }} || exit |
| 236 | + bin/hugegraph gremlin-execute --script 'g.V().count()' || exit |
| 237 | + bin/hugegraph task-list || exit |
| 238 | + bin/hugegraph backup -t all --directory ./backup-test || exit |
| 239 | + cd - || exit |
| 240 | +
|
| 241 | + # 9.3 start hubble and connect to server |
| 242 | + echo "test hubble" |
| 243 | + cd ./*hubble*${{ inputs.release_version }} || exit |
| 244 | + # TODO: add hubble doc & test it |
| 245 | + cat conf/hugegraph-hubble.properties |
| 246 | + bin/stop-hubble.sh && bin/start-hubble.sh |
| 247 | + cd - || exit |
| 248 | +
|
| 249 | + strategy: |
| 250 | + fail-fast: false |
| 251 | + matrix: |
| 252 | + java_version: [ '8','11' ] |
0 commit comments