forked from google/go-licenses
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gitworkflows patch 1 #4
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,11 @@ TMP = ./.tmp | |
RESULTS = $(TMP)/results | ||
ASSETS = assets | ||
DBASSET = $(ASSETS)/licenses.db | ||
# note: go tools requires an absolute path | ||
BIN = $(abspath $(TMP)/bin) | ||
COVER_REPORT = $(RESULTS)/cover.report | ||
COVER_TOTAL = $(RESULTS)/cover.total | ||
LINTCMD = $(BIN)/golangci-lint run --tests=false --config .golangci.yaml | ||
|
||
BOLD := $(shell tput -T linux bold) | ||
PURPLE := $(shell tput -T linux setaf 5) | ||
GREEN := $(shell tput -T linux setaf 2) | ||
|
@@ -15,7 +15,6 @@ RED := $(shell tput -T linux setaf 1) | |
RESET := $(shell tput -T linux sgr0) | ||
TITLE := $(BOLD)$(PURPLE) | ||
SUCCESS := $(BOLD)$(GREEN) | ||
# the quality gate lower threshold for unit test total % coverage (by function statements) | ||
COVERAGE_THRESHOLD := 34 | ||
|
||
RELEASE_CMD=$(BIN)/goreleaser --rm-dist | ||
|
@@ -44,25 +43,18 @@ help: | |
|
||
bootstrap: ## Download and install all project dependencies (+ prep tooling in the ./.tmp dir) | ||
$(call title,Downloading dependencies) | ||
# prep temp dirs | ||
mkdir -p $(TMP) || exit 1 | ||
mkdir -p $(RESULTS) || exit 1 | ||
mkdir -p $(BIN) || exit 1 | ||
# download install project dependencies + tooling | ||
@mkdir -p $(TMP) $(RESULTS) $(BIN) || exit 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Standardize error handling across commands Some commands use '|| exit 1' for error handling while others don't. Consider standardizing this across all commands for consistency and robust error handling.
|
||
go mod download || exit 1 | ||
cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % env GOBIN=$(BIN) go install % || exit 1 | ||
# install golangci-lint | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN) v1.50.1 || exit 1 | ||
# install pkger | ||
cd $(TMP) && curl -sLO https://github.com/markbates/pkger/releases/download/v0.17.0/pkger_0.17.0_$(shell uname)_x86_64.tar.gz && \ | ||
tar -xzvf pkger_0.17.0_$(shell uname)_x86_64.tar.gz pkger && \ | ||
mv pkger $(BIN) || exit 1 | ||
# install goreleaser | ||
GOBIN=$(BIN) go install github.com/goreleaser/goreleaser@v1.3.1 || exit 1 | ||
|
||
$(DBASSET): | ||
$(call title,Building assets) | ||
mkdir -p $(ASSETS) || exit 1 | ||
@mkdir -p $(ASSETS) || exit 1 | ||
$(BIN)/license_serializer -output $(ASSETS) || exit 1 | ||
|
||
pkged.go: $(DBASSET) | ||
|
@@ -89,22 +81,19 @@ lint-fix: ## Auto-format all source code + run golangci-lint fixers | |
unit: ## Run unit tests (with coverage) | ||
$(call title,Running unit tests) | ||
go test -coverprofile $(COVER_REPORT) ./... | ||
@go tool cover -func $(COVER_REPORT) | grep total | awk '{print substr($$3, 1, length($$3)-1)}' > $(COVER_TOTAL) | ||
@go tool cover -func $(COVER_REPORT) | grep total | awk '{print substr($$3, 1, length($$3)-1)}' > $(COVER_TOTAL) | ||
@echo "Coverage: $$(cat $(COVER_TOTAL))" | ||
@if [ $$(echo "$$(cat $(COVER_TOTAL)) >= $(COVERAGE_THRESHOLD)" | bc -l) -ne 1 ]; then echo "$(RED)$(BOLD)Failed coverage quality gate (> $(COVERAGE_THRESHOLD)%)$(RESET)" && false; fi | ||
|
||
# The following targets are all CI related | ||
@if [ $$(echo "$$(cat $(COVER_TOTAL)) >= $(COVERAGE_THRESHOLD)" | bc -l) -ne 1 ]; then \ | ||
echo "$(RED)$(BOLD)Failed coverage quality gate (> $(COVERAGE_THRESHOLD)%)$(RESET)" && false; \ | ||
fi | ||
|
||
ci-build-snapshot-packages: pkged.go | ||
$(RELEASE_CMD) \ | ||
--snapshot \ | ||
--skip-publish | ||
$(RELEASE_CMD) --snapshot --skip-publish | ||
|
||
# note: since google's licenseclassifier requires the go tooling ('go list' from x/tools/go/packages) we need to use a golang image | ||
ci-plugs-out-test: | ||
docker run \ | ||
-v //var/run/docker.sock://var/run/docker.sock \ | ||
-v /${PWD}://src \ | ||
-v ${PWD}://src \ | ||
-w //src \ | ||
golang:latest \ | ||
/bin/bash -x -c "\ | ||
|
@@ -137,6 +126,4 @@ ci-release: pkged.go | |
$(BIN)/goreleaser --rm-dist | ||
|
||
clean: ## Clean build artifacts | ||
rm -rf dist | ||
rm -rf .tmp | ||
rm -rf $(RESULTS) | ||
rm -rf dist .tmp $(RESULTS) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider using the latest version of actions/setup-go
While updating from v1 to v2 is good, consider using the latest version (v4 as of now) for potential improvements and bug fixes.