Skip to content

Commit

Permalink
Merge branch 'fix-parsing-of-build-tags-des-1318'
Browse files Browse the repository at this point in the history
  • Loading branch information
Serock3 committed Oct 22, 2024
2 parents 8a9c15f + 7d06c96 commit 6533665
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/desktop-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
- name: Run end-to-end tests
shell: bash -ieo pipefail {0}
run: |
git fetch --tags --force
git fetch --tags --prune-tags --force
export TEST_FILTERS="${{ github.event.inputs.tests }}"
./test/scripts/ci-runtests.sh ${{ matrix.os }}
- uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -234,7 +234,7 @@ jobs:
- name: Run end-to-end tests
shell: bash -ieo pipefail {0}
run: |
git fetch --tags --force
git fetch --tags --prune-tags --force
export TEST_FILTERS="${{ github.event.inputs.tests }}"
./test/scripts/ci-runtests.sh ${{ matrix.os }}
- uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -311,7 +311,7 @@ jobs:
- name: Run end-to-end tests
shell: bash -ieo pipefail {0}
run: |
git fetch --tags --force
git fetch --tags --prune-tags --force
export TEST_FILTERS="${{ github.event.inputs.tests }}"
./test/scripts/ci-runtests.sh ${{ matrix.os }}
- uses: actions/upload-artifact@v3
Expand Down
36 changes: 21 additions & 15 deletions test/scripts/test-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ commit=${commit:0:6}
TAG=$(git describe --exact-match HEAD 2>/dev/null || echo "")

if [[ -n "$TAG" && ${CURRENT_VERSION} =~ -dev- ]]; then
CURRENT_VERSION+="+${TAG}"
# Remove disallowed version characters from the tag
CURRENT_VERSION+="+${TAG//[^0-9a-z_-]/}"
fi

export CURRENT_VERSION
Expand Down Expand Up @@ -91,12 +92,23 @@ function nice_time {
echo "\"$*\" completed in $((s/60))m:$((s%60))s"
return $result
}
# Matches $1 with a build version string and sets the following exported variables:
# - BUILD_VERSION: The version part of the build string (e.g., "2024.3-beta1-dev-").
# - COMMIT_HASH: The commit hash part of the build string (e.g., "abcdef").
# - TAG: The tag part of the build string (e.g., "+tag").
function parse_build_version {
if [[ "$1" =~ (^[0-9.]+(-beta[0-9]+)?-dev-)([0-9a-z]+)(\+[0-9a-z|-]+)?$ ]]; then
BUILD_VERSION="${BASH_REMATCH[1]}"
COMMIT_HASH="${BASH_REMATCH[3]}"
TAG="${BASH_REMATCH[4]}"
return 0
fi
return 1
}

# Returns 0 if $1 is a development build. `BASH_REMATCH` contains match groups
# if that is the case.
# Returns 0 if $1 is a development build.
function is_dev_version {
local pattern="(^[0-9.]+(-beta[0-9]+)?-dev-)([0-9a-z]+)(\+[0-9a-z|-]+)?$"
if [[ "$1" =~ $pattern ]]; then
if [[ "$1" == *"-dev-"* ]]; then
return 0
fi
return 1
Expand All @@ -106,13 +118,8 @@ function get_app_filename {
local version=$1
local os=$2
if is_dev_version "$version"; then
# only save 6 chars of the hash
local commit="${BASH_REMATCH[3]}"
version="${BASH_REMATCH[1]}${commit}"
# If the dev-version includes a tag, we need to append it to the app filename
if [[ -n ${BASH_REMATCH[4]} ]]; then
version="${version}${BASH_REMATCH[4]}"
fi
parse_build_version "$version"
version="${BUILD_VERSION}${COMMIT_HASH}${TAG:-}"
fi
case $os in
debian*|ubuntu*)
Expand Down Expand Up @@ -166,9 +173,8 @@ function get_e2e_filename {
local version=$1
local os=$2
if is_dev_version "$version"; then
# only save 6 chars of the hash
local commit="${BASH_REMATCH[3]}"
version="${BASH_REMATCH[1]}${commit}"
parse_build_version "$version"
version="${BUILD_VERSION}${COMMIT_HASH}"
fi
case $os in
debian*|ubuntu*|fedora*)
Expand Down

0 comments on commit 6533665

Please sign in to comment.