From 116ce4153a97c9443c492e2b9dd46d5a95b2d80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=AD=90=E7=AF=86?= Date: Thu, 30 Apr 2020 09:25:01 +0800 Subject: [PATCH] CI: switch to GitHub Action (#142) * Create go.yml * ignore windows crlf problem * remove travis * coverage CI * fix coverage * rename jobs * coverage * fix name * maybe don't need get dependencies? * goveralls * manual setup goveralls * linter * get tools * fix path --- .github/workflows/go.yml | 64 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 26 ---------------- 2 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/go.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 00000000..34ddd66b --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,64 @@ +name: Go + +on: + - push + - pull_request + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Run linters + run: | + GO111MODULE=off go get golang.org/x/lint/golint + GO111MODULE=off go get github.com/mgechev/revive + echo "### revive" + $(go env GOPATH)/bin/revive -config .revive.toml ./... + echo "### golint" + $(go env GOPATH)/bin/golint ./... + exit 0 + test: + name: Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + go-version: [1.12, 1.13, 1.14] + steps: + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: Get dependencies + run: | + go get -t ./... + - name: Go Test + run: go test ./... + - name: Go Race Test + run: go test -race ./... + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - name: Install Go + if: success() + uses: actions/setup-go@v1 + with: + go-version: 1.13 + - name: Checkout code + uses: actions/checkout@v2 + - name: Calculate coverage + run: | + go test -v -covermode=count -coverprofile=coverage.out ./... + - name: Coveralls + env: + COVERALLS_TOKEN: "YZKB1SLTzPJMOdXp5U3xwEsh4++Xe8EeVK8SZVEQkn/y4xCbzmbdo6BJ4B/eGBG6bK4DLzFD3sb6uaUB2bHlVUXnR8YHbetjps6PUwLYtX9UdcBjB7UN5tdQs1d8k2qg7vPNtKVEY4kJHFURijc4Kk+zlNbq1oGJcEfm6gz+zGg=" + run: | + GO111MODULE=off go get github.com/mattn/goveralls + $(go env GOPATH)/bin/goveralls -coverprofile=coverage.out -service=github diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 19a26d97..00000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: go - -go: - - "1.12" - - tip - -notifications: - email: false - -env: - global: - # Coveralls.io token. - - secure: "YZKB1SLTzPJMOdXp5U3xwEsh4++Xe8EeVK8SZVEQkn/y4xCbzmbdo6BJ4B/eGBG6bK4DLzFD3sb6uaUB2bHlVUXnR8YHbetjps6PUwLYtX9UdcBjB7UN5tdQs1d8k2qg7vPNtKVEY4kJHFURijc4Kk+zlNbq1oGJcEfm6gz+zGg=" - -install: - - go get -t ./... - -before_script: - - wget https://github.com/mewmew/ci/raw/master/get_tools.sh - - chmod +x get_tools.sh - - ./get_tools.sh - - wget https://github.com/mewmew/ci/raw/master/ci_checks.sh - - chmod +x ci_checks.sh - -script: - - ./ci_checks.sh