Skip to content

Commit

Permalink
try to fix jenkins compat with GHA
Browse files Browse the repository at this point in the history
since migration is going slow
  • Loading branch information
CamJN committed Sep 30, 2024
1 parent 7397933 commit 01bfa8c
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 28 deletions.
35 changes: 27 additions & 8 deletions dev/ci/lib/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,48 @@ function autodetect_environment()
if [ "${GITHUB_ACTIONS:-false}" = "true" ]; then
echo "Running in Github Actions: yes"
export CACHE_DIR="$RUNNER_TOOL_CACHE/$GITHUB_JOB/$RUNNER_OS"
elif [[ "$JENKINS_HOME" != "" ]]; then
echo "Running in Jenkins: yes"
export IN_JEKINS=true
if [ $OS = "linux" ]; then
export CACHE_DIR="$JENKINS_HOME/cache/$JOB_NAME/executor-$EXECUTOR_NUMBER"
else
require_envvar WORKSPACE "$WORKSPACE"
export CACHE_DIR="$WORKSPACE/cache/$JOB_NAME/executor-$EXECUTOR_NUMBER"
fi
else
echo "Running in Github Actions: no"
echo "Running in CI: no"
export IN_JENKINS=false
export CACHE_DIR="$PASSENGER_ROOT/.ci_cache"
fi
echo "Cache directory: $CACHE_DIR"
}

function sanity_check_environment()
{
if [ "${GITHUB_ACTIONS:-false}" = "true" ]; then
if $IN_JENKINS; then
if [[ "$JOB_NAME" = "" ]]; then
echo "ERROR: Jenkins environment detected, but JOB_NAME environment variable not set." >&2
return 1
fi
if [[ "$EXECUTOR_NUMBER" = "" ]]; then
echo "ERROR: Jenkins environment detected, but EXECUTOR_NUMBER environment variable not set." >&2
return 1
fi
elif [ "${GITHUB_ACTIONS:-false}" = "true" ]; then
if [ -z "$GITHUB_JOB" ]; then
echo "ERROR: Github Actions environment detected, but GITHUB_JOB environment variable not set." >&2
return 1
else
export "JOB_NAME=$GITHUB_JOB"
else
export "JOB_NAME=$GITHUB_JOB"
fi
if [ -z "$GITHUB_RUN_ID" ]; then
echo "ERROR: Github Actions environment detected, but GITHUB_RUN_ID environment variable not set." >&2
return 1
else
export "EXECUTOR_NUMBER=$GITHUB_RUN_ID"
else
export "EXECUTOR_NUMBER=$GITHUB_RUN_ID"
fi
fi
fi
}

