From f42bcdd7a8568a3bc1c8d59f1c2858017f4cc941 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 16 Dec 2024 22:31:22 +0000 Subject: [PATCH] nit: automate dep management --- .github/actions/fetch_ctk/action.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/actions/fetch_ctk/action.yml b/.github/actions/fetch_ctk/action.yml index 81d5f8dc..17db5deb 100644 --- a/.github/actions/fetch_ctk/action.yml +++ b/.github/actions/fetch_ctk/action.yml @@ -22,11 +22,21 @@ runs: - name: Install dependencies shell: bash --noprofile --norc -xeuo pipefail {0} run: | - if (command -v curl 2>&1 >/dev/null) && (command -v zstd 2>&1 >/dev/null); then + dependencies=(zstd curl xz-utils) + dependent_exes=(zstd curl xz) + + not_found=0 + for dep in ${dependent_exes[@]}; do + if ! (command -v curl 2>&1 >/dev/null); then + not_found=1 + break + fi + fi + if [[ $not_found == 0 ]]; then echo "All dependencies are found. Do nothing." exit 0 fi - if ! command -v sudo 2>&1 >/dev/null; then + if ! (command -v sudo 2>&1 >/dev/null); then if [[ $EUID == 0 ]]; then alias SUDO="" else @@ -38,7 +48,7 @@ runs: fi shopt -s expand_aliases SUDO apt update - SUDO apt install -y zstd curl xz-utils + SUDO apt install -y ${dependencies[@]} - name: Download CTK cache id: ctk-get-cache