Skip to content

Commit

Permalink
Make scripts consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
almirsarajcic committed Sep 18, 2024
1 parent 48641e2 commit c78c16e
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/github_workflows.ex
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ defmodule GithubWorkflows do
jobs ++
[
{:"test_linux_#{shell}", test_linux_script_job(shell)},
# {:"test_macos_#{shell}", test_macos_script_job(shell)}
{:"test_macos_#{shell}", test_macos_script_job(shell)}
]
end)
end
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,40 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
test_macos_bash:
name: Test macOS script with bash shell
runs-on: macos-latest
env:
SHELL: /bin/bash
TZ: America/New_York
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
id: result_cache
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/static/macOS.sh') }}
path: priv/static/macOS.sh
- name: Install expect tool
if: steps.result_cache.outputs.cache-hit != 'true'
run: brew install expect
- name: Test the script
if: steps.result_cache.outputs.cache-hit != 'true'
run: cd test/scripts && expect script.exp macOS.sh
shell: /bin/bash -l {0}
- name: Generate an app and start the server
if: steps.result_cache.outputs.cache-hit != 'true'
run: /bin/bash -c 'source ~/.bash_profile && make -f test/scripts/Makefile serve'
shell: /bin/bash -l {0}
- name: Check HTTP status code
if: steps.result_cache.outputs.cache-hit != 'true'
uses: nick-fields/retry@v2
with:
command: INPUT_SITES='["http://localhost:4000"]' INPUT_EXPECTED='[200]' ./test/scripts/check_status_code.sh
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
test_linux_zsh:
name: Test Linux script with zsh shell
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,11 +111,50 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
test_macos_zsh:
name: Test macOS script with zsh shell
runs-on: macos-latest
env:
SHELL: /bin/zsh
TZ: America/New_York
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
id: result_cache
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/static/macOS.sh') }}
path: priv/static/macOS.sh
- name: Install shell
if: steps.result_cache.outputs.cache-hit != 'true'
run: brew install zsh
- name: Install expect tool
if: steps.result_cache.outputs.cache-hit != 'true'
run: brew install expect
- name: Test the script
if: steps.result_cache.outputs.cache-hit != 'true'
run: cd test/scripts && expect script.exp macOS.sh
shell: /bin/zsh -l {0}
- name: Generate an app and start the server
if: steps.result_cache.outputs.cache-hit != 'true'
run: /bin/zsh -c 'source ~/.zshrc && make -f test/scripts/Makefile serve'
shell: /bin/zsh -l {0}
- name: Check HTTP status code
if: steps.result_cache.outputs.cache-hit != 'true'
uses: nick-fields/retry@v2
with:
command: INPUT_SITES='["http://localhost:4000"]' INPUT_EXPECTED='[200]' ./test/scripts/check_status_code.sh
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
deploy_production_app:
name: Deploy production app
needs:
- test_linux_bash
- test_macos_bash
- test_linux_zsh
- test_macos_zsh
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,40 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
test_macos_bash:
name: Test macOS script with bash shell
runs-on: macos-latest
env:
SHELL: /bin/bash
TZ: America/New_York
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
id: result_cache
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/static/macOS.sh') }}
path: priv/static/macOS.sh
- name: Install expect tool
if: steps.result_cache.outputs.cache-hit != 'true'
run: brew install expect
- name: Test the script
if: steps.result_cache.outputs.cache-hit != 'true'
run: cd test/scripts && expect script.exp macOS.sh
shell: /bin/bash -l {0}
- name: Generate an app and start the server
if: steps.result_cache.outputs.cache-hit != 'true'
run: /bin/bash -c 'source ~/.bash_profile && make -f test/scripts/Makefile serve'
shell: /bin/bash -l {0}
- name: Check HTTP status code
if: steps.result_cache.outputs.cache-hit != 'true'
uses: nick-fields/retry@v2
with:
command: INPUT_SITES='["http://localhost:4000"]' INPUT_EXPECTED='[200]' ./test/scripts/check_status_code.sh
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
test_linux_zsh:
name: Test Linux script with zsh shell
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,11 +111,50 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
test_macos_zsh:
name: Test macOS script with zsh shell
runs-on: macos-latest
env:
SHELL: /bin/zsh
TZ: America/New_York
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
id: result_cache
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/static/macOS.sh') }}
path: priv/static/macOS.sh
- name: Install shell
if: steps.result_cache.outputs.cache-hit != 'true'
run: brew install zsh
- name: Install expect tool
if: steps.result_cache.outputs.cache-hit != 'true'
run: brew install expect
- name: Test the script
if: steps.result_cache.outputs.cache-hit != 'true'
run: cd test/scripts && expect script.exp macOS.sh
shell: /bin/zsh -l {0}
- name: Generate an app and start the server
if: steps.result_cache.outputs.cache-hit != 'true'
run: /bin/zsh -c 'source ~/.zshrc && make -f test/scripts/Makefile serve'
shell: /bin/zsh -l {0}
- name: Check HTTP status code
if: steps.result_cache.outputs.cache-hit != 'true'
uses: nick-fields/retry@v2
with:
command: INPUT_SITES='["http://localhost:4000"]' INPUT_EXPECTED='[200]' ./test/scripts/check_status_code.sh
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
deploy_preview_app:
name: Deploy preview app
needs:
- test_linux_bash
- test_macos_bash
- test_linux_zsh
- test_macos_zsh
runs-on: ubuntu-latest
permissions: write-all
concurrency:
Expand Down
10 changes: 0 additions & 10 deletions priv/static/Linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,22 @@ function install() {
case "$1" in
"Elixir")
mise use -g elixir@$elixir_version
mise reshim
;;
"Erlang")
if [ ! -f ~/.kerlrc ]; then
echo 'KERL_CONFIGURE_OPTIONS="--without-javac"' >~/.kerlrc
fi
mise use -g erlang@$erlang_version
mise reshim
;;
"mise")
MISE_DEBUG=1 curl https://mise.run | sh
echo -e "\n\n" >>$config_file

