swh:1:snp:505c374fd75bb208ae4e9a54e64bb310bc49295e
Raw File
Tip revision: 5b19bb8edabc9bae89b7df25fd74a32d7de590b6 authored by Felix Puscasu on 15 February 2024, 16:44:21 UTC
RISC-V: Smrnmi-ext: WPRI checks
Tip revision: 5b19bb8
test_release_version.sh
#!/bin/sh
set -eu

# test the version associated to a git tag. Here we use
# a random version and we check if it is correctly parsed
# The script tezos-version prints the
# same version displayed by octez-node --version

VERSION='10.94'
RANDOMTAG='testtesttest'
TESTBRANCH="$RANDOMTAG"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

test_version() {
  rm -f _build/default/src/lib_version/generated_git_info.ml
  res=$(dune exec octez-version || :)
  if [ "$res" != "$1" ]; then
    echo "Expected version '$1', got '$res' => FAIL"
    exit 1
  else
    echo "Tag '$2', expected version '$res' => PASS"
  fi
}

cleanup() {
  set +e
  git tag -d "$RANDOMTAG" > /dev/null 2>&1
  git tag -d "$VERSION" > /dev/null 2>&1
  git tag -d "v$VERSION" > /dev/null 2>&1
  git tag -d "v$VERSION"+rc1 > /dev/null 2>&1
  git tag -d "v$VERSION"-rc1 > /dev/null 2>&1
  git checkout "$CURRENT_BRANCH"
  git branch -D "$TESTBRANCH"
  set -e
}

trap cleanup EXIT INT

cleanup

git checkout -b "$TESTBRANCH"

git tag "$VERSION" -m "test"
test_version "$VERSION" "$VERSION"

git tag "v$VERSION" -m "test"
test_version "$VERSION" "v$VERSION"

git commit --allow-empty -m "test" > /dev/null 2>&1
test_version "$VERSION+dev" "$(git describe --tags)"

git tag "$RANDOMTAG" -m "test"
test_version "0.0+dev" "$RANDOMTAG"

git tag "v$VERSION+rc1" -m "test"
test_version "$VERSION+dev" "v$VERSION+rc1"

git tag "v$VERSION-rc1" -m "test"
test_version "$VERSION~rc1" "v$VERSION-rc1"

git commit --allow-empty -m "test" > /dev/null 2>&1
test_version "$VERSION~rc1+dev" "$(git describe --tags)"

git checkout -

cleanup
back to top