mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-21 10:18:21 -05:00
switch to golangci-lint
This commit is contained in:
+3
-16
@@ -47,17 +47,11 @@ $(FLAEX): $(BINGO_DIR)/flaex.mod
|
||||
@echo "(re)installing $(GOBIN)/flaex-v0.2.0"
|
||||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=flaex.mod -o=$(GOBIN)/flaex-v0.2.0 "github.com/owncloud/flaex"
|
||||
|
||||
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.35.2
|
||||
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.37.1
|
||||
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
|
||||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
|
||||
@echo "(re)installing $(GOBIN)/golangci-lint-v1.35.2"
|
||||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.35.2 "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||
|
||||
GOLINT := $(GOBIN)/golint-v0.0.0-20201208152925-83fdc39ff7b5
|
||||
$(GOLINT): $(BINGO_DIR)/golint.mod
|
||||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
|
||||
@echo "(re)installing $(GOBIN)/golint-v0.0.0-20201208152925-83fdc39ff7b5"
|
||||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golint.mod -o=$(GOBIN)/golint-v0.0.0-20201208152925-83fdc39ff7b5 "golang.org/x/lint/golint"
|
||||
@echo "(re)installing $(GOBIN)/golangci-lint-v1.37.1"
|
||||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.37.1 "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||
|
||||
GOVERAGE := $(GOBIN)/goverage-v0.0.0-20180129164344-eec3514a20b5
|
||||
$(GOVERAGE): $(BINGO_DIR)/goverage.mod
|
||||
@@ -118,10 +112,3 @@ $(REFLEX): $(BINGO_DIR)/reflex.mod
|
||||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
|
||||
@echo "(re)installing $(GOBIN)/reflex-v0.3.0"
|
||||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=reflex.mod -o=$(GOBIN)/reflex-v0.3.0 "github.com/cespare/reflex"
|
||||
|
||||
STATICCHECK := $(GOBIN)/staticcheck-v0.1.2
|
||||
$(STATICCHECK): $(BINGO_DIR)/staticcheck.mod
|
||||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
|
||||
@echo "(re)installing $(GOBIN)/staticcheck-v0.1.2"
|
||||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=staticcheck.mod -o=$(GOBIN)/staticcheck-v0.1.2 "honnef.co/go/tools/cmd/staticcheck"
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@ module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
|
||||
|
||||
go 1.15
|
||||
|
||||
require github.com/golangci/golangci-lint v1.35.2 // cmd/golangci-lint
|
||||
require github.com/golangci/golangci-lint v1.37.1 // cmd/golangci-lint
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
|
||||
|
||||
go 1.15
|
||||
|
||||
require golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // golint
|
||||
@@ -1,5 +0,0 @@
|
||||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
|
||||
|
||||
go 1.15
|
||||
|
||||
require honnef.co/go/tools v0.1.2 // cmd/staticcheck
|
||||
@@ -18,9 +18,7 @@ FILEB0X="${GOBIN}/fileb0x-v1.1.4"
|
||||
|
||||
FLAEX="${GOBIN}/flaex-v0.2.0"
|
||||
|
||||
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.35.2"
|
||||
|
||||
GOLINT="${GOBIN}/golint-v0.0.0-20201208152925-83fdc39ff7b5"
|
||||
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.37.1"
|
||||
|
||||
GOVERAGE="${GOBIN}/goverage-v0.0.0-20180129164344-eec3514a20b5"
|
||||
|
||||
@@ -41,6 +39,3 @@ PROTOC_GEN_MICROWEB="${GOBIN}/protoc-gen-microweb-v0.0.0-20210224131655-d9b1137a
|
||||
PROTOC_GEN_OPENAPIV2="${GOBIN}/protoc-gen-openapiv2-v2.2.0"
|
||||
|
||||
REFLEX="${GOBIN}/reflex-v0.3.0"
|
||||
|
||||
STATICCHECK="${GOBIN}/staticcheck-v0.1.2"
|
||||
|
||||
|
||||
+33
-35
@@ -240,10 +240,10 @@ def testOcisModules(ctx):
|
||||
for module in config['modules']:
|
||||
pipelines.append(testOcisModule(ctx, module))
|
||||
|
||||
coverage_upload = uploadCoverage(ctx)
|
||||
coverage_upload['depends_on'] = getPipelineNames(pipelines)
|
||||
scan_result_upload = uploadScanResults(ctx)
|
||||
scan_result_upload['depends_on'] = getPipelineNames(pipelines)
|
||||
|
||||
return pipelines + [coverage_upload]
|
||||
return pipelines + [scan_result_upload]
|
||||
|
||||
def testPipelines(ctx):
|
||||
pipelines = [
|
||||
@@ -264,29 +264,13 @@ def testPipelines(ctx):
|
||||
def testOcisModule(ctx, module):
|
||||
steps = makeGenerate(module) + [
|
||||
{
|
||||
'name': 'vet',
|
||||
'name': 'golangci-lint',
|
||||
'image': 'webhippie/golang:1.15',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'make -C %s vet' % (module),
|
||||
],
|
||||
'volumes': [stepVolumeGoWebhippie,],
|
||||
},
|
||||
{
|
||||
'name': 'staticcheck',
|
||||
'image': 'webhippie/golang:1.15',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'make -C %s staticcheck' % (module),
|
||||
],
|
||||
'volumes': [stepVolumeGoWebhippie,],
|
||||
},
|
||||
{
|
||||
'name': 'lint',
|
||||
'image': 'webhippie/golang:1.15',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'make -C %s lint' % (module),
|
||||
'mkdir -p cache/checkstyle',
|
||||
'make -C %s ci-golangci-lint' % (module),
|
||||
'mv %s/checkstyle.xml cache/checkstyle/%s_checkstyle.xml' % (module, module),
|
||||
],
|
||||
'volumes': [stepVolumeGoWebhippie,],
|
||||
},
|
||||
@@ -295,8 +279,9 @@ def testOcisModule(ctx, module):
|
||||
'image': 'webhippie/golang:1.15',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'mkdir -p cache/coverage',
|
||||
'make -C %s test' % (module),
|
||||
'mv %s/coverage.out %s_coverage.out' % (module, module),
|
||||
'mv %s/coverage.out cache/coverage/%s_coverage.out' % (module, module),
|
||||
],
|
||||
'volumes': [stepVolumeGoWebhippie,],
|
||||
},
|
||||
@@ -308,8 +293,8 @@ def testOcisModule(ctx, module):
|
||||
'from_secret': 'cache_s3_endpoint'
|
||||
},
|
||||
'bucket': 'cache',
|
||||
'source': '%s_coverage.out' % (module),
|
||||
'target': '%s/%s/coverage' % (ctx.repo.slug, ctx.build.commit + '-${DRONE_BUILD_NUMBER}'),
|
||||
'source': 'cache/**/*',
|
||||
'target': '%s/%s' % (ctx.repo.slug, ctx.build.commit + '-${DRONE_BUILD_NUMBER}'),
|
||||
'path_style': True,
|
||||
'access_key': {
|
||||
'from_secret': 'cache_s3_access_key'
|
||||
@@ -364,7 +349,7 @@ def buildOcisBinaryForTesting(ctx):
|
||||
'volumes': [pipelineVolumeGoWebhippie],
|
||||
}
|
||||
|
||||
def uploadCoverage(ctx):
|
||||
def uploadScanResults(ctx):
|
||||
sonar_env = {
|
||||
'SONAR_TOKEN': {
|
||||
'from_secret': 'sonar_token',
|
||||
@@ -377,26 +362,39 @@ def uploadCoverage(ctx):
|
||||
'SONAR_PULL_REQUEST_KEY': '%s' % (ctx.build.ref.replace("refs/pull/", "").split("/")[0]),
|
||||
})
|
||||
|
||||
repo_slug = ctx.build.source_repo if ctx.build.source_repo else ctx.repo.slug
|
||||
|
||||
return {
|
||||
'kind': 'pipeline',
|
||||
'type': 'docker',
|
||||
'name': 'upload-coverage',
|
||||
'name': 'upload-scan-results',
|
||||
'platform': {
|
||||
'os': 'linux',
|
||||
'arch': 'amd64',
|
||||
},
|
||||
'clone': {
|
||||
'disable': True, # Sonarcloud does not apply issues on already merged branch
|
||||
},
|
||||
'steps': [
|
||||
{
|
||||
'name': 'clone',
|
||||
'image': 'alpine/git',
|
||||
'commands': [
|
||||
'git clone https://github.com/%s.git .' % (repo_slug),
|
||||
'git checkout $DRONE_COMMIT',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'sync-from-cache',
|
||||
'image': 'minio/mc:RELEASE.2020-12-10T01-26-17Z',
|
||||
'image': 'minio/mc:RELEASE.2021-02-19T05-34-40Z',
|
||||
'environment': {
|
||||
'MC_HOST_cache': {
|
||||
'MC_HOST_cachebucket': {
|
||||
'from_secret': 'cache_s3_connection_url'
|
||||
}
|
||||
},
|
||||
'commands': [
|
||||
'mkdir -p coverage',
|
||||
'mc mirror cache/cache/%s/%s/coverage coverage/' % (ctx.repo.slug, ctx.build.commit + '-${DRONE_BUILD_NUMBER}'),
|
||||
'mkdir -p cache',
|
||||
'mc mirror cachebucket/cache/%s/%s/cache cache/' % (ctx.repo.slug, ctx.build.commit + '-${DRONE_BUILD_NUMBER}'),
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -411,7 +409,7 @@ def uploadCoverage(ctx):
|
||||
},
|
||||
{
|
||||
'name': 'sonarcloud',
|
||||
'image': 'sonarsource/sonar-scanner-cli:latest',
|
||||
'image': 'sonarsource/sonar-scanner-cli',
|
||||
'pull': 'always',
|
||||
'environment': sonar_env,
|
||||
},
|
||||
@@ -419,12 +417,12 @@ def uploadCoverage(ctx):
|
||||
'name': 'purge-cache',
|
||||
'image': 'minio/mc:RELEASE.2020-12-10T01-26-17Z',
|
||||
'environment': {
|
||||
'MC_HOST_cache': {
|
||||
'MC_HOST_cachebucket': {
|
||||
'from_secret': 'cache_s3_connection_url'
|
||||
}
|
||||
},
|
||||
'commands': [
|
||||
'mc rm --recursive --force cache/cache/%s/%s/coverage' % (ctx.repo.slug, ctx.build.commit + '-${DRONE_BUILD_NUMBER}'),
|
||||
'mc rm --recursive --force cachebucket/cache/%s/%s/cache' % (ctx.repo.slug, ctx.build.commit + '-${DRONE_BUILD_NUMBER}'),
|
||||
]
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
*/coverage.out
|
||||
*/checkstyle.xml
|
||||
|
||||
ocis/config/identifier-registration.yaml
|
||||
*/bin
|
||||
|
||||
+6
-10
@@ -68,17 +68,13 @@ go-mod-tidy:
|
||||
fmt:
|
||||
gofmt -s -w $(SOURCES)
|
||||
|
||||
.PHONY: vet
|
||||
vet:
|
||||
go vet $(PACKAGES)
|
||||
.PHONY: golangci-lint
|
||||
golangci-lint: $(GOLANGCI_LINT)
|
||||
$(GOLANGCI_LINT) run -E gosec -E bodyclose -E dogsled -E durationcheck -E golint -E ifshort -E makezero -E prealloc -E predeclared --path-prefix $(NAME)
|
||||
|
||||
.PHONY: staticcheck
|
||||
staticcheck: $(STATICCHECK)
|
||||
$(STATICCHECK) -tags '$(TAGS)' $(PACKAGES)
|
||||
|
||||
.PHONY: lint
|
||||
lint: $(GOLINT)
|
||||
for PKG in $(PACKAGES); do $(GOLINT) -set_exit_status $$PKG || exit 1; done;
|
||||
.PHONY: ci-golangci-lint
|
||||
ci-golangci-lint: $(GOLANGCI_LINT)
|
||||
$(GOLANGCI_LINT) run -E gosec -E bodyclose -E dogsled -E durationcheck -E golint -E ifshort -E makezero -E prealloc -E predeclared --path-prefix $(NAME) --timeout 10m0s --issues-exit-code 0 --out-format checkstyle > checkstyle.xml
|
||||
|
||||
.PHONY: test
|
||||
test: $(GOVERAGE)
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ docs-init:
|
||||
.PHONY: docs-serve
|
||||
docs-serve: docs-init docs-generate docs-copy ## serve docs with hugo
|
||||
@bash -c "trap 'trap - SIGINT SIGTERM ERR; $(MAKE) --no-print-directory docs-sync-stop; exit 0' SIGINT SIGTERM ERR; $(MAKE) --no-print-directory docs-sync-start && $(MAKE) --no-print-directory hugo-serve"
|
||||
|
||||
|
||||
.PHONY: test
|
||||
test: $(HUGO)
|
||||
@cd hugo && $(HUGO)
|
||||
|
||||
+2
-2
@@ -35,13 +35,13 @@ assets: yarn-build \
|
||||
assets/identifier/static:
|
||||
mkdir -p assets/identifier/static
|
||||
|
||||
LOGO_URL = https://raw.githubusercontent.com/owncloud/assets/main/logo.svg
|
||||
LOGO_URL = https://raw.githubusercontent.com/owncloud/assets/main/logo.svg
|
||||
|
||||
.PHONY: assets/identifier/static/logo.svg # force overwrite
|
||||
assets/identifier/static/logo.svg:
|
||||
curl -o assets/identifier/static/logo.svg ${LOGO_URL}
|
||||
|
||||
FAVICON_URL = https://raw.githubusercontent.com/owncloud/assets/main/favicon.ico
|
||||
FAVICON_URL = https://raw.githubusercontent.com/owncloud/assets/main/favicon.ico
|
||||
|
||||
.PHONY: assets/identifier/static/favicon.ico # force overwrite
|
||||
assets/identifier/static/favicon.ico:
|
||||
|
||||
@@ -22,14 +22,18 @@ sonar.links.issue=https://github.com/owncloud/ocis/issues
|
||||
sonar.sources=.
|
||||
|
||||
# Pull Requests
|
||||
sonar.pullrequest.provider=GitHub
|
||||
sonar.pullrequest.provider=github
|
||||
sonar.pullrequest.github.repository=owncloud/ocis
|
||||
sonar.pullrequest.base=${env.SONAR_PULL_REQUEST_BASE}
|
||||
sonar.pullrequest.branch=${env.SONAR_PULL_REQUEST_BRANCH}
|
||||
sonar.pullrequest.key=${env.SONAR_PULL_REQUEST_KEY}
|
||||
|
||||
# Properties specific to language plugins:
|
||||
sonar.go.coverage.reportPaths=coverage/*_coverage.out
|
||||
sonar.go.coverage.reportPaths=cache/coverage/*
|
||||
# golangci-lint does not support wildcard
|
||||
# https://github.com/SonarSource/slang/blob/85b05160bc1b31c6072a35f8818da4376b107afa/sonar-go-plugin/src/main/java/org/sonar/go/externalreport/GolangCILintReportSensor.java#L37
|
||||
# https://github.com/SonarSource/slang/blob/85b05160bc1b31c6072a35f8818da4376b107afa/sonar-go-plugin/src/main/java/org/sonar/go/externalreport/AbstractReportSensor.java#L76-L90
|
||||
sonar.go.golangci-lint.reportPaths=cache/checkstyle/accounts_checkstyle.xml,cache/checkstyle/glauth_checkstyle.xml,cache/checkstyle/graph_checkstyle.xml,cache/checkstyle/graph-explorer_checkstyle.xml,cache/checkstyle/idp_checkstyle.xml,cache/checkstyle/ocis_checkstyle.xml,cache/checkstyle/ocis-pkg_checkstyle.xml,cache/checkstyle/ocs_checkstyle.xml,cache/checkstyle/onlyoffice_checkstyle.xml,cache/checkstyle/proxy_checkstyle.xml,cache/checkstyle/settings_checkstyle.xml,cache/checkstyle/storage_checkstyle.xml,cache/checkstyle/store_checkstyle.xml,cache/checkstyle/thumbnails_checkstyle.xml,cache/checkstyle/web_checkstyle.xml,cache/checkstyle/webdav_checkstyle.xml
|
||||
|
||||
# Exclude files
|
||||
sonar.exclusions=**/third_party,docs/**,changelog/**,*/pkg/assets/embed.go,idp/assets/identifier/**,**/package.json,**/rollup.config.js,CHANGELOG.md,**/pkg/proto/**/*.pb.*,deployments/**,tests/**,vendor-bin/**,README.md
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"io/ioutil"
|
||||
@@ -112,6 +113,9 @@ func (s *FileSystem) storeImage(key string, img []byte) (string, error) {
|
||||
// <filestorage-root>/users/<3 characters>/<3 characters>/<48 characters>/
|
||||
// This will balance the folders in setups with many users.
|
||||
func (s *FileSystem) userDir(username string) string {
|
||||
mh := md5.New()
|
||||
mh.Write([]byte("something"))
|
||||
|
||||
hash := sha256.New224()
|
||||
if _, err := hash.Write([]byte(username)); err != nil {
|
||||
s.logger.Fatal().Err(err).Msg("failed to create hash")
|
||||
|
||||
Reference in New Issue
Block a user