Skip to content

Commit d980b43

Browse files
authored
Merge pull request #924 from github/alejndr0/autocheck
Updates test-ghe-host-check
2 parents 150f192 + b78590d commit d980b43

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
if: matrix.os != 'macos-latest'
2121
- name: Install Dependencies (macOS)
2222
run: |
23-
brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt
23+
brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt wget
2424
brew install moreutils gawk
2525
if: matrix.os == 'macos-latest'
2626
- name: Get Sources

test/test-ghe-host-check.sh

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,40 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions
5454
set -e
5555
# shellcheck disable=SC2046 # Word splitting is required to populate the variables
5656
read -r bu_version_major bu_version_minor _ <<<$(ghe_parse_version $BACKUP_UTILS_VERSION)
57-
57+
bu_major_minor="$bu_version_major.$bu_version_minor"
58+
releases=$(/usr/bin/curl -s https://github-enterprise.s3.amazonaws.com/release/latest.json)
59+
supported=$(echo $releases | jq -r 'select(."'${bu_major_minor}'")')
60+
# shellcheck disable=SC2207 # Command required as alternatives fail
61+
keys=($(echo $releases | jq -r 'keys[]'))
62+
63+
if [ -z "$supported" ]
64+
then
65+
#BACKUP_UTILS_VERSION WAS NOT FOUND IN LATEST.JSON, CHECK IF ITS GREATER THAN LAST VERSION
66+
if [ "$(version $bu_major_minor)" -ge "$(version ${keys[$((${#keys[@]} - 2 ))]})" ]; then
67+
GHE_TEST_REMOTE_VERSION="$bu_major_minor.0" ghe-host-check
68+
GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]} - 2 ))]}.0" ghe-host-check
69+
GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]} - 3 ))]}.0" ghe-host-check
70+
fi
71+
else
72+
#BACKUP_UTILS_VERSION WAS FOUND IN LATEST.JSON
73+
ix=0
74+
for i in "${keys[@]}";do
75+
if [ "$i" == "$bu_major_minor" ];then
76+
break
77+
fi
78+
ix=$(( $ix + 1 ))
79+
done
80+
GHE_TEST_REMOTE_VERSION="${keys[$ix]}.0" ghe-host-check
81+
GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 1 ))]}.0" ghe-host-check
82+
GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 2 ))]}.0" ghe-host-check
83+
84+
fi
5885
! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check
59-
# hardcode until https://github.com/github/backup-utils/issues/675 is resolved
60-
! GHE_TEST_REMOTE_VERSION=2.20.0 ghe-host-check
61-
! GHE_TEST_REMOTE_VERSION=2.21.0 ghe-host-check
62-
! GHE_TEST_REMOTE_VERSION=2.22.0 ghe-host-check
63-
! GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check
64-
! GHE_TEST_REMOTE_VERSION=3.1.0 ghe-host-check
65-
GHE_TEST_REMOTE_VERSION=3.2.0 ghe-host-check
66-
GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check
67-
GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check
6886
GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check
6987
GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999gm1 ghe-host-check
7088
! GHE_TEST_REMOTE_VERSION=3.9999.1521793591.performancetest ghe-host-check
7189
GHE_TEST_REMOTE_VERSION=$((bu_version_major+1)).0.0 ghe-host-check
90+
7291
)
7392
end_test
7493

0 commit comments

Comments
 (0)