Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 55 additions & 25 deletions .github/github_workflows.ex
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,19 @@ defmodule GithubWorkflows do
{:"test_linux_#{shell}", test_linux_script_job(shell)},
{:"test_macos_#{shell}", test_macos_script_job(shell)}
]
end)
end) ++
[
{:test_wsl, test_wsl_script_job()}
]
end

defp test_shell_script_job(opts) do
os = Keyword.fetch!(opts, :os)
runs_on = Keyword.fetch!(opts, :runs_on)
shell = Keyword.fetch!(opts, :shell)
shell_install_command = Keyword.fetch!(opts, :shell_install_command)
expect_install_command = Keyword.fetch!(opts, :expect_install_command)
shell_install_command = Keyword.get(opts, :shell_install_command)
expect_install_command = Keyword.get(opts, :expect_install_command)
setup = Keyword.get(opts, :setup, [])

[
name: "Test #{os} script with #{shell} shell",
Expand All @@ -396,20 +400,21 @@ defmodule GithubWorkflows do
TZ: "America/New_York"
],
steps:
[
checkout_step(),
[checkout_step()] ++
setup ++
[
name: "Restore script result cache",
uses: "actions/cache@v3",
id: "result_cache",
with: [
key:
"${{ runner.os }}-#{shell}-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}",
path: "priv/script.sh"
[
name: "Restore script result cache",
uses: "actions/cache@v3",
id: "result_cache",
with: [
key:
"${{ runner.os }}-#{shell}-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}",
path: "priv/script.sh"
]
]
]
] ++
if(shell == "bash",
] ++
if(String.contains?(shell, "bash"),
do: [],
else: [
[
Expand All @@ -419,26 +424,31 @@ defmodule GithubWorkflows do
]
]
) ++
if(os == "Linux",
do: [],
else: [
if(os == "macOS",
do: [
[
name: "Disable password prompt for macOS",
if: "steps.result_cache.outputs.cache-hit != 'true'",
run:
~S<sudo sed -i "" "s/%admin ALL = (ALL) ALL/%admin ALL = (ALL) NOPASSWD: ALL/g" /etc/sudoers>
]
]
],
else: []
) ++
[
[
name: "Install expect tool",
if: "steps.result_cache.outputs.cache-hit != 'true'",
run: expect_install_command
if(expect_install_command,
do: [
[
name: "Install expect tool",
if: "steps.result_cache.outputs.cache-hit != 'true'",
run: expect_install_command
]
],
else: []
) ++
[
[
name: "Remove mise config files",
run: "rm -f .mise.toml .tool-versions"
run: "#{if(os == "WSL", do: "wsl ", else: "")}rm -f .mise.toml .tool-versions"
],
[
name: "Test the script",
Expand Down Expand Up @@ -488,6 +498,26 @@ defmodule GithubWorkflows do
)
end

defp test_wsl_script_job do
test_shell_script_job(
os: "WSL",
runs_on: "windows-latest",
shell: "wsl-bash",
setup: [
[
name: "Setup WSL",
uses: "Vampire/setup-wsl@v3",
with: [
distribution: "Ubuntu-22.04",
additional_packages: "expect",
wsl_shell_user: "root",
update: true
]
]
]
)
end

defp unused_deps_job do
elixir_job("Check unused deps",
needs: :compile,
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,46 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
test_wsl:
name: Test WSL script with wsl-bash shell
runs-on: windows-latest
env:
SHELL: wsl-bash
TZ: America/New_York
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup WSL
uses: Vampire/setup-wsl@v3
with:
distribution: Ubuntu-22.04
additional_packages: expect
wsl_shell_user: root
update: true
- name: Restore script result cache
uses: actions/cache@v3
id: result_cache
with:
key: ${{ runner.os }}-wsl-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
- name: Remove mise config files
run: wsl rm -f .mise.toml .tool-versions
- name: Test the script
if: steps.result_cache.outputs.cache-hit != 'true'
run: cd test/scripts && expect script.exp
shell: wsl-bash -l {0}
- name: Generate an app and start the server
if: steps.result_cache.outputs.cache-hit != 'true'
run: make -f test/scripts/Makefile serve
shell: wsl-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
deploy_production_app:
name: Deploy production app
needs:
Expand All @@ -518,6 +558,7 @@ jobs:
- test_macos_fish
- test_linux_zsh
- test_macos_zsh
- test_wsl
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,46 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
test_wsl:
name: Test WSL script with wsl-bash shell
runs-on: windows-latest
env:
SHELL: wsl-bash
TZ: America/New_York
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup WSL
uses: Vampire/setup-wsl@v3
with:
distribution: Ubuntu-22.04
additional_packages: expect
wsl_shell_user: root
update: true
- name: Restore script result cache
uses: actions/cache@v3
id: result_cache
with:
key: ${{ runner.os }}-wsl-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
- name: Remove mise config files
run: wsl rm -f .mise.toml .tool-versions
- name: Test the script
if: steps.result_cache.outputs.cache-hit != 'true'
run: cd test/scripts && expect script.exp
shell: wsl-bash -l {0}
- name: Generate an app and start the server
if: steps.result_cache.outputs.cache-hit != 'true'
run: make -f test/scripts/Makefile serve
shell: wsl-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
deploy_preview_app:
name: Deploy preview app
needs:
Expand All @@ -522,6 +562,7 @@ jobs:
- test_macos_fish
- test_linux_zsh
- test_macos_zsh
- test_wsl
runs-on: ubuntu-latest
permissions: write-all
concurrency:
Expand Down
Loading