case $current_shell in
"bash" | "rbash")
echo "eval \"\$(~/.local/bin/mise activate bash)\"" >>$config_file
echo "eval \"\$(~/.local/bin/mise hook-env -s bash)\"" >>$config_file
eval "$(~/.local/bin/mise activate bash)"
eval "$(~/.local/bin/mise hook-env -s bash)"
;;
"zsh")
echo "eval \"\$(~/.local/bin/mise activate zsh)\"" >>$config_file
echo "eval \"\$(~/.local/bin/mise hook-env -s zsh)\"" >>$config_file
eval "$(~/.local/bin/mise activate zsh)"
eval "$(~/.local/bin/mise hook-env -s zsh)"
;;
esac

Expand All @@ -108,7 +99,6 @@ function install() {
sudo apt-get update
sudo apt-get -y install linux-headers-generic build-essential libssl-dev libreadline-dev zlib1g-dev libcurl4-openssl-dev uuid-dev icu-devtools
mise use -g postgres@$postgres_version
mise reshim
;;
*)
echo "Invalid name argument on install: $1"
Expand Down
18 changes: 1 addition & 17 deletions priv/static/macOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ case $current_shell in
;;
esac

is_interactive_shell() {
case $- in
*i*) return 0 ;;
*) return 1 ;;
esac
}

function already_installed() {
case "$1" in
"Elixir")
Expand Down Expand Up @@ -94,27 +87,18 @@ function install() {
$current_shell -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
;;
"mise")
MISE_DEBUG=1 curl https://mise.run | sh
echo -e "\n\n" >>$config_file

case $current_shell in
"bash" | "rbash")
if is_interactive_shell; then
echo "eval \"\$(~/.local/bin/mise activate bash --shims)\"" >>$config_file
fi

echo "eval \"\$(~/.local/bin/mise activate bash)\"" >>$config_file
;;
"zsh")
if is_interactive_shell; then
echo "eval \"\$(~/.local/bin/mise activate zsh --shims)\"" >>$config_file
fi

echo "eval \"\$(~/.local/bin/mise activate zsh)\"" >>$config_file
;;
esac

. "$config_file"
source $config_file >/dev/null 2>&1
;;
"Phoenix")
mise exec -- mix local.hex --force
Expand Down

0 comments on commit c78c16e

Please sign in to comment.