Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
ci: use GitHub actions
Browse files Browse the repository at this point in the history
Fix up tests etc whilst we are at it
  • Loading branch information
myitcv committed Apr 7, 2020
1 parent f2461c8 commit 49dc232
Show file tree
Hide file tree
Showing 14 changed files with 245 additions and 210 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on:
push:
branches:
- master
pull_request:
branches:
- '**'

env:
GOPROXY: https://proxy.golang.org

# At the time of writing (2020-04-07) the default git config
# on action runners includes core.autocrlf=true. Therefore we
# override that below before checkout out the code.
#
# See also https://github.com/actions/checkout/issues/135

name: Test
jobs:
test:
strategy:
fail-fast: false
matrix:
go-version: [1.13.9, 1.14.1]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@9fbc767707c286e568c92927bbf57d76b73e0892
with:
go-version: ${{ matrix.go-version }}
- name: Fix git config
run: git config --global core.autocrlf false
- run: mkdir -p gopath/src/github.com/myitcv/gobin
- name: Checkout code
uses: actions/checkout@01aecccf739ca6ff86c0539fbc67a7a5007bbc81
with:
path: gopath/src/github.com/myitcv/gobin
- name: Test
run: go test ./...
working-directory: gopath/src/github.com/myitcv/gobin
- name: Adjust GOPATH for non-module install
run: echo "::set-env name=GOPATH::$PWD/gopath"
- name: Adjust GO111MODULE for non-module install
run: echo "::set-env name=GO111MODULE::off"
- run: go env
working-directory: gopath/src/github.com/myitcv/gobin
- run: go list
working-directory: gopath/src/github.com/myitcv/gobin
- name: Non-module install test
run: go install
working-directory: gopath/src/github.com/myitcv/gobin
32 changes: 32 additions & 0 deletions .github/workflows/verify_commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
branches:
- master
pull_request:
branches:
- '**'

env:
GOPROXY: https://proxy.golang.org

name: Verify commit is clean
jobs:
test:
strategy:
fail-fast: false
matrix:
go-version: [1.14.1]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@9fbc767707c286e568c92927bbf57d76b73e0892
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@01aecccf739ca6ff86c0539fbc67a7a5007bbc81
- run: go mod vendor
- run: go mod tidy
- name: Check git is clean
run: test -z "$(git status --porcelain)" || (git status; git diff; false)

74 changes: 0 additions & 74 deletions .travis.yml

This file was deleted.

29 changes: 0 additions & 29 deletions _scripts/apply_known_diffs.sh

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions _scripts/known_diffs/go1.12.9/badly_sorted_vendor_modules.txt.diff

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/myitcv/gobin

require github.com/rogpeppe/go-internal v1.3.1
require github.com/rogpeppe/go-internal v1.5.2

go 1.11
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/rogpeppe/go-internal v1.3.1 h1:pgz0lCb+F99TrCwoy7d83j5kI//45fBQ34KzZ7t5as0=
github.com/rogpeppe/go-internal v1.3.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.5.2 h1:qLvObTrvO/XRCqmkKxUlOBc48bI3efyDuAZe25QiF0w=
github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,15 @@ func getGoEnv() (goEnv, error) {
}
}
{
// Create a temp dir that is not a module for the simple
// results we need from a go list of runtime
td, err := ioutil.TempDir("", "gobin-release-tags-")
if err != nil {
return goEnv{}, fmt.Errorf("failed to create temp dir for release tags derivation: %v", err)
}
defer os.RemoveAll(td)
cmd := exec.Command("go", "list", `-f={{join context.ReleaseTags "\n"}}`, "runtime")
cmd.Dir = td
out, err := cmd.CombinedOutput()
if err != nil {
return goEnv{}, fmt.Errorf("failed to get release tags: %v\n%s", err, out)
Expand Down
9 changes: 7 additions & 2 deletions script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ func TestExitCode(t *testing.T) {
"GONOSUMDB=*",
"GOPROXY="+proxyURL,
"TESTSCRIPT_COMMAND=gobin",

// We zero GOPATH here so that we definitely use the default
// location of $HOME (with the new $HOME)
"GOPATH=",
)

err = cmd.Run()
out, err := cmd.CombinedOutput()
fmt.Printf(">> %s\n", out)
if err == nil {
t.Fatalf("unexpected success")
}
Expand All @@ -72,7 +77,7 @@ func TestExitCode(t *testing.T) {
}
want := 42
if got := ExitCode(ee.ProcessState); want != got {
t.Fatalf("expected exit code %v; got %v", want, got)
t.Fatalf("expected exit code %v; got %v; output was: %s", want, got, out)
}
}

Expand Down
3 changes: 2 additions & 1 deletion testdata/mod_readonly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ cd repo
! stdout .+
[go1.11] [!go1.12] stderr 'import lookup disabled by -mod=readonly'
[go1.12] [!go1.13] stderr 'can''t load package: package github.com/gobin-testrepos/simple-main: unknown import path "github.com/gobin-testrepos/simple-main": import lookup disabled by -mod=readonly'
[go1.13] stderr 'can''t load package: package github\.com/gobin-testrepos/simple-main: import lookup disabled by -mod=readonly'
[go1.13] [!go1.14] stderr 'updates to go.mod needed, disabled by -mod=readonly'
[go1.14] stderr 'cannot find module providing package github\.com/gobin-testrepos/simple-main: import lookup disabled by -mod=readonly'

-- repo/go.mod --
module example.com/repo
26 changes: 12 additions & 14 deletions vendor/github.com/rogpeppe/go-internal/testscript/cmd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 49dc232

Please sign in to comment.