diff options
author | Davide Beatrici <git@davidebeatrici.dev> | 2021-01-06 21:35:05 +0300 |
---|---|---|
committer | Davide Beatrici <git@davidebeatrici.dev> | 2021-01-08 01:19:30 +0300 |
commit | ab6b6d142c3a40bd8beaa3cfdb1d16ad2002a5ed (patch) | |
tree | 32b371d334ae543feda3a8b448e6098c405c4d71 /.ci | |
parent | d8a5133b090cbffd920a861bb3ca787a8f524998 (diff) |
CI(azure): Get unique build number from our server
BUILD_NUMBER_TOKEN is defined on Azure Pipelines and contains a secret token that is used to access the endpoint on our server.
Restricted access is in place for the sole purpose of preventing the build number from being increased when accessing the page outside of the CI environment.
This commit also improves the descriptive header of the build script files.
Diffstat (limited to '.ci')
-rwxr-xr-x | .ci/azure-pipelines/build_linux.bash | 22 | ||||
-rwxr-xr-x | .ci/azure-pipelines/build_macos.bash | 39 | ||||
-rw-r--r-- | .ci/azure-pipelines/build_windows.bat | 32 | ||||
-rwxr-xr-x | .ci/travis-ci/script.bash | 8 |
4 files changed, 76 insertions, 25 deletions
diff --git a/.ci/azure-pipelines/build_linux.bash b/.ci/azure-pipelines/build_linux.bash index a4ca8a8e7..d9bcbe5ed 100755 --- a/.ci/azure-pipelines/build_linux.bash +++ b/.ci/azure-pipelines/build_linux.bash @@ -7,20 +7,34 @@ # # Below is a list of configuration variables used from environment. # +# Predefined variables: +# # BUILD_BINARIESDIRECTORY - The local path on the agent that can be used # as an output folder for compiled binaries. # BUILD_SOURCESDIRECTORY - The local path on the agent where the # repository is downloaded. # +# Defined on Azure Pipelines: +# +# BUILD_NUMBER_TOKEN - Access token for the build number page on our server. +# -VER=$(python scripts/mumble-version.py) +if [[ -n "$BUILD_NUMBER_TOKEN" ]]; then + VERSION=$(python "scripts/mumble-version.py" --project) + BUILD_NUMBER=$(curl "https://mumble.info/get-build-number?version=$VERSION&token=$BUILD_NUMBER_TOKEN") +else + BUILD_NUMBER=0 +fi + +RELEASE_ID=$(python "scripts/mumble-version.py") cd $BUILD_BINARIESDIRECTORY -cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=appdir/usr -Dtests=ON Donline-tests=ON -Dversion=$VER -Dsymbols=ON \ - -Donline-tests=ON -Dgrpc=ON -Ddisplay-install-paths=ON $BUILD_SOURCESDIRECTORY +cmake -G Ninja -DCMAKE_INSTALL_PREFIX=appdir/usr \ + -DCMAKE_BUILD_TYPE=Release -DRELEASE_ID=$RELEASE_ID -DBUILD_NUMBER=$BUILD_NUMBER \ + -Dtests=ON -Donline-tests=ON -Dsymbols=ON -Dgrpc=ON \ + -Ddisplay-install-paths=ON $BUILD_SOURCESDIRECTORY cmake --build . ctest --verbose cmake --install . - diff --git a/.ci/azure-pipelines/build_macos.bash b/.ci/azure-pipelines/build_macos.bash index e46ab121c..0d711e96c 100755 --- a/.ci/azure-pipelines/build_macos.bash +++ b/.ci/azure-pipelines/build_macos.bash @@ -5,21 +5,46 @@ # that can be found in the LICENSE file at the root of the # Mumble source tree or at <https://www.mumble.info/LICENSE>. # +# Builds Mumble using the specified build script. +# The path to the script is relative to the build environment's root. +# The configuration we build with is adjusted to be close to +# our release builds. +# # Below is a list of configuration variables used from environment. # -# BUILD_BINARIESDIRECTORY - The local path on the agent that can be used -# as an output folder for compiled binaries. -# BUILD_SOURCESDIRECTORY - The local path on the agent where the -# repository is downloaded. +# Predefined variables: +# +# BUILD_BINARIESDIRECTORY - The local path on the agent that can be used +# as an output folder for compiled binaries. +# BUILD_SOURCESDIRECTORY - The local path on the agent where the +# repository is downloaded. +# +# Defined in .azure-pipelines.yml: +# +# MUMBLE_ENVIRONMENT_PATH - Path to the environment's root directory. +# MUMBLE_ENVIRONMENT_TOOLCHAIN - Path to the vcpkg CMake toolchain, used for CMake. +# MUMBLE_ENVIRONMENT_TRIPLET - vcpkg triplet. # +# Defined on Azure Pipelines: +# +# BUILD_NUMBER_TOKEN - Access token for the build number page on our server. +# + +if [[ -n "$BUILD_NUMBER_TOKEN" ]]; then + VERSION=$(python "scripts/mumble-version.py" --project) + BUILD_NUMBER=$(curl "https://mumble.info/get-build-number?version=$VERSION&token=$BUILD_NUMBER_TOKEN") +else + BUILD_NUMBER=0 +fi -VER=$(python scripts/mumble-version.py) +RELEASE_ID=$(python "scripts/mumble-version.py") cd $BUILD_BINARIESDIRECTORY cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=$MUMBLE_ENVIRONMENT_TOOLCHAIN -DIce_HOME="$MUMBLE_ENVIRONMENT_PATH/installed/x64-osx" \ - -DCMAKE_BUILD_TYPE=Release -Dtests=ON -Dversion=$VER -Dstatic=ON -Dsymbols=ON -Donline-tests=ON -Dgrpc=ON \ - -Ddisplay-install-paths=ON $BUILD_SOURCESDIRECTORY + -DCMAKE_BUILD_TYPE=Release -DRELEASE_ID=$RELEASE_ID -DBUILD_NUMBER=$BUILD_NUMBER \ + -Dtests=ON -Donline-tests=ON -Dstatic=ON -Dsymbols=ON -Dgrpc=ON \ + -Ddisplay-install-paths=ON $BUILD_SOURCESDIRECTORY cmake --build . ctest --verbose diff --git a/.ci/azure-pipelines/build_windows.bat b/.ci/azure-pipelines/build_windows.bat index 3bf9d09e4..568268493 100644 --- a/.ci/azure-pipelines/build_windows.bat +++ b/.ci/azure-pipelines/build_windows.bat @@ -1,4 +1,4 @@ -:: Copyright 2020-2020 The Mumble Developers. All rights reserved. +:: Copyright 2020 The Mumble Developers. All rights reserved. :: Use of this source code is governed by a BSD-style license :: that can be found in the LICENSE file at the root of the :: Mumble source tree or at <https://www.mumble.info/LICENSE>. @@ -23,17 +23,28 @@ :: :: Defined in .azure-pipelines.yml: :: -:: MUMBLE_ENVIRONMENT_STORE - Path to the folder the build environment is stored in. -:: MUMBLE_ENVIRONMENT_SOURCE - Build environment web source folder URL. -:: MUMBLE_ENVIRONMENT_TRIPLET - vcpkg triplet. -:: MUMBLE_ENVIRONMENT_VERSION - Full build environment version -:: Must match archive and extracted folder name. +:: MUMBLE_ENVIRONMENT_PATH - Path to the environment's root directory. :: MUMBLE_ENVIRONMENT_TOOLCHAIN - Path to the vcpkg CMake toolchain, used for CMake. +:: MUMBLE_ENVIRONMENT_TRIPLET - vcpkg triplet. :: VCVARS_PATH - Path to the Visual Studio environment initialization script. +:: +:: Defined on Azure Pipelines: +:: +:: BUILD_NUMBER_TOKEN - Access token for the build number page on our server. +:: @echo on -for /f "tokens=* USEBACKQ" %%g in (`python "scripts/mumble-version.py"`) do (set "VER=%%g") +if defined BUILD_NUMBER_TOKEN ( + :: The method we use to store a command's output into a variable: + :: https://stackoverflow.com/a/6362922 + for /f "tokens=* USEBACKQ" %%g in (`python "scripts/mumble-version.py" --project`) do (set "VERSION=%%g") + for /f "tokens=* USEBACKQ" %%g in (`curl "https://mumble.info/get-build-number?version=%VERSION%&token=%BUILD_NUMBER_TOKEN%"`) do (set "BUILD_NUMBER=%%g") +) else ( + set BUILD_NUMBER=0 +) + +for /f "tokens=* USEBACKQ" %%g in (`python "scripts/mumble-version.py"`) do (set "RELEASE_ID=%%g") cd /d %BUILD_BINARIESDIRECTORY% @@ -51,9 +62,10 @@ del C:\Strawberry\c\bin\g++.exe del C:\Strawberry\c\bin\c++.exe cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="%MUMBLE_ENVIRONMENT_TOOLCHAIN%" -DVCPKG_TARGET_TRIPLET=%MUMBLE_ENVIRONMENT_TRIPLET% ^ - -DIce_HOME="%MUMBLE_ENVIRONMENT_PATH%\installed\%MUMBLE_ENVIRONMENT_TRIPLET%" -DCMAKE_BUILD_TYPE=Release -Dtests=ON ^ - -Dversion=%VER% -Dpackaging=ON -Dstatic=ON -Dsymbols=ON -Dasio=ON -Dg15=ON -Donline-tests=ON -Dgrpc=ON ^ - -Ddisplay-install-paths=ON "%BUILD_SOURCESDIRECTORY%" + -DIce_HOME="%MUMBLE_ENVIRONMENT_PATH%\installed\%MUMBLE_ENVIRONMENT_TRIPLET%" ^ + -DCMAKE_BUILD_TYPE=Release -DRELEASE_ID=%RELEASE_ID% -DBUILD_NUMBER=%BUILD_NUMBER% ^ + -Dpackaging=ON -Dtests=ON -Donline-tests=ON -Dstatic=ON -Dsymbols=ON -Dgrpc=ON -Dasio=ON -Dg15=ON ^ + -Ddisplay-install-paths=ON "%BUILD_SOURCESDIRECTORY%" if errorlevel 1 ( exit /b %errorlevel% diff --git a/.ci/travis-ci/script.bash b/.ci/travis-ci/script.bash index a67abbf98..82be9ad27 100755 --- a/.ci/travis-ci/script.bash +++ b/.ci/travis-ci/script.bash @@ -11,13 +11,13 @@ if [ "${TRAVIS_REPO_SLUG}" == "mumble-voip/mumble" ] && [ "${TRAVIS_PULL_REQUEST fi fi -VER=$(python scripts/mumble-version.py) +RELEASE_ID=$(python scripts/mumble-version.py) if [ "${TRAVIS_OS_NAME}" == "linux" ]; then if [ "${MUMBLE_HOST}" == "aarch64-linux-gnu" ]; then mkdir build && cd build - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -Dtests=ON -Dversion=$VER -Dsymbols=ON -Donline-tests=ON -Dgrpc=ON -Ddisplay-install-paths=ON .. + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -Dtests=ON -DRELEASE_ID=$RELEASE_ID -Dsymbols=ON -Donline-tests=ON -Dgrpc=ON -Ddisplay-install-paths=ON .. cmake --build . # We don't execute tests on ARM64 because TestPacketDataStream fails. @@ -28,7 +28,7 @@ if [ "${TRAVIS_OS_NAME}" == "linux" ]; then mkdir build && cd build # We specify the absolute path because otherwise Travis CI's CMake is used. - /usr/bin/cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -Dtests=ON -Dversion=$VER -Dsymbols=ON -Donline-tests=ON -Dgrpc=ON \ + /usr/bin/cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -Dtests=ON -DRELEASE_ID=$RELEASE_ID -Dsymbols=ON -Donline-tests=ON -Dgrpc=ON \ -Ddisplay-install-paths=ON .. /usr/bin/cmake --build . @@ -43,7 +43,7 @@ if [ "${TRAVIS_OS_NAME}" == "linux" ]; then PATH=$PATH:/usr/lib/mxe/usr/bin - ${MUMBLE_HOST}.static-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -Dtests=ON -Dversion=$VER -Dstatic=ON -Dsymbols=ON -Dasio=ON \ + ${MUMBLE_HOST}.static-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -Dtests=ON -DRELEASE_ID=$RELEASE_ID -Dstatic=ON -Dsymbols=ON -Dasio=ON \ -Dzeroconf=OFF -Dice=OFF -Doverlay=OFF -Donline-tests=ON -Ddisplay-install-paths=ON .. cmake --build . # TODO: investigate why tests fail. |