ci(parse-git-ref): handle more than one tag on the same commit
also add shelltest in CI
This commit is contained in:
parent
308d7b872d
commit
8545cac33d
|
@ -20,6 +20,11 @@ runs:
|
||||||
run: |
|
run: |
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get update -qy && apt-get install -qy shellcheck
|
DEBIAN_FRONTEND=noninteractive apt-get update -qy && apt-get install -qy shellcheck
|
||||||
./scripts/shellcheck.sh
|
./scripts/shellcheck.sh
|
||||||
|
- name: Run shell tests
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get update -qy && apt-get install -qy shelltestrunner
|
||||||
|
scripts/shelltest/run_tests.sh
|
||||||
- name: Check workflow files
|
- name: Check workflow files
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -6,12 +6,14 @@ set -euo pipefail
|
||||||
|
|
||||||
is_latest() {
|
is_latest() {
|
||||||
ref_name=$(basename "$1")
|
ref_name=$(basename "$1")
|
||||||
latest_ref_name=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
# shellcheck disable=SC2046
|
||||||
if [[ "$ref_name" == "$latest_ref_name" ]]; then
|
for t in $(git tag --points-at $(git rev-list --tags --max-count=1)); do
|
||||||
echo true;
|
if [[ "$t" == "$ref_name" ]]; then
|
||||||
else
|
echo true;
|
||||||
echo false;
|
return;
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
echo false
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $1 =~ ^refs/tags/v[5-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
if [[ $1 =~ ^refs/tags/v[5-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
@ -45,7 +47,7 @@ elif [[ $1 =~ ^refs/tags/e[5-9]+\.[0-9]+\.[0-9]+-(alpha|beta|rc)\.[0-9]+$ ]]; th
|
||||||
RELEASE=true
|
RELEASE=true
|
||||||
LATEST=false
|
LATEST=false
|
||||||
elif [[ $1 =~ ^refs/tags/.+ ]]; then
|
elif [[ $1 =~ ^refs/tags/.+ ]]; then
|
||||||
echo "Unrecognized tag: $1"
|
echo "Unrecognized tag: $1" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ $1 =~ ^refs/heads/master$ ]]; then
|
elif [[ $1 =~ ^refs/heads/master$ ]]; then
|
||||||
PROFILE=emqx
|
PROFILE=emqx
|
||||||
|
@ -63,7 +65,7 @@ elif [[ $1 =~ ^refs/heads/ci/.* ]]; then
|
||||||
RELEASE=false
|
RELEASE=false
|
||||||
LATEST=false
|
LATEST=false
|
||||||
else
|
else
|
||||||
echo "Unrecognized git ref: $1"
|
echo "Unrecognized git ref: $1" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
git tag -d v5.1.99 >/dev/null
|
||||||
|
git tag -d e5.1.99 >/dev/null
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
git tag v5.1.99
|
||||||
|
git tag e5.1.99
|
|
@ -0,0 +1,94 @@
|
||||||
|
./parse-git-ref.sh refs/tags/v5.2.0-foobar.1
|
||||||
|
>>>2
|
||||||
|
Unrecognized tag: refs/tags/v5.2.0-foobar.1
|
||||||
|
>>>= 1
|
||||||
|
|
||||||
|
./parse-git-ref.sh v5.2.0
|
||||||
|
>>>2
|
||||||
|
Unrecognized git ref: v5.2.0
|
||||||
|
>>>= 1
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/v5.1.0
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx", "edition": "Opensource", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/v5.1.5.1
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx", "edition": "Opensource", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/v5.2.0-alpha.1
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx", "edition": "Opensource", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/v5.2.0-alpha-1
|
||||||
|
>>>2
|
||||||
|
Unrecognized tag: refs/tags/v5.2.0-alpha-1
|
||||||
|
>>>= 1
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/v5.2.0-beta.1
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx", "edition": "Opensource", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/v5.2.0-rc.1
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx", "edition": "Opensource", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/e5.1.0
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx-enterprise", "edition": "Enterprise", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/e5.1.5.1
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx-enterprise", "edition": "Enterprise", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/e5.2.0-alpha.1
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx-enterprise", "edition": "Enterprise", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/e5.2.0-beta.1
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx-enterprise", "edition": "Enterprise", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/e5.2.0-rc.1
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx-enterprise", "edition": "Enterprise", "release": true, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/e5.1.99
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx-enterprise", "edition": "Enterprise", "release": true, "latest": true}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/tags/v5.1.99
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx", "edition": "Opensource", "release": true, "latest": true}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/heads/master
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx", "edition": "Opensource", "release": false, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/heads/release-51
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx-enterprise", "edition": "Enterprise", "release": false, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/heads/ci/foobar
|
||||||
|
>>>
|
||||||
|
{"profile": "emqx", "edition": "Opensource", "release": false, "latest": false}
|
||||||
|
>>>= 0
|
||||||
|
|
||||||
|
./parse-git-ref.sh refs/heads/release-44
|
||||||
|
>>>2
|
||||||
|
Unrecognized git ref: refs/heads/release-44
|
||||||
|
>>>= 1
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cd -P -- "$(dirname -- "$0")/.."
|
||||||
|
|
||||||
|
exit_code=0
|
||||||
|
|
||||||
|
for test in shelltest/*.test; do
|
||||||
|
echo "Running $test"
|
||||||
|
/bin/sh "${test%.test}.setup"
|
||||||
|
shelltest -c --diff --all --precise -- "$test"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit_code=1
|
||||||
|
fi
|
||||||
|
/bin/sh "${test%.test}.cleanup"
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $exit_code
|
Loading…
Reference in New Issue