summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Turner <jt@jtnet.co.uk>2020-02-04 20:29:50 +0000
committerJonathan Turner <jt@jtnet.co.uk>2020-02-04 20:29:50 +0000
commit522698a21dfbcf6420fe2354b6e8072632db545c (patch)
treef466f310bb609412ce70606dfd47cee1c3dee134
parentb01fc342e21237de07bdcd890edc29783401ec7a (diff)
test by actions
-rw-r--r--.github/workflows/testing.yml67
-rw-r--r--.github/workflows/testingv2.yml53
2 files changed, 120 insertions, 0 deletions
diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml
new file mode 100644
index 0000000..46478fa
--- /dev/null
+++ b/.github/workflows/testing.yml
@@ -0,0 +1,67 @@
+name: v1
+on:
+ push:
+ paths-ignore:
+ - 'v[0-9]+/**'
+ pull_request:
+ paths-ignore:
+ - 'v[0-9]+/**'
+
+jobs:
+ build:
+ name: Tests
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ go: [ '1.11.x', '1.12.x', '1.13.x' ]
+ steps:
+ - name: Set up Go ${{ matrix.go }}
+ uses: actions/setup-go@v1
+ with:
+ go-version: ${{ matrix.go }}
+
+ - name: Checkout
+ uses: actions/checkout@v2
+ with:
+ ref: ${{ github.ref }}
+
+ - name: Test well formatted with gofmt
+ run: |
+ # Remove major version sub directories
+ find . -maxdepth 1 -type d -regex '\./v[0-9]+' | xargs -i rm -rf {}
+ GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/)
+ test -z $(gofmt -s -d -l -e $GO_FILES | tee /dev/fd/2 | xargs | sed 's/\s//g')
+ id: gofmt
+
+ - name: Copy into GOPATH
+ run: |
+ # Default GOPATH=${HOME}/go
+ mkdir -p ${HOME}/go/src/github.com/${GITHUB_REPOSITORY}
+ cp -r $GITHUB_WORKSPACE/* /home/runner/go/src/github.com/${GITHUB_REPOSITORY}
+ id: copyToGOPATH
+
+ - name: Get dependencies
+ run: |
+ cd ${HOME}/go/src/github.com/${GITHUB_REPOSITORY}
+ go get -v -t -d ./...
+ id: goGet
+
+ - name: Go vet
+ run: |
+ cd ${HOME}/go/src/github.com/${GITHUB_REPOSITORY}
+ go vet $(go list ./... | grep -E -v '/v[0-9]+' | grep -v /vendor/)
+ id: govet
+
+ - name: Unit tests
+ run: |
+ cd ${HOME}/go/src/github.com/${GITHUB_REPOSITORY}
+ go test -race $(go list ./... | grep -E -v '/v[0-9]+' | grep -v /vendor/)
+ id: unitTests
+
+ - name: Unit tests (32bit)
+ run: |
+ cd ${HOME}/go/src/github.com/${GITHUB_REPOSITORY}
+ go test $(go list ./... | grep -E -v '/v[0-9]+' | grep -v /vendor/)
+ env:
+ GOARCH: 386
+ id: unitTest32 \ No newline at end of file
diff --git a/.github/workflows/testingv2.yml b/.github/workflows/testingv2.yml
new file mode 100644
index 0000000..ec65a3e
--- /dev/null
+++ b/.github/workflows/testingv2.yml
@@ -0,0 +1,53 @@
+# Name of the workflow needs to match the name of the major version directory
+name: v2
+on:
+ push:
+ paths:
+ - 'v2/**'
+ pull_request:
+ paths:
+ - 'v2/**'
+
+jobs:
+ build:
+ name: Tests
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ go: [ '1.11.x', '1.12.x', '1.13.x' ]
+ steps:
+ - name: Set up Go ${{ matrix.go }}
+ uses: actions/setup-go@v1
+ with:
+ go-version: ${{ matrix.go }}
+
+ - name: Checkout
+ uses: actions/checkout@v2
+ with:
+ ref: ${{ github.ref }}
+
+ - name: Test well formatted with gofmt
+ run: |
+ GO_FILES=$(find ${GITHUB_WORKFLOW} -iname '*.go' -type f | grep -v /vendor/)
+ test -z $(gofmt -s -d -l -e $GO_FILES | tee /dev/fd/2 | xargs | sed 's/\s//g')
+ id: gofmt
+
+ - name: Go vet
+ run: |
+ cd ${GITHUB_WORKFLOW}
+ go vet ./...
+ id: govet
+
+ - name: Unit tests
+ run: |
+ cd ${GITHUB_WORKFLOW}
+ go test -race ./...
+ id: unitTests
+
+ - name: Unit tests (32bit)
+ run: |
+ cd ${GITHUB_WORKFLOW}
+ go test ./...
+ env:
+ GOARCH: 386
+ id: unitTest32 \ No newline at end of file