From a76f7421070cc2cdaab33815ad16130497bef751 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Tue, 6 Dec 2022 12:44:43 -0500 Subject: [PATCH] e2e: add script to generate multiversion-tests --- .github/workflows/e2e-manual.yml | 2 +- .github/workflows/e2e-nightly-34x.yml | 2 +- .github/workflows/e2e-nightly-37x.yml | 2 +- .github/workflows/e2e-nightly-main.yml | 2 +- test/e2e/generate-multiversion.sh | 26 ++++++++++++++++++++++++++ 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100755 test/e2e/generate-multiversion.sh diff --git a/.github/workflows/e2e-manual.yml b/.github/workflows/e2e-manual.yml index c0eade4bd..bec0c73dc 100644 --- a/.github/workflows/e2e-manual.yml +++ b/.github/workflows/e2e-manual.yml @@ -29,7 +29,7 @@ jobs: - name: Generate testnets working-directory: test/e2e # When changing -g, also change the matrix groups above - run: ./build/generator -g 5 -d networks/nightly/ + run: ./generate-multiversion.sh -g 5 -d networks/nightly/ - name: Run ${{ matrix.p2p }} p2p testnets working-directory: test/e2e diff --git a/.github/workflows/e2e-nightly-34x.yml b/.github/workflows/e2e-nightly-34x.yml index 8d89a20da..b618e9bcc 100644 --- a/.github/workflows/e2e-nightly-34x.yml +++ b/.github/workflows/e2e-nightly-34x.yml @@ -40,7 +40,7 @@ jobs: - name: Generate testnets working-directory: test/e2e # When changing -g, also change the matrix groups above - run: ./build/generator -g 2 -d networks/nightly + run: ./generate-multiversion.sh -g 2 -d networks/nightly - name: Run testnets in group ${{ matrix.group }} working-directory: test/e2e diff --git a/.github/workflows/e2e-nightly-37x.yml b/.github/workflows/e2e-nightly-37x.yml index ebcc4a3fb..fc2d36ff8 100644 --- a/.github/workflows/e2e-nightly-37x.yml +++ b/.github/workflows/e2e-nightly-37x.yml @@ -40,7 +40,7 @@ jobs: - name: Generate testnets working-directory: test/e2e # When changing -g, also change the matrix groups above - run: ./build/generator -g 5 -d networks/nightly/ + run: ./generate-multiversion.sh -g 5 -d networks/nightly/ - name: Run ${{ matrix.p2p }} p2p testnets working-directory: test/e2e diff --git a/.github/workflows/e2e-nightly-main.yml b/.github/workflows/e2e-nightly-main.yml index 7f734367d..850dda672 100644 --- a/.github/workflows/e2e-nightly-main.yml +++ b/.github/workflows/e2e-nightly-main.yml @@ -34,7 +34,7 @@ jobs: - name: Generate testnets working-directory: test/e2e # When changing -g, also change the matrix groups above - run: ./build/generator -g 5 -d networks/nightly/ + run: ./generate-multiversion.sh -g 5 -d networks/nightly/ - name: Run ${{ matrix.p2p }} p2p testnets working-directory: test/e2e diff --git a/test/e2e/generate-multiversion.sh b/test/e2e/generate-multiversion.sh new file mode 100755 index 000000000..48a8cf860 --- /dev/null +++ b/test/e2e/generate-multiversion.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -euo pipefail + +ARGS=$@ +FLAGS=${ARGS:=-g 4 -d networks/nightly} + +# This lists all tags that are reachable from the current commit, sorted by +# increasing semver version. +SORTED_TAGS=`git tag -l --merge HEAD --sort="v:refname"` + +# Extracts the major and minor version of the most recent -dev tagged version. +# For example, on the backport branch for v0.32, the most recent dev tag will contain v0.32.0-dev. +# v0.32 is then extracted from this tag. +BRANCH_MINOR_VERSION=`echo "$SORTED_TAGS" | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+\(-dev[0-9]*\)$' | tail -n 1 | sed -n 's/^\(v[0-9]\+\.[0-9]\+\).*/\1/p'` +LATEST_RELEASE_VERSION=`echo "$SORTED_TAGS" | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | tail -n 1` + +# Check to see if the major and minor version of the latest release version are +# the same as those of the current branch. This ensures that the multi-version testing +# is only run on branches with a tagged release of the same major and minor version +# and not on branches that do not yet have releases such as new backport branches +# and the main branch. +if [ `echo "$LATEST_RELEASE_VERSION" | grep "^$BRANCH_MINOR_VERSION"` ]; then + FLAGS="$FLAGS --multi-version $LATEST_RELEASE_VERSION" +fi + +./build/generator $FLAGS