Skip to content

Commit

Permalink
Fix library support for self-hosted runners
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Jun 15, 2024
1 parent 20d7c08 commit 61ec81f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/scripts/cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ add_log() {
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "Added $subject"
else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "Failed to setup $subject"
[ "${fail_fast:?}" = "true" ] && exit 1
fi
done
}
Expand Down Expand Up @@ -106,8 +107,6 @@ data() {

dependencies() {
if [ "$os" = "Linux" ] || [ "$os" = "Darwin" ]; then
export tick=""
export cross=""
export ext_config_directory="/tmp/extcache"
export deps_cache_directory="${RUNNER_TOOL_CACHE}"/deps
sudo mkdir -p "$deps_cache_directory"
Expand All @@ -116,6 +115,8 @@ dependencies() {
}

init() {
export tick=""
export cross=""
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)
# shellcheck disable=SC1090
. "$script_dir/$(echo "$os" | tr '[:upper:]' '[:lower:]').sh"
Expand Down
16 changes: 15 additions & 1 deletion src/scripts/linux.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
read_env() {
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
[[ -z "${ImageOS}" && -z "${ImageVersion}" || -n ${ACT} ]] && _runner=self-hosted || _runner=github
runner="${runner:-${RUNNER:-$_runner}}"

if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
fail_fast=true
add_log "${cross:?}" "Runner" "Runner set as github in self-hosted environment"
fi
}

check_package() {
apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
}
Expand Down Expand Up @@ -86,7 +97,9 @@ filter_libraries() {
setup_libraries() {
libraries=$1
if [[ -n "${libraries// /}" ]]; then
libraries=$(filter_libraries "$libraries")
if [ "$runner" = "github" ]; then
libraries=$(filter_libraries "$libraries")
fi
if [[ -n "${libraries// /}" ]]; then
step_log "Setup libraries"
IFS=' ' read -r -a libraries_array <<<"$libraries"
Expand Down Expand Up @@ -131,6 +144,7 @@ setup_dependencies() {

self_hosted_helper() {
if ! [ -e /tmp/cache_extension_self_hosted ]; then
read_env
add_package sudo
add_package curl
link_apt_fast
Expand Down

0 comments on commit 61ec81f

Please sign in to comment.