diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05ab900..85e9cc6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,39 +1,27 @@ -# This workflow will do a clean install of the dependencies and run tests across different versions -# -# Replace with the track name -# Replace with an image to run the jobs on -# Replace with a github action to setup tooling on the image -# Replace with a cli command to install the dependencies -# -# Find Github Actions to setup tooling here: -# - https://github.com/actions/?q=setup&type=&language= -# - https://github.com/actions/starter-workflows/tree/main/ci -# - https://github.com/marketplace?type=actions&query=setup -# -# Requires scripts: -# - bin/verify-exercises - -name: / Test +name: Test on: push: branches: [main] pull_request: + branches: [main] workflow_dispatch: jobs: ci: - runs-on: + runs-on: ubuntu-22.04 steps: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - - name: Use - uses: + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get -y install wget jq coreutils libc-dev binutils - - name: Install project dependencies - run: + - name: Install Roc + run: bin/install-roc - name: Verify all exercises run: bin/verify-exercises diff --git a/bin/install-roc b/bin/install-roc new file mode 100755 index 0000000..35d6d08 --- /dev/null +++ b/bin/install-roc @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Synopsis: +# Install Roc + +# We currently install the nightly version as Roc does not have versioned releases yet. +# Once it does, we will use that. + +function download_nightly() { + local install_dir="${1}" + local install_file="${install_dir}/roc.tar.gz" + local release_url="https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz" + mkdir -p "${install_dir}" + wget -q -O ${install_file} ${release_url} + tar -xzf "${install_file}" -C "${install_dir}" --strip-components 1 + rm -f "${install_file}" +} + +function update_shell { + local install_dir="${1}" + local file="${HOME}/${2}" + + if [[ -f "${file}" ]]; then + echo "export PATH=${install_dir}:\$PATH" >> "${file}" + source "${file}" + fi +} + +install_dir="${HOME}/.roc/bin" + +download_nightly "${install_dir}" + +if [[ -z "${GITHUB_ACTIONS}" ]]; then + update_shell "${install_dir}" ".bashrc" + update_shell "${install_dir}" ".zshrc" +else + echo "${install_dir}" >> "${GITHUB_PATH}" +fi