1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-10 00:23:32 +02:00

Move GitHub Actions CI scripts into separate files

Break the workflow into smaller stages (Configure, Build, Install,
Package, etc.) so that you can see exactly which stage failed in the
GitHub Actions run log.

Create a separate Bash CI script for each job stage (configure.sh,
build.sh, install.sh, package.sh, etc.) to reduce the size of the main
YAML workflow file and enable Bash syntax highlighting.

Close #917
This commit is contained in:
Peter Jonas
2021-06-10 16:52:24 +01:00
committed by Dmitry Vedenko
parent 3ebebbb360
commit 4b5c95d7fe
12 changed files with 257 additions and 201 deletions

22
scripts/ci/build.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; }
set -euxo pipefail
if [[ "${OSTYPE}" == msys* ]]; then # Windows
cpus="${NUMBER_OF_PROCESSORS}"
elif [[ "${OSTYPE}" == darwin* ]]; then # macOS
cpus="$(sysctl -n hw.ncpu)"
else # Linux & others
cpus="$(nproc)"
fi
# Build Audacity
cmake --build build -j "${cpus}" --config "${AUDACITY_BUILD_TYPE}"

32
scripts/ci/configure.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; }
set -euxo pipefail
conan --version # check it works
cmake_args=(
-S .
-B build
-G "${AUDACITY_CMAKE_GENERATOR}"
-D audacity_use_pch=no
-D audacity_has_networking=yes
-D CMAKE_BUILD_TYPE="${AUDACITY_BUILD_TYPE}"
-D CMAKE_INSTALL_PREFIX="${AUDACITY_INSTALL_PREFIX}"
)
if [[ "${AUDACITY_CMAKE_GENERATOR}" == "Visual Studio"* ]]; then
case "${AUDACITY_ARCH_LABEL}" in
32bit) cmake_args+=( -A Win32 ) ;;
64bit) cmake_args+=( -A x64 ) ;;
*) echo >&2 "$0: Unrecognised arch label '${AUDACITY_ARCH_LABEL}'" ; exit 1 ;;
esac
elif [[ "${AUDACITY_CMAKE_GENERATOR}" == Xcode* ]]; then
cmake_args+=(
-T buildsystem=1
)
fi
# Configure Audacity
cmake "${cmake_args[@]}"

49
scripts/ci/dependencies.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
((${BASH_VERSION%%.*} >= 4)) || echo >&2 "$0: Warning: Using ancient Bash version ${BASH_VERSION}."
set -euxo pipefail
if [[ "${OSTYPE}" == msys* ]]; then # Windows
# Python packages
pip_packages=(
conan
)
pip3 install "${pip_packages[@]}"
elif [[ "${OSTYPE}" == darwin* ]]; then # macOS
# Homebrew packages
brew_packages=(
bash # macOS ships with Bash v3 for licensing reasons so upgrade it now
conan
)
brew install "${brew_packages[@]}"
else # Linux & others
# Distribution packages
if which apt-get; then
apt_packages=(
libasound2-dev
libgtk2.0-dev
gettext
python3-pip
)
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends "${apt_packages[@]}"
sudo apt-get remove -y ccache
else
echo >&2 "$0: Error: You don't have a recognized package manager installed."
exit 1
fi
# Python packages
pip_packages=(
conan
)
pip3 install wheel setuptools # need these first to install other packages (e.g. conan)
pip3 install "${pip_packages[@]}"
fi

25
scripts/ci/environment.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
if [[ "$0" == "${BASH_SOURCE}" ]]; then
echo >&2 "$0: Please source this script instead of running it."
exit 1
fi
((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "${BASH_SOURCE}: Error: Please upgrade Bash."; return 1; }
function gh_export()
{
[[ "${GITHUB_ENV-}" ]] || local -r GITHUB_ENV="/dev/null"
export -- "$@" && printf "%s\n" "$@" >> "${GITHUB_ENV}"
}
repository_root="$(cd "$(dirname "${BASH_SOURCE}")/../.."; echo "${PWD}")"
gh_export CONAN_USER_HOME="${repository_root}/conan-home/"
gh_export CONAN_USER_HOME_SHORT="${repository_root}/conan-home/short"
gh_export GIT_HASH="$(git show -s --format='%H')"
gh_export GIT_HASH_SHORT="$(git show -s --format='%h')"
gh_export AUDACITY_BUILD_TYPE="Release"
gh_export AUDACITY_INSTALL_PREFIX="${repository_root}/build/install"

8
scripts/ci/install.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; }
set -euxo pipefail
# Install Audacity
cmake --install build --config "${AUDACITY_BUILD_TYPE}" --verbose

8
scripts/ci/package.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; }
set -euxo pipefail
cd build
cpack -C "${AUDACITY_BUILD_TYPE}" --verbose