From d2060f4e4b0f7b24fc7e62b75ebc85caed1287f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Almir=20Saraj=C4=8Di=C4=87?= Date: Fri, 20 Sep 2024 10:24:51 +0200 Subject: [PATCH] Enable unattended setup --- .github/github_workflows.ex | 11 +++++++++++ .github/workflows/main.yml | 6 ++++++ .github/workflows/pr.yml | 6 ++++++ priv/static/Linux.sh | 10 ++++++++++ priv/static/macOS.sh | 10 ++++++++++ 5 files changed, 43 insertions(+) diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index 3d4dc148..207b6957 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -419,6 +419,17 @@ defmodule GithubWorkflows do ] ] ) ++ + if(os == "Linux", + do: [], + else: [ + [ + name: "Disable password prompt for macOS", + if: "steps.result_cache.outputs.cache-hit != 'true'", + run: + ~S + ] + ] + ) ++ [ [ name: "Install expect tool", diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85d34e2a..6dc8297e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -313,6 +313,9 @@ jobs: with: key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/static/macOS.sh') }} path: priv/static/macOS.sh + - name: Disable password prompt for macOS + if: steps.result_cache.outputs.cache-hit != 'true' + run: 'sudo sed -i "" "s/%admin ALL = (ALL) ALL/%admin ALL = (ALL) NOPASSWD: ALL/g" /etc/sudoers' - name: Install expect tool if: steps.result_cache.outputs.cache-hit != 'true' run: brew install expect @@ -391,6 +394,9 @@ jobs: - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: brew install zsh + - name: Disable password prompt for macOS + if: steps.result_cache.outputs.cache-hit != 'true' + run: 'sudo sed -i "" "s/%admin ALL = (ALL) ALL/%admin ALL = (ALL) NOPASSWD: ALL/g" /etc/sudoers' - name: Install expect tool if: steps.result_cache.outputs.cache-hit != 'true' run: brew install expect diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e2022897..a8c785e0 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -317,6 +317,9 @@ jobs: with: key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/static/macOS.sh') }} path: priv/static/macOS.sh + - name: Disable password prompt for macOS + if: steps.result_cache.outputs.cache-hit != 'true' + run: 'sudo sed -i "" "s/%admin ALL = (ALL) ALL/%admin ALL = (ALL) NOPASSWD: ALL/g" /etc/sudoers' - name: Install expect tool if: steps.result_cache.outputs.cache-hit != 'true' run: brew install expect @@ -395,6 +398,9 @@ jobs: - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: brew install zsh + - name: Disable password prompt for macOS + if: steps.result_cache.outputs.cache-hit != 'true' + run: 'sudo sed -i "" "s/%admin ALL = (ALL) ALL/%admin ALL = (ALL) NOPASSWD: ALL/g" /etc/sudoers' - name: Install expect tool if: steps.result_cache.outputs.cache-hit != 'true' run: brew install expect diff --git a/priv/static/Linux.sh b/priv/static/Linux.sh index 94bf71b4..6bab0d2f 100755 --- a/priv/static/Linux.sh +++ b/priv/static/Linux.sh @@ -125,6 +125,16 @@ maybe_install() { add_env() { printf "\n" + # Ask for sudo password upfront + sudo -v + + # Keep sudo alive + while true; do + sudo -n true + sleep 60 + kill -0 "$$" || exit + done 2>/dev/null & + printf "${white}\n" sleep 1.5 maybe_install "mise" diff --git a/priv/static/macOS.sh b/priv/static/macOS.sh index 2c849299..1f4f5364 100755 --- a/priv/static/macOS.sh +++ b/priv/static/macOS.sh @@ -134,6 +134,16 @@ maybe_install() { add_env() { printf "\n" + # Ask for sudo password upfront + sudo -v + + # Keep sudo alive + while true; do + sudo -n true + sleep 60 + kill -0 "$$" || exit + done 2>/dev/null & + printf "${white}\n" sleep 1.5 maybe_install "Xcode Command Line Tools"