Skip to content

Commit

Permalink
Merge pull request #36 from pantheon-systems/releng-284
Browse files Browse the repository at this point in the history
[RELENG-284] Replace Coveralls with Codacy
  • Loading branch information
pantheon-chris authored Jun 20, 2024
2 parents 496d169 + a758eaa commit d59a5bf
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 31 deletions.
15 changes: 13 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,18 @@ jobs:
- restore-go-mod-cache
- run:
name: lint and test
command: make test-circle
command: make test-circle && make test-coverage
- run:
name: Upload Coverage Results to Codacy
command: |
if [ -x "$(which curl)" ]; then
curl -Ls https://coverage.codacy.com/get.sh > get.sh
elif [ -x "$(which wget)" ] ; then
wget -qO - https://coverage.codacy.com/get.sh > get.sh
else
printf "Could not find curl or wget, please install one."
fi
source get.sh report --force-coverage-parser go -r coverage.out
# Tag for release
release:
executor: go-build
Expand Down Expand Up @@ -91,4 +102,4 @@ workflows:
filters:
branches:
only:
- main
- main
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[![Early Access](https://img.shields.io/badge/Pantheon-Early_Access-yellow?logo=pantheon&color=FFDC28)](https://docs.pantheon.io/oss-support-levels#early-access)

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/5a16739ac87e496c80e9578e64ab79ca)](https://app.codacy.com/gh/pantheon-systems/sites-yml-validator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)

A utility for validating a `sites.yml` file on a Pantheon site during a WordPress multisite's search and replace tasks. For more information, see [Pantheon's Multisite Docs](https://docs.pantheon.io/guides/multisite/search-replace/).

## Usage
Expand Down Expand Up @@ -73,8 +75,6 @@ curl -LO https://github.com/pantheon-systems/sites-yml-validator/releases/latest

## Testing

[![Coverage Status](https://coveralls.io/repos/github/pantheon-systems/sites-yml-validator/badge.svg?t=PGhafd)](https://coveralls.io/github/pantheon-systems/sites-yml-validator)

`make test` runs linting and testing.

## Releases
Expand Down
34 changes: 14 additions & 20 deletions devops/make/common-go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# INPUT VARIABLES
# - GOLINT_ARGS: Override the options passed to golangci-lint for linting (-v --timeout 3m by default)
# - GOTEST_ARGS: Override the options passed by default ot go test (--race by default)
# - COVERALLS_TOKEN: Token to use when pushing coverage to coveralls.
#
# - FETCH_CA_CERT: The presence of this variable will cause the root CA certs
# to be downloaded to the file ca-certificates.crt before building.
Expand All @@ -16,11 +15,12 @@ deps:: deps-go
deps-circle:: deps-circle-go deps
lint:: lint-go
test:: lint-go test-go-tparse
test-circle:: test test-coveralls
test-circle:: test
test-coverage:: test-coverage-go
build:: $(APP)
build-go:: $(APP)
clean:: clean-go
format:: format-go

ifndef GOLINT_ARGS
GOLINT_ARGS := -v --timeout 3m
Expand Down Expand Up @@ -70,9 +70,17 @@ deps-go:: deps-lint ## install dependencies for project assumes you have go bina
ifneq (,$(wildcard vendor))
@find ./vendor/* -maxdepth 0 -type d -exec rm -rf "{}" \; || true
endif
$(call INFO, "restoring dependencies using modules via: go get $(GO_GET_ARGS)")
@GO111MODULE=on go get $(GO_GET_ARGS)

$(call INFO, "restoring dependencies using modules via: go mod download $(GO_GET_ARGS)")
@GO111MODULE=on go mod download $(GO_GET_ARGS)

format-go:
$(call INFO, "cleaning up go.mod")
@go mod tidy
$(call INFO, "formatting go-code")
@go fmt
$(call INFO, "running golangci-lint with fixes")
@# TODO: call lint-go
@golangci-lint run -E goimports --fix $(GOLINT_ARGS)

lint-go:: deps-go deps-lint
$(call INFO, "scanning source with golangci-lint")
Expand Down Expand Up @@ -109,12 +117,6 @@ else
endif
endif

deps-coveralls-go:: ## install goveralls for sending go test coverage reports to Coveralls.io
ifeq (, $(shell command -v goveralls;))
$(call INFO, "installing goveralls")
@GO111MODULE=off go get github.com/mattn/goveralls > /dev/null
endif

deps-status:: ## check status of deps with gostatus
ifeq (, $(shell command -v gostatus;))
$(call INFO, "installing gostatus")
Expand All @@ -131,14 +133,6 @@ test-coverage-go:: ## run coverage report
$(call INFO, "running go coverage tests with $(GO_TEST_COVERAGE_ARGS)")
@$(GO_TEST_COVERAGE_CMD) > /dev/null

test-coveralls:: deps-coveralls-go test-coverage-go ## run coverage and report to coveralls
ifdef COVERALLS_TOKEN
$(call INFO, "reporting coverage to coveralls")
@goveralls -repotoken $$COVERALLS_TOKEN -service=circleci -coverprofile=coverage.out > /dev/null
else
$(call WARN, "You asked to use Coveralls but neglected to set the COVERALLS_TOKEN environment variable")
endif

test-coverage-html:: test-coverage ## output html coverage file
$(call INFO, "generating html coverage report")
@go tool cover -html=coverage.out > /dev/null
Expand All @@ -153,5 +147,5 @@ ifdef FETCH_CA_CERT
@curl -s -L https://curl.haxx.se/ca/cacert.pem -o ca-certificates.crt > /dev/null
endif

.PHONY:: _fetch-cert test-coverage-html test-coveralls deps-status deps-coveralls-go deps-circle deps-go deps-lint \
.PHONY:: _fetch-cert test-coverage-html deps-status deps-circle deps-go deps-lint \
lint-go test-circle test-go build-circle build-linux build-go clean-go
30 changes: 23 additions & 7 deletions devops/make/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ ROOT_DIR ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# override to use eg your own checkout for making pr's to upstream
COMMON_MAKE_DIR ?= $(ROOT_DIR)/devops/make

# the branch or ref to get common-make updates from
COMMON_MAKE_UPDATE_TARGET ?= master

help: ## print list of tasks and descriptions
@grep --no-filename -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) $(filter_tasks_cmd) | sort | awk 'BEGIN {FS = ":.*?##"}; { printf "\033[36m%-30s\033[0m %s \n", $$1, $$2}'
@grep --no-filename -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) $(filter_tasks_cmd) | sort | uniq | awk 'BEGIN {FS = ":.*?##"}; { printf "\033[36m%-30s\033[0m %s \n", $$1, $$2}'
.DEFAULT_GOAL := help

# Invoke this with $(call INFO,<test>)
Expand Down Expand Up @@ -50,7 +53,7 @@ ifndef BRANCH
endif

ifndef COMMIT_NO
COMMIT_NO := $(shell git rev-parse --short HEAD)
COMMIT_NO := $(shell git rev-parse --short=8 HEAD)
endif

ifndef COMMIT
Expand All @@ -68,6 +71,19 @@ test-circle:: ## invoke test tasks for CI
test-coverage:: ## run test coverage reports
build:: ## run all build
clean:: ## clean up artifacts from test and build
format:: ## attempts to properly format or cleanup files, writing changes to disk

# runs format and errors if anything has changed
check-format: format
@s=$$(git status --porcelain); if [ -z "$$s" ]; then \
echo "workdir is clean"; \
else \
echo "The following files have changed on disk"; \
echo "$$s"; \
git diff; \
exit 1; \
fi


update-makefiles:: ## update the make subtree, assumes the subtree is in devops/make
ifneq (, $(wildcard scripts/make))
Expand All @@ -79,12 +95,12 @@ update-makefiles:: ## update the make subtree, assumes the subtree is in devops/
@echo "git commit -am \"Move common_makefiles to new prefix\""
@exit 1
endif
# best effort attempt to do one time setup
@set -x; if ! git remote show common_makefiles &> /dev/null; then \
echo "adding common_makefiles as a remote"; \
@if ! git remote show common_makefiles &> /dev/null; then \
echo "temporarily adding common_makefiles as a remote"; \
git remote add common_makefiles [email protected]:pantheon-systems/common_makefiles.git --no-tags; \
git subtree add --prefix devops/make common_makefiles master --squash &>/dev/null || true; \
git subtree add --prefix devops/make common_makefiles $(COMMON_MAKE_UPDATE_TARGET) --squash &>/dev/null || true; \
fi
@git subtree pull --prefix devops/make common_makefiles master --squash
@git subtree pull --prefix devops/make common_makefiles $(COMMON_MAKE_UPDATE_TARGET) --squash -m 'update common make'
@git remote remove common_makefiles

.PHONY:: all help update-makefiles

0 comments on commit d59a5bf

Please sign in to comment.