From b34a9a6cd3c449d49db935af47c3f352c79f5051 Mon Sep 17 00:00:00 2001 From: Gal Schlezinger Date: Thu, 1 Oct 2020 05:54:14 -0700 Subject: [PATCH] Add installation script testing (#243) --- .ci/install.sh | 12 ++++ .github/workflows/installation_script.yml | 81 +++++++++++++++++++++++ .github/workflows/refmt.yml | 6 +- 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/installation_script.yml diff --git a/.ci/install.sh b/.ci/install.sh index c2e6c22..944850e 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -109,11 +109,21 @@ check_dependencies() { fi } +ensure_containing_dir_exists() { + local CONTAINING_DIR + CONTAINING_DIR="$(dirname "$1")" + if [ ! -d "$CONTAINING_DIR" ]; then + echo " >> Creating directory $CONTAINING_DIR" + mkdir -p "$CONTAINING_DIR" + fi +} + setup_shell() { CURRENT_SHELL=$(basename $SHELL) if [ "$CURRENT_SHELL" == "zsh" ]; then CONF_FILE=$HOME/.zshrc + ensure_containing_dir_exists "$CONF_FILE" echo "Installing for Zsh. Appending the following to $CONF_FILE:" echo "" echo ' # fnm' @@ -127,6 +137,7 @@ setup_shell() { elif [ "$CURRENT_SHELL" == "fish" ]; then CONF_FILE=$HOME/.config/fish/config.fish + ensure_containing_dir_exists "$CONF_FILE" echo "Installing for Fish. Appending the following to $CONF_FILE:" echo "" echo ' # fnm' @@ -144,6 +155,7 @@ setup_shell() { else CONF_FILE=$HOME/.bashrc fi + ensure_containing_dir_exists "$CONF_FILE" echo "Installing for Bash. Appending the following to $CONF_FILE:" echo "" echo ' # fnm' diff --git a/.github/workflows/installation_script.yml b/.github/workflows/installation_script.yml new file mode 100644 index 0000000..1099e5f --- /dev/null +++ b/.github/workflows/installation_script.yml @@ -0,0 +1,81 @@ +name: Installation script +on: + pull_request: + push: + branches: + - master + +jobs: + install_on_linux: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - shell: fish + source: ~/.config/fish/config.fish + - shell: zsh + source: ~/.zshrc + - shell: bash + source: ~/.bashrc + steps: + - uses: actions/checkout@v2 + - run: "sudo apt-get install -y ${{ matrix.shell }}" + name: Install shell + - run: "cp ~/.bashrc ~/.bashrc.bak && echo '. ~/.bashrc.bak' > ~/.bashrc" + name: reset bashrc file + - run: "env SHELL=$(which ${{ matrix.shell }}) bash ./.ci/install.sh" + name: Run the installation script + + - run: | + ${{ matrix.shell }} -c ' + source ${{ matrix.source }} + fnm install 12.5.0 + fnm ls | grep 12.5.0 + ' + name: 'Install a Node version with `fnm install`' + + - run: | + ${{ matrix.shell }} -c ' + source ${{ matrix.source }} + fnm use 12.5.0 + node --version | grep 12.5.0 + ' + name: 'Check switching versions with `fnm use`' + + install_on_mac: + runs-on: macos-latest + strategy: + matrix: + include: + - shell: fish + source: ~/.config/fish/config.fish + - shell: zsh + source: ~/.zshrc + - shell: bash + source: ~/.bashrc + steps: + - uses: actions/checkout@v2 + - run: "brew install ${{ matrix.shell }}" + name: Install shell + - name: reset bashrc file + run: | + cp ~/.bashrc ~/.bashrc.bak + echo '. ~/.bashrc.bak' > ~/.bashrc + - run: "env SHELL=$(which ${{ matrix.shell }}) bash ./.ci/install.sh --force-install" + name: Run the installation script + + - name: 'Install a Node version with `fnm install`' + run: | + ${{ matrix.shell }} -c ' + source ${{ matrix.source }} + fnm install 12.5.0 + fnm ls | grep 12.5.0 + ' + + - name: 'Check switching versions with `fnm use`' + run: | + ${{ matrix.shell }} -c ' + source ${{ matrix.source }} + fnm use 12.5.0 + node --version | grep 12.5.0 + ' diff --git a/.github/workflows/refmt.yml b/.github/workflows/refmt.yml index 0646841..76cb551 100644 --- a/.github/workflows/refmt.yml +++ b/.github/workflows/refmt.yml @@ -1,5 +1,9 @@ name: Check formatting -on: [push, pull_request] +on: + pull_request: + push: + branches: + - master # consider using docker: ocaml/opam2:4.06 # - sudo apt-get update && apt-get install -y m4