mirror of https://github.com/gogs/gogs.git
ci: use new lint action and add custom config (#6562)
parent
c4cf659e32
commit
1a1a01a842
|
@ -7,10 +7,13 @@ on:
|
||||||
paths:
|
paths:
|
||||||
- '**.go'
|
- '**.go'
|
||||||
- 'go.mod'
|
- 'go.mod'
|
||||||
|
- '.golangci.yml'
|
||||||
|
- '.github/workflows/go.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '**.go'
|
- '**.go'
|
||||||
- 'go.mod'
|
- 'go.mod'
|
||||||
|
- '.golangci.yml'
|
||||||
- '.github/workflows/go.yml'
|
- '.github/workflows/go.yml'
|
||||||
env:
|
env:
|
||||||
GOPROXY: "https://proxy.golang.org"
|
GOPROXY: "https://proxy.golang.org"
|
||||||
|
@ -22,31 +25,25 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Run golangci-lint
|
- name: Run golangci-lint
|
||||||
uses: actions-contrib/golangci-lint@v1
|
uses: golangci/golangci-lint-action@v2
|
||||||
with:
|
with:
|
||||||
args: 'run --timeout=30m'
|
version: latest
|
||||||
|
args: --timeout=30m
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test
|
name: Test
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [1.14.x, 1.15.x]
|
go-version: [1.14.x, 1.15.x, 1.16.x]
|
||||||
platform: [ubuntu-latest, macos-latest, windows-latest]
|
platform: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
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
|
- name: Cache downloaded modules
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
|
@ -54,4 +51,11 @@ jobs:
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-
|
${{ runner.os }}-go-
|
||||||
|
- name: Run unit tests
|
||||||
|
run: go test -v -race -coverprofile=coverage -covermode=atomic ./...
|
||||||
|
- name: Upload coverage report to Codecov
|
||||||
|
uses: codecov/codecov-action@v1.5.0
|
||||||
|
with:
|
||||||
|
file: ./coverage
|
||||||
|
flags: unittests
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
linters-settings:
|
||||||
|
nakedret:
|
||||||
|
max-func-lines: 0 # Disallow any unnamed return statement
|
||||||
|
|
||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- deadcode
|
||||||
|
- errcheck
|
||||||
|
- gosimple
|
||||||
|
- govet
|
||||||
|
- ineffassign
|
||||||
|
- staticcheck
|
||||||
|
- structcheck
|
||||||
|
- typecheck
|
||||||
|
- unused
|
||||||
|
- varcheck
|
||||||
|
- nakedret
|
||||||
|
- gofmt
|
||||||
|
- rowserrcheck
|
||||||
|
- unconvert
|
||||||
|
- goimports
|
|
@ -3,7 +3,7 @@
|
||||||
# The default configuration is also calling all the scripts in /etc/periodic/${period}
|
# The default configuration is also calling all the scripts in /etc/periodic/${period}
|
||||||
|
|
||||||
if test -f ./setup; then
|
if test -f ./setup; then
|
||||||
# shellcheck disable=SC2039,SC1091
|
# shellcheck disable=SC2039,SC1091,SC3046
|
||||||
source ./setup
|
source ./setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if test -f ./setup; then
|
if test -f ./setup; then
|
||||||
# shellcheck disable=SC2039,SC1091
|
# shellcheck disable=SC2039,SC1091,SC3046
|
||||||
source ./setup
|
source ./setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if test -f ./setup; then
|
if test -f ./setup; then
|
||||||
# shellcheck disable=SC2039,SC1091
|
# shellcheck disable=SC2039,SC1091,SC3046
|
||||||
source ./setup
|
source ./setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if test -f ./setup; then
|
if test -f ./setup; then
|
||||||
# shellcheck disable=SC2039,SC1091
|
# shellcheck disable=SC2039,SC1091,SC3046
|
||||||
source ./setup
|
source ./setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ create_socat_links() {
|
||||||
SERV_FOLDER=/app/gogs/docker/s6/SOCAT_${NAME}_${PORT}
|
SERV_FOLDER=/app/gogs/docker/s6/SOCAT_${NAME}_${PORT}
|
||||||
mkdir -p "${SERV_FOLDER}"
|
mkdir -p "${SERV_FOLDER}"
|
||||||
CMD="socat -ls TCP4-LISTEN:${PORT},fork,reuseaddr TCP4:${ADDR}:${PORT}"
|
CMD="socat -ls TCP4-LISTEN:${PORT},fork,reuseaddr TCP4:${ADDR}:${PORT}"
|
||||||
# shellcheck disable=SC2039
|
# shellcheck disable=SC2039,SC3037
|
||||||
echo -e "#!/bin/sh\nexec $CMD" > "${SERV_FOLDER}"/run
|
echo -e "#!/bin/sh\nexec $CMD" > "${SERV_FOLDER}"/run
|
||||||
chmod +x "${SERV_FOLDER}"/run
|
chmod +x "${SERV_FOLDER}"/run
|
||||||
USED_PORT="${USED_PORT}:${PORT}"
|
USED_PORT="${USED_PORT}:${PORT}"
|
||||||
|
@ -24,7 +24,7 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
# Cleanup SOCAT services and s6 event folder
|
# Cleanup SOCAT services and s6 event folder
|
||||||
# On start and on shutdown in case container has been killed
|
# On start and on shutdown in case container has been killed
|
||||||
rm -rf "$(find /app/gogs/docker/s6/ -name 'event')"
|
rm -rf "$(find /app/gogs/docker/s6/ -name 'event')"
|
||||||
rm -rf /app/gogs/docker/s6/SOCAT_*
|
rm -rf /app/gogs/docker/s6/SOCAT_*
|
||||||
|
@ -67,7 +67,7 @@ if [ "$CROND" = "true" ] || [ "$CROND" = "1" ]; then
|
||||||
rm -f /app/gogs/docker/s6/crond/down
|
rm -f /app/gogs/docker/s6/crond/down
|
||||||
/bin/sh /app/gogs/docker/runtime/backup-init.sh "${PUID}"
|
/bin/sh /app/gogs/docker/runtime/backup-init.sh "${PUID}"
|
||||||
else
|
else
|
||||||
# Tell s6 not to run the crond service
|
# Tell s6 not to run the crond service
|
||||||
touch /app/gogs/docker/s6/crond/down
|
touch /app/gogs/docker/s6/crond/down
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ import (
|
||||||
|
|
||||||
"github.com/gogs/cron"
|
"github.com/gogs/cron"
|
||||||
|
|
||||||
"gogs.io/gogs/internal/db"
|
|
||||||
"gogs.io/gogs/internal/conf"
|
"gogs.io/gogs/internal/conf"
|
||||||
|
"gogs.io/gogs/internal/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
var c = cron.New()
|
var c = cron.New()
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/unknwon/com"
|
"github.com/unknwon/com"
|
||||||
log "unknwon.dev/clog/v2"
|
log "unknwon.dev/clog/v2"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
|
|
@ -227,7 +227,7 @@ func GetStatistic() (stats Statistic) {
|
||||||
stats.Counter.HookTask, _ = x.Count(new(HookTask))
|
stats.Counter.HookTask, _ = x.Count(new(HookTask))
|
||||||
stats.Counter.Team, _ = x.Count(new(Team))
|
stats.Counter.Team, _ = x.Count(new(Team))
|
||||||
stats.Counter.Attachment, _ = x.Count(new(Attachment))
|
stats.Counter.Attachment, _ = x.Count(new(Attachment))
|
||||||
return
|
return stats
|
||||||
}
|
}
|
||||||
|
|
||||||
func Ping() error {
|
func Ping() error {
|
||||||
|
|
|
@ -221,7 +221,7 @@ func SSHKeyGenParsePublicKey(key string) (string, int, error) {
|
||||||
func SSHNativeParsePublicKey(keyLine string) (string, int, error) {
|
func SSHNativeParsePublicKey(keyLine string) (string, int, error) {
|
||||||
fields := strings.Fields(keyLine)
|
fields := strings.Fields(keyLine)
|
||||||
if len(fields) < 2 {
|
if len(fields) < 2 {
|
||||||
return "", 0, fmt.Errorf("not enough fields in public key line: %s", string(keyLine))
|
return "", 0, fmt.Errorf("not enough fields in public key line: %s", keyLine)
|
||||||
}
|
}
|
||||||
|
|
||||||
raw, err := base64.StdEncoding.DecodeString(fields[1])
|
raw, err := base64.StdEncoding.DecodeString(fields[1])
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
gouuid "github.com/satori/go.uuid"
|
gouuid "github.com/satori/go.uuid"
|
||||||
log "unknwon.dev/clog/v2"
|
log "unknwon.dev/clog/v2"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
|
||||||
"github.com/gogs/git-module"
|
"github.com/gogs/git-module"
|
||||||
api "github.com/gogs/go-gogs-client"
|
api "github.com/gogs/go-gogs-client"
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
|
||||||
"github.com/gogs/git-module"
|
"github.com/gogs/git-module"
|
||||||
api "github.com/gogs/go-gogs-client"
|
api "github.com/gogs/go-gogs-client"
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
|
||||||
"github.com/gogs/git-module"
|
"github.com/gogs/git-module"
|
||||||
api "github.com/gogs/go-gogs-client"
|
api "github.com/gogs/go-gogs-client"
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultSetting = Settings{false, "GogsServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false}
|
var defaultSetting = Settings{false, "GogsServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false}
|
||||||
|
|
|
@ -216,7 +216,7 @@ func wrapImgWithLink(urlPrefix string, buf *bytes.Buffer, token html.Token) {
|
||||||
buf.WriteString(`">`)
|
buf.WriteString(`">`)
|
||||||
|
|
||||||
if needPrepend {
|
if needPrepend {
|
||||||
src = strings.Replace(urlPrefix+string(src), " ", "%20", -1)
|
src = strings.Replace(urlPrefix+src, " ", "%20", -1)
|
||||||
buf.WriteString(`<img src="`)
|
buf.WriteString(`<img src="`)
|
||||||
buf.WriteString(src)
|
buf.WriteString(src)
|
||||||
buf.WriteString(`"`)
|
buf.WriteString(`"`)
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
|
|
||||||
"github.com/microcosm-cc/bluemonday"
|
"github.com/microcosm-cc/bluemonday"
|
||||||
|
|
||||||
"gogs.io/gogs/internal/lazyregexp"
|
|
||||||
"gogs.io/gogs/internal/conf"
|
"gogs.io/gogs/internal/conf"
|
||||||
|
"gogs.io/gogs/internal/lazyregexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Sanitizer is a protection wrapper of *bluemonday.Policy which does not allow
|
// Sanitizer is a protection wrapper of *bluemonday.Policy which does not allow
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
|
||||||
"gogs.io/gogs/internal/conf"
|
"gogs.io/gogs/internal/conf"
|
||||||
"gogs.io/gogs/internal/context"
|
"gogs.io/gogs/internal/context"
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gogs.io/gogs/internal/conf"
|
||||||
"gogs.io/gogs/internal/context"
|
"gogs.io/gogs/internal/context"
|
||||||
"gogs.io/gogs/internal/db"
|
"gogs.io/gogs/internal/db"
|
||||||
"gogs.io/gogs/internal/route"
|
"gogs.io/gogs/internal/route"
|
||||||
"gogs.io/gogs/internal/conf"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -7,11 +7,12 @@ package repo
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
api "github.com/gogs/go-gogs-client"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/json-iterator/go"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/unknwon/com"
|
"github.com/unknwon/com"
|
||||||
|
|
||||||
|
api "github.com/gogs/go-gogs-client"
|
||||||
|
|
||||||
"gogs.io/gogs/internal/context"
|
"gogs.io/gogs/internal/context"
|
||||||
"gogs.io/gogs/internal/db"
|
"gogs.io/gogs/internal/db"
|
||||||
"gogs.io/gogs/internal/route/api/v1/convert"
|
"gogs.io/gogs/internal/route/api/v1/convert"
|
||||||
|
|
Loading…
Reference in New Issue