Browse Source

Add `fnm --version` printing to CI (#248)

remotes/origin/add-with-shims
Gal Schlezinger 5 years ago committed by GitHub
parent
commit
e13c1ef0ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .ci/get_shell_profile.sh
  2. 7
      .ci/install.sh
  3. 28
      .ci/test_installation_script.sh
  4. 14
      .github/workflows/installation_script.yml

6
.ci/get_shell_profile.sh

@ -1,16 +1,14 @@ @@ -1,16 +1,14 @@
#!/bin/bash
OS="$(uname -s)"
case $1 in
"fish")
CONFIG_DIR="$(fish -c 'echo -n $__fish_config_dir')"
echo "${CONFIG_DIR-"$HOME/.config/fish"}/fish.config"
echo "$HOME/.config/fish/config.fish"
;;
"zsh")
echo "$HOME/.zshrc"
;;
"bash")
OS="$(uname -s)"
if [ "$OS" = "Darwin" ]; then
echo "$HOME/.profile"
else

7
.ci/install.sh

@ -4,6 +4,7 @@ set -e @@ -4,6 +4,7 @@ set -e
INSTALL_DIR="$HOME/.fnm"
RELEASE="latest"
OS="$(uname -s)"
# Parse Flags
parse_args() {
@ -39,10 +40,6 @@ parse_args() { @@ -39,10 +40,6 @@ parse_args() {
}
set_filename() {
local OS
OS=$(uname -s)
if [ "$OS" == "Linux" ]; then
FILENAME="fnm-linux"
elif [ "$OS" == "Darwin" ] && [ "$FORCE_INSTALL" == "true" ]; then
@ -77,7 +74,7 @@ download_fnm() { @@ -77,7 +74,7 @@ download_fnm() {
mkdir -p "$INSTALL_DIR" &>/dev/null
if ! curl --progress-bar -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then
if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then
echo "Download failed. Check that the release/filename are correct."
exit 1
fi

28
.ci/test_installation_script.sh

@ -1,21 +1,37 @@ @@ -1,21 +1,37 @@
#!/bin/bash
set -e
DIRECTORY="$(dirname "$0")"
SHELL_TO_RUN="$1"
PROFILE_FILE="$("$DIRECTORY/get_shell_profile.sh" "$SHELL_TO_RUN")"
ls -lah ~
echo "---"
echo "Profile is $PROFILE_FILE"
echo "---"
cat "$PROFILE_FILE"
echo "---"
echo "PATH=$PATH"
echo "---"
$SHELL_TO_RUN -c "
. $PROFILE_FILE
fnm --version
"
$SHELL_TO_RUN -c '
$SHELL_TO_RUN -c "
. $PROFILE_FILE
fnm install 12.5.0
fnm ls | grep 12.5.0
echo "fnm ls worked."
'
echo 'fnm ls worked.'
"
$SHELL_TO_RUN -c '
$SHELL_TO_RUN -c "
. $PROFILE_FILE
fnm use 12.5.0
node --version | grep 12.5.0
echo "node --version worked."
'
echo 'node --version worked.'
"

14
.github/workflows/installation_script.yml

@ -31,8 +31,18 @@ jobs: @@ -31,8 +31,18 @@ jobs:
- run: "brew install ${{ matrix.shell }}"
name: Install ${{matrix.shell}} using Homebrew
if: matrix.setup.os == 'macos'
- run: "cp ~/.bashrc ~/.bashrc.bak && echo '. ~/.bashrc.bak' > ~/.bashrc"
name: reset bashrc file
- run: |
if [ -f ~/.bashrc ]; then
cp ~/.bashrc ~/.bashrc.bak
echo 'echo hello world' > ~/.bashrc
echo '. ~/.bashrc.bak' >> ~/.bashrc
fi
if [ -f ~/.zshrc ]; then
echo 'echo hello world' > ~/.zshrc
echo '. ~/.zshrc.bak' >> ~/.zshrc
fi
name: reset shell profiles
- run: "env SHELL=$(which ${{ matrix.shell }}) bash ./.ci/install.sh ${{ matrix.setup.script_arguments }}"
name: Run the installation script
- run: ./.ci/test_installation_script.sh ${{ matrix.shell }}

Loading…
Cancel
Save