fix sonarcloud run for master, remove unneeded configs, rework makefile

This commit is contained in:
Willy Kloucek
2020-12-28 11:57:46 +01:00
parent d964f2f6b1
commit 5c72d915ee
18 changed files with 99 additions and 82 deletions

View File

@@ -368,6 +368,18 @@ def buildOcisBinaryForTesting(ctx):
}
def uploadCoverage(ctx):
sonar_env = {
'SONAR_TOKEN': {
'from_secret': 'sonar_token',
},
}
if True or ctx.build.event == 'pull_request':
sonar_env.update({
'SONAR_PULL_REQUEST_BASE': '%s' % (ctx.build.target),
'SONAR_PULL_REQUEST_BRANCH': '%s' % (ctx.build.source),
'SONAR_PULL_REQUEST_KEY': '%s' % (ctx.build.ref.replace("refs/pull/", "").split("/")[0]),
})
return {
'kind': 'pipeline',
'type': 'docker',
@@ -404,14 +416,7 @@ def uploadCoverage(ctx):
'name': 'sonarcloud',
'image': 'sonarsource/sonar-scanner-cli',
'pull': 'always',
'environment': {
'SONAR_TOKEN': {
'from_secret': 'sonar_token',
},
'SONAR_PULL_REQUEST_BASE': '%s' % ('master' if ctx.build.event == 'pull_request' else None),
'SONAR_PULL_REQUEST_BRANCH': '%s' % (ctx.build.source if ctx.build.event == 'pull_request' else None),
'SONAR_PULL_REQUEST_KEY': '%s' % (ctx.build.ref.replace("refs/pull/", "").split("/")[0] if ctx.build.event == 'pull_request' else None),
},
'environment': sonar_env,
},
{
'name': 'purge-cache',

View File

@@ -17,8 +17,9 @@ OCIS_MODULES = \
glauth \
konnectd \
ocis \
ocs \
ocis-pkg \
ocs \
onlyoffice \
proxy \
settings \
storage \
@@ -83,3 +84,16 @@ go-mod-tidy:
@for mod in $(OCIS_MODULES); do \
$(MAKE) --no-print-directory -C $$mod go-mod-tidy; \
done
.PHONY: test
test:
@for mod in $(OCIS_MODULES); do \
$(MAKE) --no-print-directory -C $$mod test; \
done
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@for mod in $(OCIS_MODULES); do \
echo -n "% coverage $$mod: "; $(MAKE) --no-print-directory -C $$mod go-coverage; \
done

View File

@@ -96,6 +96,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -1,37 +0,0 @@
sonar.projectKey=owncloud_ocis-accounts
sonar.organization=owncloud-1
sonar.projectName=ocis-accounts
sonar.projectVersion=1.0
sonar.host.url=https://sonarcloud.io
# =====================================================
# Meta-data for the project
# =====================================================
sonar.links.homepage=https://github.com/owncloud/ocis-accounts
sonar.links.ci=https://cloud.drone.io/owncloud/ocis-accounts/
sonar.links.scm=https://github.com/owncloud/ocis-accounts
sonar.links.issue=https://github.com/owncloud/ocis/accounts/issues
# =====================================================
# Properties that will be shared amongst all modules
# =====================================================
# SQ standard properties
sonar.sources=.
# Pull Requests
sonar.pullrequest.provider=GitHub
sonar.pullrequest.github.repository=owncloud/ocis-accounts
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.out
# Exclude protobuf files
sonar.exclusions=pkg/proto/**, changelog/**, docs/**, package.json, rollup.config.js, changelog.md

View File

@@ -91,6 +91,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -113,6 +113,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -69,6 +69,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: build
build:
$(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./...

View File

@@ -95,9 +95,14 @@ changelog: ## generate changelog
go run github.com/restic/calens -i ../changelog -t ../changelog/CHANGELOG.tmpl >| ../CHANGELOG.md
.PHONY: test
test: ## run tests
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES) ## install
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -92,6 +92,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -93,6 +93,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -92,6 +92,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -95,6 +95,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -93,6 +93,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -92,6 +92,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -93,6 +93,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -1,35 +0,0 @@
sonar.projectKey=owncloud_ocis-thumbnails
sonar.organization=owncloud-1
sonar.projectName=ocis-thumbnails
sonar.projectVersion=1.0
sonar.host.url=https://sonarcloud.io
# =====================================================
# Meta-data for the project
# =====================================================
sonar.links.homepage=https://github.com/owncloud/ocis-thumbnails
sonar.links.ci=https://cloud.drone.io/owncloud/ocis-thumbnails/
sonar.links.scm=https://github.com/owncloud/ocis-thumbnails
sonar.links.issue=https://github.com/owncloud/ocis/thumbnails/issues
# =====================================================
# Properties that will be shared amongst all modules
# =====================================================
# SQ standard properties
sonar.sources=.
# Pull Requests
sonar.pullrequest.provider=GitHub
sonar.pullrequest.github.repository=owncloud/ocis-thumbnails
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.out
# Exclude protobuf files
sonar.exclusions=pkg/proto/**, changelog/**, docs/**, package.json, rollup.config.js, changelog.md

View File

@@ -92,6 +92,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)

View File

@@ -91,6 +91,11 @@ changelog:
test:
go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES)
.PHONY: go-coverage
go-coverage:
@if [ ! -f coverage.out ]; then $(MAKE) test &>/dev/null; fi;
@go tool cover -func coverage.out | tail -1 | grep -Eo "[0-9]+\.[0-9]+"
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)