Bläddra i källkod

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
ᴜɴᴋɴᴡᴏɴ 5 år sedan
förälder
incheckning
0be8db6fdb
5 ändrade filer med 52 tillägg och 32 borttagningar
  1. 46 0
      .github/workflows/go.yml
  2. 0 9
      .github/workflows/golint.yml
  3. 0 18
      .travis.yml
  4. 0 4
      internal/conf/conf_test.go
  5. 6 1
      internal/testutil/golden.go

+ 46 - 0
.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-
+      

+ 0 - 9
.github/workflows/golint.yml

@@ -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

+ 0 - 18
.travis.yml

@@ -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)

+ 0 - 4
internal/conf/conf_test.go

@@ -37,10 +37,6 @@ func TestMustAsset(t *testing.T) {
 }
 }
 
 
 func TestInit(t *testing.T) {
 func TestInit(t *testing.T) {
-	if IsWindowsRuntime() {
-		return
-	}
-
 	ini.PrettyFormat = false
 	ini.PrettyFormat = false
 	defer func() {
 	defer func() {
 		MustInit("")
 		MustInit("")

+ 6 - 1
internal/testutil/golden.go

@@ -9,6 +9,7 @@ import (
 	"flag"
 	"flag"
 	"io/ioutil"
 	"io/ioutil"
 	"regexp"
 	"regexp"
+	"runtime"
 	"testing"
 	"testing"
 
 
 	"github.com/stretchr/testify/assert"
 	"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
 // 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{}) {
 func AssertGolden(t testing.TB, path string, update bool, got interface{}) {
+	if runtime.GOOS == "windows" {
+		return
+	}
+
 	t.Helper()
 	t.Helper()
 
 
 	data := marshal(t, got)
 	data := marshal(t, got)