# The following is necessary to make the C++ tests work.
Expand All @@ -112,7 +131,7 @@ function sanity_check_environment()
function add_bundler_path_to_gem_path()
{
local bundle_path

if bundle_path=$(bundle show rake); then
bundle_path=$(dirname "$bundle_path")
bundle_path=$(dirname "$bundle_path")
Expand Down
38 changes: 24 additions & 14 deletions dev/ci/lib/set-container-envvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,40 @@ export CCACHE_LOGFILE="$(pwd)/buildout/testlogs/ccache.log"
export NOEXEC_DISABLE=1

if [[ "$EXECUTOR_NUMBER" != "" ]]; then
if [ "${GITHUB_ACTIONS:-false}" = "false" ]; then
(( TEST_PORT_BASE=64000+EXECUTOR_NUMBER*10 ))
else
(( TEST_PORT_BASE=64000 ))
fi
export TEST_PORT_BASE
fi

if [[ "$OS" != macos ]]; then
if [[ "$OS" = macos ]]; then
if [ "${GITHUB_ACTIONS:-false}" = "false" ]; then
# Ensure that Homebrew tools can be found
eval "$(/usr/libexec/path_helper -s)"
fi
else
export LC_CTYPE=C.UTF-8
fi

if [[ -f ~/.rvm/scripts/rvm ]]; then
# shellcheck source=/dev/null
source ~/.rvm/scripts/rvm
# shellcheck source=/dev/null
source ~/.rvm/scripts/rvm
elif [[ -f /usr/local/rvm/scripts/rvm ]]; then
# shellcheck source=/dev/null
source /usr/local/rvm/scripts/rvm
# shellcheck source=/dev/null
source /usr/local/rvm/scripts/rvm
fi

if command -v rvm; then
if [[ "$TEST_RUBY_VERSION" != "" ]]; then
header2 "Using Ruby version $TEST_RUBY_VERSION"
run rvm use "$TEST_RUBY_VERSION"
echo
fi
# RVM's cd override causes problems (probably thanks to bash
# error handling being weird and quirky:
# https://news.ycombinator.com/item?id=14321213)
unset cd
if [[ "$TEST_RUBY_VERSION" != "" ]]; then
header2 "Using Ruby version $TEST_RUBY_VERSION"
run rvm use "$TEST_RUBY_VERSION"
echo
fi

# RVM's cd override causes problems (probably thanks to bash
# error handling being weird and quirky:
# https://news.ycombinator.com/item?id=14321213)
unset cd
fi
9 changes: 8 additions & 1 deletion dev/ci/lib/setup-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ header2 "Creating test/config.json"
if [[ "$OS" = linux ]]; then
run cp test/config.json.travis test/config.json
else

if [ "${GITHUB_ACTIONS:-false}" = "true" ]; then
KEYCHAIN_PATH='/Library/Keychains/System.keychain'
else
KEYCHAIN_PATH='~/Library/Keychains/login.keychain-db'
fi

sed \
-e "s/_AUTHORITY_/Developer/" \
-e "s|_KEYCHAIN_|/Library/Keychains/System.keychain|" \
-e "s|_KEYCHAIN_|$KEYCHAIN_PATH|" \
-e "s/_USER_/$USER/" \
test/config.json.travis-osx > test/config.json
fi
Expand Down
5 changes: 3 additions & 2 deletions dev/ci/setup-host
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [[ "$OS" = macos && "$1" = "" ]]; then
exit 1
fi

if [ "${GITHUB_ACTIONS:-false}" = "true" ]; then
if [ "${CI:-false}" = "true" ]; then
# Relax permissions. Necessary for unit tests which test permissions.
header2 "Relaxing file permissions"
echo "+ Setting umask"
Expand All @@ -31,9 +31,10 @@ if [ "${GITHUB_ACTIONS:-false}" = "true" ]; then
find ./* -type d -print0 | xargs -0 -n 512 chmod g+rx,o+rx

# Create this file now because otherwise it would be owned by root,
# which CI runner cannot remove.
run touch test/test.log

if [ "$OS" = "macos" ]; then
if [ "${GITHUB_ACTIONS:-false}" = "true" ] && [ "$OS" = "macos" ]; then
brew update
brew install ccache
sudo security authorizationdb write com.apple.trust-settings.admin allow
Expand Down
19 changes: 16 additions & 3 deletions dev/ci/tests/homebrew-packaging/setup
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
#!/usr/bin/env bash
set -e

if ! gem list | grep -qE '^rack '; then
if command -v rvm-exec; then
GEM_COMMAND='rvm-exec system gem'
RAKE_COMMAND='rvm-exec system rake'
SUDO_COMMAND='rvmsudo'
else
GEM_COMMAND='gem'
RAKE_COMMAND='rake'
SUDO_COMMAND='sudo'
fi

# rvm or system ruby
if ! $GEM_COMMAND list | grep -qE '^rack '; then
# The native packaging test runs passenger-install-*-module with the system Ruby,
# which in turn requires the 'rack' gem to be installed in the system Ruby's
# default RubyGems path. 'rake test:install_deps' installs to a local bundler
# directory but not to the default RubyGems path.
retry_run 3 sudo gem install rack --no-document
export rvmsudo_secure_path=0
retry_run 3 $SUDO_COMMAND $GEM_COMMAND install rack --no-document
fi
retry_run 3 rake test:install_deps DEVDEPS_DEFAULT=no BASE_DEPS=yes SUDO=yes
retry_run 3 $RAKE_COMMAND test:install_deps DEVDEPS_DEFAULT=no BASE_DEPS=yes SUDO=yes
# just system ruby
retry_run 3 gem install bundler -v '~>1.0' --no-document
retry_run 3 rake test:install_deps BASE_DEPS=yes

0 comments on commit 01bfa8c

Please sign in to comment.