Skip to content

Commit

Permalink
ci: refactor zig installation process
Browse files Browse the repository at this point in the history
  • Loading branch information
ee7 authored and J.R. Hill committed Oct 19, 2022
1 parent 302d7c5 commit 9dfb95f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
32 changes: 32 additions & 0 deletions .github/bin/install-zig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

case "$(uname)" in
Darwin*) os='macos' ;;
Linux*) os='linux' ;;
Windows*) os='windows' ;;
MINGW*) os='windows' ;;
MSYS_NT-*) os='windows' ;;
*) os='linux' ;;
esac

case "${os}" in
windows*) ext='zip' ;;
*) ext='tar.xz' ;;
esac

version='0.8.1'
url="https://ziglang.org/download/${version}/zig-${os}-x86_64-${version}.${ext}"

curlopts=(
--silent
--show-error
--fail
--location
--retry 3
)

file="zig.${ext}"
curl "${curlopts[@]}" --output "${file}" "${url}"
tar xJf "${file}"
mkdir -p "${HOME}/bin"
ln -s "$(pwd)"/zig-*/zig "${HOME}/bin/zig"
29 changes: 7 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,17 @@ on:

jobs:
test-exercises:
name: Check exercises
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

- name: Install Zig
run: |
curl -o zig.tar.xz https://ziglang.org/download/0.8.1/zig-linux-x86_64-0.8.1.tar.xz
tar xJf zig.tar.xz
mkdir -p $HOME/bin
ln -s $(pwd)/zig-*/zig $HOME/bin
- name: Test exercises
run: ./_test/run-tests.sh
test-exercises-mac:
name: Check exercises on mac
runs-on: macos-latest
name: Check exercises (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8

- name: Install Zig
run: |
curl -o zig.tar.xz https://ziglang.org/download/0.8.1/zig-macos-x86_64-0.8.1.tar.xz
tar xJf zig.tar.xz
mkdir -p $HOME/bin
ln -s $(pwd)/zig-*/zig $HOME/bin
run: ./.github/bin/install-zig.sh

- name: Test exercises
run: ./_test/run-tests.sh

0 comments on commit 9dfb95f

Please sign in to comment.