ci: add support for GitHub Actions in the CI scripts
This commit is contained in:
parent
f50d6ea348
commit
262ce313d0
@ -262,6 +262,8 @@ pub enum CiEnv {
|
||||
None,
|
||||
/// The Azure Pipelines environment, for Linux (including Docker), Windows, and macOS builds.
|
||||
AzurePipelines,
|
||||
/// The GitHub Actions environment, for Linux (including Docker), Windows and macOS builds.
|
||||
GitHubActions,
|
||||
}
|
||||
|
||||
impl CiEnv {
|
||||
@ -269,6 +271,8 @@ impl CiEnv {
|
||||
pub fn current() -> CiEnv {
|
||||
if env::var("TF_BUILD").ok().map_or(false, |e| &*e == "True") {
|
||||
CiEnv::AzurePipelines
|
||||
} else if env::var("GITHUB_ACTIONS").ok().map_or(false, |e| &*e == "true") {
|
||||
CiEnv::GitHubActions
|
||||
} else {
|
||||
CiEnv::None
|
||||
}
|
||||
|
@ -38,38 +38,26 @@ steps:
|
||||
displayName: Show the current environment
|
||||
|
||||
- bash: src/ci/scripts/install-sccache.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Install sccache
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/install-clang.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Install clang
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/switch-xcode.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Switch to Xcode 9.3
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/install-wix.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Install wix
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/install-innosetup.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Install InnoSetup
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/windows-symlink-build-dir.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Ensure the build happens on C:\ instead of D:\
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
@ -78,35 +66,22 @@ steps:
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/install-msys2.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
SYSTEM_WORKFOLDER: $(System.Workfolder)
|
||||
displayName: Install msys2
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/install-msys2-packages.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
SYSTEM_WORKFOLDER: $(System.Workfolder)
|
||||
displayName: Install msys2 packages
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/install-mingw.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
SYSTEM_WORKFOLDER: $(System.Workfolder)
|
||||
displayName: Install MinGW
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/install-ninja.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Install ninja
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/enable-docker-ipv6.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Enable IPv6 on Docker
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
@ -120,22 +95,16 @@ steps:
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/checkout-submodules.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Checkout submodules
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
- bash: src/ci/scripts/verify-line-endings.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
displayName: Verify line endings
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
|
||||
# Ensure the `aws` CLI is installed so we can deploy later on, cache docker
|
||||
# images, etc.
|
||||
- bash: src/ci/scripts/install-awscli.sh
|
||||
env:
|
||||
AGENT_OS: $(Agent.OS)
|
||||
condition: and(succeeded(), not(variables.SKIP_JOB))
|
||||
displayName: Install awscli
|
||||
|
||||
|
@ -172,6 +172,8 @@ docker \
|
||||
--env CI \
|
||||
--env TF_BUILD \
|
||||
--env BUILD_SOURCEBRANCHNAME \
|
||||
--env GITHUB_ACTIONS \
|
||||
--env GITHUB_REF \
|
||||
--env TOOLSTATE_REPO_ACCESS_TOKEN \
|
||||
--env TOOLSTATE_REPO \
|
||||
--env TOOLSTATE_PUBLISH \
|
||||
|
@ -23,9 +23,7 @@ fi
|
||||
ci_dir=`cd $(dirname $0) && pwd`
|
||||
source "$ci_dir/shared.sh"
|
||||
|
||||
branch_name=$(getCIBranch)
|
||||
|
||||
if [ ! isCI ] || [ "$branch_name" = "auto" ] || [ "$branch_name" = "try" ]; then
|
||||
if [ ! isCI ] || isCiBranch auto || isCiBranch beta; then
|
||||
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set build.print-step-timings --enable-verbose-tests"
|
||||
fi
|
||||
|
||||
|
@ -52,7 +52,7 @@ if isWindows; then
|
||||
if [[ "${CUSTOM_MINGW-0}" -ne 1 ]]; then
|
||||
pacman -S --noconfirm --needed mingw-w64-$arch-toolchain mingw-w64-$arch-cmake \
|
||||
mingw-w64-$arch-gcc mingw-w64-$arch-python2
|
||||
ciCommandAddPath "${SYSTEM_WORKFOLDER}/msys2/mingw${bits}/bin"
|
||||
ciCommandAddPath "$(ciCheckoutPath)/msys2/mingw${bits}/bin"
|
||||
else
|
||||
mingw_dir="mingw${bits}"
|
||||
|
||||
|
@ -12,8 +12,8 @@ IFS=$'\n\t'
|
||||
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
|
||||
|
||||
if isWindows; then
|
||||
choco install msys2 --params="/InstallDir:${SYSTEM_WORKFOLDER}/msys2 /NoPath" -y --no-progress
|
||||
mkdir -p "${SYSTEM_WORKFOLDER}/msys2/home/${USERNAME}"
|
||||
choco install msys2 --params="/InstallDir:$(ciCheckoutPath)/msys2 /NoPath" -y --no-progress
|
||||
mkdir -p "$(ciCheckoutPath)/msys2/home/${USERNAME}"
|
||||
|
||||
ciCommandAddPath "${SYSTEM_WORKFOLDER}/msys2/usr/bin"
|
||||
ciCommandAddPath "$(ciCheckoutPath)/msys2/usr/bin"
|
||||
fi
|
||||
|
@ -27,27 +27,66 @@ function retry {
|
||||
}
|
||||
|
||||
function isCI {
|
||||
[ "$CI" = "true" ] || [ "$TF_BUILD" = "True" ]
|
||||
[[ "${CI-false}" = "true" ]] || isAzurePipelines || isGitHubActions
|
||||
}
|
||||
|
||||
function isAzurePipelines {
|
||||
[[ "${TF_BUILD-False}" = "True" ]]
|
||||
}
|
||||
|
||||
function isGitHubActions {
|
||||
[[ "${GITHUB_ACTIONS-false}" = "true" ]]
|
||||
}
|
||||
|
||||
function isMacOS {
|
||||
[ "$AGENT_OS" = "Darwin" ]
|
||||
[[ "${OSTYPE}" = "darwin"* ]]
|
||||
}
|
||||
|
||||
function isWindows {
|
||||
[ "$AGENT_OS" = "Windows_NT" ]
|
||||
[[ "${OSTYPE}" = "cygwin" ]] || [[ "${OSTYPE}" = "msys" ]]
|
||||
}
|
||||
|
||||
function isLinux {
|
||||
[ "$AGENT_OS" = "Linux" ]
|
||||
[[ "${OSTYPE}" = "linux-gnu" ]]
|
||||
}
|
||||
|
||||
function getCIBranch {
|
||||
echo "$BUILD_SOURCEBRANCHNAME"
|
||||
function isCiBranch {
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "usage: $0 <branch-name>"
|
||||
exit 1
|
||||
fi
|
||||
name="$1"
|
||||
|
||||
if isAzurePipelines; then
|
||||
[[ "${BUILD_SOURCEBRANCHNAME}" = "${name}" ]]
|
||||
elif isGitHubActions; then
|
||||
[[ "${GITHUB_REF}" = "refs/heads/${name}" ]]
|
||||
else
|
||||
echo "isCiBranch only works inside CI!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function ciCommit {
|
||||
echo "${BUILD_SOURCEVERSION}"
|
||||
if isAzurePipelines; then
|
||||
echo "${BUILD_SOURCEVERSION}"
|
||||
elif isGitHubActions; then
|
||||
echo "${GITHUB_SHA}"
|
||||
else
|
||||
echo "ciCommit only works inside CI!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function ciCheckoutPath {
|
||||
if isAzurePipelines; then
|
||||
echo "${SYSTEM_WORKFOLDER}"
|
||||
elif isGitHubActions; then
|
||||
echo "${GITHUB_WORKSPACE}"
|
||||
else
|
||||
echo "ciCheckoutPath only works inside CI!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function ciCommandAddPath {
|
||||
@ -57,7 +96,14 @@ function ciCommandAddPath {
|
||||
fi
|
||||
path="$1"
|
||||
|
||||
echo "##vso[task.prependpath]${path}"
|
||||
if isAzurePipelines; then
|
||||
echo "##vso[task.prependpath]${path}"
|
||||
elif isGitHubActions; then
|
||||
echo "::add-path::${value}"
|
||||
else
|
||||
echo "ciCommandAddPath only works inside CI!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function ciCommandSetEnv {
|
||||
@ -68,5 +114,12 @@ function ciCommandSetEnv {
|
||||
name="$1"
|
||||
value="$2"
|
||||
|
||||
echo "##vso[task.setvariable variable=${name}]${value}"
|
||||
if isAzurePipelines; then
|
||||
echo "##vso[task.setvariable variable=${name}]${value}"
|
||||
elif isGitHubActions; then
|
||||
echo "::set-env name=${name}::${value}"
|
||||
else
|
||||
echo "ciCommandSetEnv only works inside CI!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user