From 5c76261bfd00e0d28519adcae85983517ba7aa56 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Fri, 1 Nov 2019 19:18:03 -0700 Subject: [PATCH] github actions: cache go modules; disable travis This is mostly an experiment, but I think it will work well. GitHub Actions provides MacOS and Windows builds (though I'm only adding in Windows at the moment), and cleaner integration. Builds also seem to be completing faster than Travis. --- .github/workflows/test.yml | 18 ----------- .github/workflows/tests.yml | 62 +++++++++++++++++++++++++++++++++++++ .travis.yml | 24 -------------- README.md | 2 +- 4 files changed, 63 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/test.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index f0e64f8..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,18 +0,0 @@ -on: [push, pull_request] -name: Test -jobs: - test: - strategy: - matrix: - go-version: [1.12.x, 1.13.x] - platform: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.platform }} - steps: - - name: Install Go - uses: actions/setup-go@v1 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v1 - - name: Test - run: go test ./... diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..2842f57 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,62 @@ +on: [push, pull_request] +name: tests +env: + GO111MODULE: on + +jobs: + test: + strategy: + matrix: + go-version: [1.12.x, 1.13.x] + platform: [ubuntu-latest] + runs-on: ${{ matrix.platform }} + + steps: + - uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v1 + + - name: Cache go modules + uses: actions/cache@preview + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Run go fmt + run: diff -u <(echo -n) <(gofmt -d -s .) + + - name: Run go vet + run: go vet ./... + + - name: Run go test + run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1.0.3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + # On Windows, just run the local tests. Don't bother with checking gofmt, go + # vet, or uploading results to Codecov + test-windows: + strategy: + matrix: + go-version: [1.12.x, 1.13.x] + platform: [windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v1 + - name: Cache go modules + uses: actions/cache@preview + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**\go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - run: go test ./... diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7d04822..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: go - -go: - - "1.x" - - "1.11.x" - -go_import_path: willnorris.com/go/imageproxy - -cache: - directories: - - $HOME/.cache/go-build - - $HOME/gopath/pkg/mod - -env: - global: - - GO111MODULE=on - -script: - - diff -u <(echo -n) <(gofmt -d -s .) - - go vet ./... - - go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index b2cad49..a91f746 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # imageproxy [![GoDoc](https://godoc.org/willnorris.com/go/imageproxy?status.svg)](https://godoc.org/willnorris.com/go/imageproxy) -[![Build Status](https://travis-ci.org/willnorris/imageproxy.svg?branch=master)](https://travis-ci.org/willnorris/imageproxy) +[![Test Status](https://github.com/willnorris/imageproxy/workflows/tests/badge.svg)](https://github.com/willnorris/imageproxy/actions?query=workflow%3Atests) [![Test Coverage](https://codecov.io/gh/willnorris/imageproxy/branch/master/graph/badge.svg)](https://codecov.io/gh/willnorris/imageproxy) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/2611/badge)](https://bestpractices.coreinfrastructure.org/projects/2611)