Skip to content

Commit d3a457a

Browse files
authored
ci: migrate from Travis CI to GitHub Actions (#62)
* ci: migrate from Travis CI to GitHub Actions - Travis CI is only _pseudo_-free after the .org -> .com merge - c.f. https://travis-ci.community/t/org-com-migration-unexpectedly-comes-with-a-plan-change-for-oss-what-exactly-is-the-new-deal/10567 - GH Actions are _actually_ free for OSS / public repos - and also offer a decent level of composability that's resulted in a huge surge in reusable community Actions (vs. CircleCI orbs etc haven't had nearly as much adoption) - and I've had a mostly great experience on them so far as well - add a matrix for OSes and different Go versions too - currently only using one Go version (as it was on Travis), but can add more later - currently only testing latest Ubuntu and macOS (as it was on Travis), but can add more versions and OSes later - note that tests fail on Windows right now (due to the shell?) - check for `$RUNNER_OS` instead of `$TRAVIS_OS_NAME` now - c.f. https://docs.github.com/en/actions/learn-github-actions/environment-variables - update the commented out "Debug" step to conditionally run on macOS as well * fix: make get_docopts work on macOS - tests failing on macOS b/c `sha256sum` doesn't exist - only use the third arg in the workaround as it doesn't support flags * run on PRs as well
1 parent 2b51559 commit d3a457a

4 files changed

Lines changed: 49 additions & 41 deletions

File tree

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches: [master]
5+
push:
6+
branches: [docopts-go, master]
7+
8+
jobs:
9+
ci:
10+
name: CI - Go ${{ matrix.go-version }}, ${{ matrix.os }}
11+
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
go-version: ["1.14"]
16+
os: [ubuntu-latest, macOS-latest]
17+
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v3
21+
- name: Setup Go ${{ matrix.go-version }}
22+
uses: actions/setup-go@v3
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
# cache: true # TODO: cache needs path to go.sum per https://github.com/actions/setup-go#caching-dependency-files-and-build-outputs
26+
- name: Install
27+
run: |
28+
bash --version ; type bash
29+
# hack for speedup on mac build with our own bash5
30+
./travis/get_bash5_macos.sh
31+
./travis/get_bats-core.sh
32+
go get github.com/docopt/docopt-go
33+
# get our official repos too
34+
go get github.com/docopt/docopts
35+
- name: Test
36+
run: make test
37+
38+
# For debugging, create reverse SSH tunnel (this should be run on failure too)
39+
# - name: Debug
40+
# if: runner.os == "macOS"
41+
# run: bash -x ./travis/reverse_ssh_tunnel.sh

.travis.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

get_docopts.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ URL="$BASE_URL/$RELEASE/$BINARY_DOWNLOAD"
100100

101101
echo "Fetching from: $URL"
102102

103+
if [[ "$OS_URL" == "darwin" ]]; then
104+
# sha256sum doesn't exist on macOS, workaround: https://unix.stackexchange.com/a/426838/152866
105+
function sha256sum() { openssl sha256 "$2" | awk '{print $2}'; }
106+
fi
107+
103108
# verification
104109
if wget -O $BINARY_DOWNLOAD "$URL" ; then
105110
file $BINARY_DOWNLOAD

travis/get_bash5_macos.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44
#
55
# Our hack for macos bash version too old for unit testing
66

7-
# was in .travis.yml
87
# brew update takes very long time
9-
# according to https://docs.travis-ci.com/user/reference/osx#homebrew
108
# homebrew is already updated, but it's still really slow
11-
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
12-
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install bash; fi
9+
#- if [[ "$RUNNER_OS" == "macOS" ]]; then brew update ; fi
10+
#- if [[ "$RUNNER_OS" == "macOS" ]]; then brew install bash; fi
1311

1412
pathshow ()
1513
{
1614
local var=${1:-PATH};
1715
eval "echo \$$var | tr : $'\n'"
1816
}
1917

20-
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
18+
if [[ "$RUNNER_OS" == "macOS" ]]; then
2119
if ((BASH_VERSINFO[0] <= 3)) ; then
2220

2321
# The following hack kept a bash5 binary in our repository

0 commit comments

Comments
 (0)