From a9dcf4ce743df40c03c0e7ae239a5f5d060d1f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=9C=C9=B4=E1=B4=8B=C9=B4=E1=B4=A1=E1=B4=8F=C9=B4?= Date: Fri, 27 Mar 2020 22:06:29 +0800 Subject: [PATCH] github: use Actions for CI (#6022) * Update golint.yml * Update README.md * Update README.md * Update golint.yml * Update golint.yml * Rename golint.yml to go.yml * Update go.yml * Update go.yml * Update go.yml * Improve tests on Windows * Delete files --- .github/workflows/go.yml | 46 ++++++++++++++++++++++++++++++++++++ .github/workflows/golint.yml | 9 ------- .travis.yml | 18 -------------- README.md | 2 +- appveyor.yml | 20 ---------------- internal/conf/conf_test.go | 4 ---- internal/testutil/golden.go | 7 +++++- 7 files changed, 53 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/go.yml delete mode 100644 .github/workflows/golint.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 000000000..6f2013274 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,46 @@ +name: Go +on: + push: + branches: [master] + pull_request: +env: + GOPROXY: "https://proxy.golang.org" + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run golangci-lint + uses: actions-contrib/golangci-lint@v1 + + test: + name: Test + strategy: + matrix: + go-version: [1.13.x, 1.14.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@v2 + - name: Run unit tests + run: go test -v -race -coverprofile=coverage -covermode=atomic ./... + - name: Upload coverage report to Codecov + uses: codecov/codecov-action@v1.0.6 + with: + file: ./coverage + flags: unittests + - name: Cache downloaded modules + uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + diff --git a/.github/workflows/golint.yml b/.github/workflows/golint.yml deleted file mode 100644 index 3ed0217cb..000000000 --- a/.github/workflows/golint.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: golint -on: [pull_request] -jobs: - golint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Run golangci-lint - uses: actions-contrib/golangci-lint@v1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 85d436958..000000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: go -os: linux -dist: xenial -go: - - 1.13.x - - 1.14.x -go_import_path: gogs.io/gogs -env: - - GO111MODULE=on -before_install: - - sudo apt-get update -qq - - sudo apt-get install -y libpam-dev -script: - - go vet ./... - - go build -v -tags "pam" - - 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 d1cb2d932..5072dfb55 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Gogs - A painless self-hosted Git service -[![Build status](https://img.shields.io/travis/gogs/gogs/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/gogs/gogs) [![Build status](https://img.shields.io/appveyor/ci/Unknwon/gogs?logo=appveyor&style=for-the-badge)](https://ci.appveyor.com/project/Unknwon/gogs/branch/master) [![Discord](https://img.shields.io/discord/382595433060499458.svg?style=for-the-badge&logo=discord)](https://discord.gg/9aqdHU7) [![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/gogs/gogs) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/gogs/gogs/Go?logo=github&style=for-the-badge)](https://github.com/gogs/gogs/actions?query=workflow%3AGo) [![Build status](https://img.shields.io/appveyor/ci/Unknwon/gogs?logo=appveyor&style=for-the-badge)](https://ci.appveyor.com/project/Unknwon/gogs/branch/master) [![Discord](https://img.shields.io/discord/382595433060499458.svg?style=for-the-badge&logo=discord)](https://discord.gg/9aqdHU7) [![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/gogs/gogs) ![Repository](https://gogs.io/img/screenshots/2.png) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 288b9549f..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: "{build}" -skip_tags: true -clone_folder: c:\gogs.io\gogs -clone_depth: 1 - -environment: - GO111MODULE: on - GOPROXY: https://proxy.golang.org - -build: false -deploy: false - -install: - - set PATH=C:\msys64\mingw64\bin;%PATH% # Fix "gcc" not found: https://github.com/appveyor/ci/issues/2613 - - go version - - go env - - go build -tags "minwinsvc" -v - -test_script: - - go test -v -race -cover ./... diff --git a/internal/conf/conf_test.go b/internal/conf/conf_test.go index 0030ea52e..51ccf93c1 100644 --- a/internal/conf/conf_test.go +++ b/internal/conf/conf_test.go @@ -37,10 +37,6 @@ func TestMustAsset(t *testing.T) { } func TestInit(t *testing.T) { - if IsWindowsRuntime() { - return - } - ini.PrettyFormat = false defer func() { MustInit("") diff --git a/internal/testutil/golden.go b/internal/testutil/golden.go index fa584d1ba..2aaad5ce4 100644 --- a/internal/testutil/golden.go +++ b/internal/testutil/golden.go @@ -9,6 +9,7 @@ import ( "flag" "io/ioutil" "regexp" + "runtime" "testing" "github.com/stretchr/testify/assert" @@ -25,8 +26,12 @@ func Update(name string) bool { } // AssertGolden compares what's got and what's in the golden file. It updates -// the golden file on-demand. +// the golden file on-demand. It does nothing when the runtime is "windows". func AssertGolden(t testing.TB, path string, update bool, got interface{}) { + if runtime.GOOS == "windows" { + return + } + t.Helper() data := marshal(t, got)