Skip to content

Commit

Permalink
GitHub actions (#5)
Browse files Browse the repository at this point in the history
* Add test via github actions

* Format with shfmt

* Test fix
  • Loading branch information
kosticmarin authored Aug 22, 2023
1 parent e367f4a commit c8a6219
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 30 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ci

on: [push, pull_request]

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: lint
if: matrix.os == 'macOS-latest'
run: |
brew install shfmt shellcheck
shfmt -d .
shellcheck -s sh *.sh
- name: tests shell
if: matrix.os == 'ubuntu-latest'
shell: bash
run: ./install_test.sh

- name: tests powershell
if: matrix.os == 'windows-latest'
shell: powershell
run: ./install_test.ps1

- name: tests powershell core
if: matrix.os == 'windows-latest'
shell: pwsh
run: ./install_test.ps1
4 changes: 3 additions & 1 deletion install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
}

$LunaticInstall = $env::LUNATIC_INSTALL
$LunaticInstall = $env:LUNATIC_INSTALL
Write-Output "HELLO WORLD ${LunaticInstall}"

$BinDir = if ($LunaticInstall) {
"${LunaticInstall}\bin"
} else {
Expand Down
37 changes: 18 additions & 19 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,35 @@
set -e

if ! command -v tar >/dev/null; then
echo "Error: tar is required to install Lunatic Runtime." 1>&2
exit 1
echo "Error: tar is required to install Lunatic Runtime." 1>&2
exit 1
fi

if [ "$OS" = "Windows_NT" ]; then
echo "Error: Official Lunatic Runtime builds for Windows NT are not available." 1>&2
exit 1
target="windows-amd64"
else
case $(uname -sm) in
"Darwin") target="macos-universal" ;;
"Linux aarch64")
echo "Error: Official Lunatic Runtime builds for Linux aarch64 are not available."
exit 1
;;
*) target="linux-amd64" ;;
esac
case $(uname -sm) in
"Darwin") target="macos-universal" ;;
"Linux aarch64")
echo "Error: Official Lunatic Runtime builds for Linux aarch64 are not available."
exit 1
;;
*) target="linux-amd64" ;;
esac
fi

if [ $# -eq 0 ]; then
lunatic_uri="https://github.com/lunatic-solutions/lunatic/releases/latest/download/lunatic-${target}.tar.gz"
lunatic_uri="https://github.com/lunatic-solutions/lunatic/releases/latest/download/lunatic-${target}.tar.gz"
else
lunatic_uri="https://github.com/lunatic-solutions/lunatic/releases/download/${1}/lunatic-${target}.tar.gz"
lunatic_uri="https://github.com/lunatic-solutions/lunatic/releases/download/${1}/lunatic-${target}.tar.gz"
fi

lunatic_install="${LUNATIC_INSTALL:-$HOME/.lunatic}"
bin_dir="$lunatic_install/bin"
exe="$bin_dir/lunatic"

if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
mkdir -p "$bin_dir"
fi

curl --fail --location --progress-bar --output "$exe.tar.gz" "$lunatic_uri"
Expand All @@ -43,16 +42,16 @@ rm "$exe.tar.gz"
echo "Lunatic was installed successfully to $exe"

if command -v lunatic >/dev/null; then
echo "Run 'lunatic --help' to get started"
echo "Run 'lunatic --help' to get started"
else
case $SHELL in
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".bashrc" ;;
esac
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo " export LUNATIC_INSTALL=\"$lunatic_install\""
echo " export PATH=\"\$LUNATIC_INSTALL/bin:\$PATH\""
echo "Run '$exe --help' to get started"
fi
echo
echo "Stuck? Join our Discord https://discord.gg/fZR5wxNp"
echo "Stuck? Join our Discord https://discord.gg/fZR5wxNp"
18 changes: 9 additions & 9 deletions install_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ $v = $null; .\install.ps1
Remove-Item "~\lunatic-0.12.0" -Recurse -Force -ErrorAction SilentlyContinue
$env:LUNATIC_INSTALL = "$Home\lunatic-0.12.0"
$v = "0.12.0"; .\install.ps1
$lunaticVersion = ~\lunatic-0.12.0\bin\lunatic.exe --version
if (!($lunaticVersion -like '*0.12.0*')) {
throw $lunaticVersion
$LunaticVersion = ~\lunatic-0.12.0\bin\lunatic.exe --version
if (!($LunaticVersion -like '*0.12.0*')) {
throw $LunaticVersion
}

# Test that we can install at a relative custom location.
Remove-Item "bin" -Recurse -Force -ErrorAction SilentlyContinue
$env:LUNATIC_INSTALL = "."
$v = "0.12.0"; .\install.ps1
$lunaticVersion = bin\lunatic.exe --version
if (!($lunaticVersion -like '*0.12.0*')) {
throw $lunaticVersion
$LunaticVersion = bin\lunatic.exe --version
if (!($LunaticVersion -like '*0.12.0*')) {
throw $LunaticVersion
}

# Test that the old temp file installer still works.
Remove-Item "~\lunatic-0.12.0" -Recurse -Force -ErrorAction SilentlyContinue
$env:LUNATIC_INSTALL = "$Home\lunatic-0.12.0"
$v = $null; .\install.ps1 v0.12.0
$lunaticVersion = ~\lunatic-0.12.0\bin\lunatic.exe --version
if (!($lunaticVersion -like '*0.12.0*')) {
throw $lunaticVersion
$LunaticVersion = ~\lunatic-0.12.0\bin\lunatic.exe --version
if (!($LunaticVersion -like '*0.12.0*')) {
throw $LunaticVersion
}
2 changes: 1 addition & 1 deletion install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ rm -rf ~/lunatic-0.12.0
export LUNATIC_INSTALL="$HOME/lunatic-0.12.0"
./install.sh v0.12.0
~/lunatic-0.12.0/bin/lunatic --version | grep 0.12.0
rm -rf ~/lunatic-0.12.0
rm -rf ~/lunatic-0.12.0

0 comments on commit c8a6219

Please sign in to comment.