Skip to content

Commit

Permalink
try correction for docopt#44 and travis for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Viart committed Apr 1, 2020
1 parent 489ab2a commit f9f7460
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 28 deletions.
17 changes: 14 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ language: go
os:
- linux
- osx

go:
- "1.11.4"
# - "1.13"
#- "1.11.4"
- "1.14"

# speed up macos brew
# https://stackoverflow.com/questions/39930171/cache-brew-builds-with-travis-ci
cache:
directories:
- $HOME/Library/Caches/Homebrew

before_install:
# brew update takes very long time
# according to https://docs.travis-ci.com/user/reference/osx#homebrew
Expand All @@ -15,13 +23,16 @@ before_install:
- go get github.com/docopt/docopt-go
# get our official repos too
- go get github.com/docopt/docopts

branches:
only:
- docopts-go
- master

notifications:
email:
on_success: never

script:
- make test
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then bash -x ./travis/reverse_ssh_tunnel.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then bash -x ./travis/reverse_ssh_tunnel.sh ; fi
57 changes: 37 additions & 20 deletions get_docopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,25 @@ then
exit 1
fi

case $OSTYPE in
darwin*)
echo "I'm on macos"
# fix bug https://github.com/docopt/docopts/issues/44
ARCH=$(uname -m)
OS_URL=darwin
;;
linux*)
echo "I'm on linux"
OS_URL=linux
ARCH=$(arch)
;;
*)
report_issue
exit 1
;;
esac

# try to detect CPU architecture
ARCH=$(arch)
case $ARCH in
x86_64)
echo "I'm 64-bits"
Expand All @@ -75,29 +92,29 @@ case $ARCH in
;;
esac


case $OSTYPE in
darwin*)
echo "I'm on macos"
URL="$BASE_URL/$RELEASE/${BINARY}_darwin_${ARCH_BIN}"
;;
linux*)
echo "I'm on linux"
URL="$BASE_URL/$RELEASE/${BINARY}_linux_${ARCH_BIN}"
;;
*)
report_issue
exit 1
;;
esac
# result
BINARY_DOWNLOAD=${BINARY}_${OS_URL}_${ARCH_BIN}
URL="$BASE_URL/$RELEASE/$BINARY_DOWNLOAD"

echo "Fetching from: $URL"
if wget -O $BINARY "$URL" ; then
file $BINARY
chmod a+x $BINARY

# verification
if wget "$URL" ; then
file $BINARY_DOWNLOAD
chmod a+x $BINARY_DOWNLOAD

URL_SHA="$BASE_URL/$RELEASE/sha256sum.txt"
sha_file=$(mktemp)
echo "verifying sha256sum signature from $URL_SHA ..."
wget -O $sha_file --quiet "$URL_SHA"
sha256sum --ignore-missing -c $sha_file
rm $sha_file

echo "renaming $BINARY_DOWNLOAD to $BINARY"
mv $BINARY_DOWNLOAD $BINARY
else
echo "download failure"
rm $BINARY
rm $BINARY_DOWNLOAD
report_issue
exit 1
fi
13 changes: 12 additions & 1 deletion tests/get_doctops.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# go to repository basepath
cd ..
[[ -x docopts ]] && rm docopts
unset GIT_USER
unset RELEASE
run ./get_docopts.sh
echo "$output"
[[ $status -eq 0 ]]
Expand All @@ -23,7 +25,6 @@
[[ $output =~ $version ]]
}


@test "get_docopts.sh use another repository" {
# go to repository basepath
cd ..
Expand All @@ -44,3 +45,13 @@
version='v0.6.4-alpha1'
[[ $output =~ $version ]]
}

@test "arch 64bits detection on macos" {
if [[ $OSTYPE =~ ^darwin.* ]] ; then
echo "checking"


else
skip "only on macos, this OS is: $OSTYPE"
fi
}
12 changes: 8 additions & 4 deletions travis/reverse_ssh_tunnel.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/usr/bin/env bash
#
# Usage: a bounce host MUST be set before!
# ansible playbook not provided yet.

set -euo pipefail

# Usage: a bounce host must be set before
# ansible playbook not provided yet.
###################################################################### Config

# The IP here is a temporay public cloud VM
# You need to edit that IP
BOUNCEHOSTIP="51.83.248.111"
# You MUST to edit that IP:
BOUNCEHOSTIP="51.83.254.145"

###################################################################### Code

# Where to store localy the remote bounce host ssh key
TEMP_SSH_KEYS=/tmp/$USER-bounce-travis/id_rsa
Expand Down

0 comments on commit f9f7460

Please sign in to comment.