forked from google/go-licenses
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update pipeline.yaml Signed-off-by: gitworkflows <[email protected]> * Update Makefile Signed-off-by: gitworkflows <[email protected]> * Update golicenses.sh Signed-off-by: gitworkflows <[email protected]> * Update goreleaser.yaml Signed-off-by: gitworkflows <[email protected]> * Update pipeline.yaml Signed-off-by: gitworkflows <[email protected]> * Update Makefile Signed-off-by: gitworkflows <[email protected]> * Update pipeline.yaml Signed-off-by: gitworkflows <[email protected]> --------- Signed-off-by: gitworkflows <[email protected]>
- Loading branch information
1 parent
1dce744
commit f3d1abd
Showing
4 changed files
with
125 additions
and
57 deletions.
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 |
---|---|---|
|
@@ -7,15 +7,26 @@ 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) | ||
CYAN := $(shell tput -T linux setaf 6) | ||
RED := $(shell tput -T linux setaf 1) | ||
RESET := $(shell tput -T linux sgr0) | ||
# Color definitions with checks for OS | ||
ifeq ($(OS),Windows_NT) | ||
BOLD := "" | ||
PURPLE := "" | ||
GREEN := "" | ||
CYAN := "" | ||
RED := "" | ||
RESET := "" | ||
else | ||
BOLD := $(shell tput -T linux bold) | ||
PURPLE := $(shell tput -T linux setaf 5) | ||
GREEN := $(shell tput -T linux setaf 2) | ||
CYAN := $(shell tput -T linux setaf 6) | ||
RED := $(shell tput -T linux setaf 1) | ||
RESET := $(shell tput -T linux sgr0) | ||
endif | ||
|
||
TITLE := $(BOLD)$(PURPLE) | ||
SUCCESS := $(BOLD)$(GREEN) | ||
COVERAGE_THRESHOLD := 34 | ||
COVERAGE_THRESHOLD := 55 | ||
|
||
RELEASE_CMD=$(BIN)/goreleaser --rm-dist | ||
|
||
|
@@ -31,7 +42,7 @@ define title | |
@printf '$(TITLE)$(1)$(RESET)\n' | ||
endef | ||
|
||
.PHONY: all bootstrap lint lint-fix unit coverage help test clean ci-build-snapshot-packages ci-plugs-out-test ci-test-linux-run ci-test-linux-arm-run ci-test-mac-run ci-test-mac-arm-run ci-release | ||
.PHONY: all bootstrap lint lint-fix unit coverage help test clean | ||
|
||
all: lint test ## Run all checks (linting, unit tests, and integration tests) | ||
@printf '$(SUCCESS)All checks pass!$(RESET)\n' | ||
|
@@ -43,40 +54,33 @@ help: | |
|
||
bootstrap: ## Download and install all project dependencies (+ prep tooling in the ./.tmp dir) | ||
$(call title,Downloading dependencies) | ||
@mkdir -p $(TMP) $(RESULTS) $(BIN) || exit 1 | ||
go mod download || exit 1 | ||
cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % env GOBIN=$(BIN) go install % || exit 1 | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN) v1.50.1 || exit 1 | ||
mkdir -p $(TMP) $(RESULTS) $(BIN) # Create necessary directories | ||
go mod download | ||
cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % env GOBIN=$(BIN) go install % | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN) v1.47.2 | ||
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 | ||
GOBIN=$(BIN) go install github.com/goreleaser/[email protected] || exit 1 | ||
mv pkger $(BIN) | ||
GOBIN=$(BIN) go install github.com/goreleaser/[email protected] | ||
|
||
$(DBASSET): | ||
$(call title,Building assets) | ||
@mkdir -p $(ASSETS) || exit 1 | ||
$(BIN)/license_serializer -output $(ASSETS) || exit 1 | ||
mkdir -p $(ASSETS) | ||
$(BIN)/license_serializer -output $(ASSETS) | ||
|
||
pkged.go: $(DBASSET) | ||
$(BIN)/pkger || exit 1 | ||
$(BIN)/pkger | ||
|
||
lint: ## Run gofmt + golangci-lint checks | ||
lint: ## Run gofmt + golangci lint checks | ||
$(call title,Running linters) | ||
@FILES_WITH_ISSUES="$(shell gofmt -l -s .)"; \ | ||
if [ -n "$$FILES_WITH_ISSUES" ]; then \ | ||
echo "The following files have gofmt issues:"; \ | ||
echo "$$FILES_WITH_ISSUES"; \ | ||
exit 1; \ | ||
fi | ||
@printf "Running golangci-lint...\n" | ||
$(LINTCMD) || exit 1 | ||
@printf "files with gofmt issues: [$(shell gofmt -l -s .)]\n" | ||
@test -z "$(shell gofmt -l -s .)" | ||
$(LINTCMD) | ||
|
||
lint-fix: ## Auto-format all source code + run golangci-lint fixers | ||
lint-fix: ## Auto-format all source code + run golangci lint fixers | ||
$(call title,Running lint fixers) | ||
@echo "Running gofmt to auto-format code..." | ||
@gofmt -w -s . || exit 1 | ||
@echo "Running golangci-lint with --fix..." | ||
$(LINTCMD) --fix || exit 1 | ||
gofmt -w -s . | ||
$(LINTCMD) --fix | ||
|
||
unit: ## Run unit tests (with coverage) | ||
$(call title,Running unit tests) | ||
|
@@ -88,7 +92,9 @@ unit: ## Run unit tests (with coverage) | |
fi | ||
|
||
ci-build-snapshot-packages: pkged.go | ||
$(RELEASE_CMD) --snapshot --skip-publish | ||
$(RELEASE_CMD) \ | ||
--snapshot \ | ||
--skip-publish | ||
|
||
ci-plugs-out-test: | ||
docker run \ | ||
|
@@ -97,33 +103,39 @@ ci-plugs-out-test: | |
-w //src \ | ||
golang:latest \ | ||
/bin/bash -x -c "\ | ||
./dist/go-licenses_linux_amd64/golicenses version && \ | ||
./dist/go-licenses_linux_amd64/golicenses list github.com/khulnasoft/go-licenses && \ | ||
./dist/go-licenses_linux_amd64/golicenses check github.com/khulnasoft/go-licenses \ | ||
./dist/linux-build_linux_amd64/golicenses version && \ | ||
./dist/linux-build_linux_amd64/golicenses list github.com/khulnasoft/go-licenses && \ | ||
./dist/linux-build_linux_amd64/golicenses check github.com/khulnasoft/go-licenses \ | ||
" | ||
|
||
ci-test-linux-run: | ||
chmod 755 ./dist/go-licenses_linux_amd64/golicenses && \ | ||
./dist/go-licenses_linux_amd64/golicenses version && \ | ||
./dist/go-licenses_linux_amd64/golicenses list github.com/khulnasoft/go-licenses | ||
chmod 755 ./dist/linux-build_linux_amd64/golicenses && \ | ||
./dist/linux-build_linux_amd64/golicenses version && \ | ||
./dist/linux-build_linux_amd64/golicenses list github.com/khulnasoft/go-licenses | ||
|
||
ci-test-linux-arm-run: | ||
chmod 755 ./dist/go-licenses_linux_arm64/golicenses && \ | ||
./dist/go-licenses_linux_arm64/golicenses version && \ | ||
./dist/go-licenses_linux_arm64/golicenses list github.com/khulnasoft/go-licenses | ||
chmod 755 ./dist/linux-build_linux_arm64/golicenses && \ | ||
./dist/linux-build_linux_arm64/golicenses version && \ | ||
./dist/linux-build_linux_arm64/golicenses list github.com/khulnasoft/go-licenses | ||
|
||
ci-test-mac-run: | ||
chmod 755 ./dist/go-licenses_darwin_amd64/golicenses && \ | ||
./dist/go-licenses_darwin_amd64/golicenses version && \ | ||
./dist/go-licenses_darwin_amd64/golicenses list github.com/khulnasoft/go-licenses | ||
chmod 755 ./dist/darwin-build_darwin_amd64/golicenses && \ | ||
./dist/darwin-build_darwin_amd64/golicenses version && \ | ||
./dist/darwin-build_darwin_amd64/golicenses list github.com/khulnasoft/go-licenses | ||
|
||
ci-test-mac-arm-run: | ||
chmod 755 ./dist/go-licenses_darwin_arm64/golicenses && \ | ||
./dist/go-licenses_darwin_arm64/golicenses version && \ | ||
./dist/go-licenses_darwin_arm64/golicenses list github.com/khulnasoft/go-licenses | ||
chmod 755 ./dist/darwin-build_darwin_arm64/golicenses && \ | ||
./dist/darwin-build_darwin_arm64/golicenses version && \ | ||
./dist/darwin-build_darwin_arm64/golicenses list github.com/khulnasoft/go-licenses | ||
|
||
ci-test-windows-run: | ||
@echo "Running Windows tests..." | ||
@powershell -Command "Start-Process -NoNewWindow -File ./dist/windows-build_windows_amd64/golicenses.exe -ArgumentList 'version' -Wait" | ||
@powershell -Command "Start-Process -NoNewWindow -File ./dist/windows-build_windows_amd64/golicenses.exe -ArgumentList 'list github.com/khulnasoft/go-licenses' -Wait" | ||
|
||
ci-release: pkged.go | ||
$(BIN)/goreleaser --rm-dist | ||
|
||
clean: ## Clean build artifacts | ||
rm -rf dist .tmp $(RESULTS) | ||
clean: | ||
rm -rf dist | ||
rm -rf .tmp |
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 |
---|---|---|
@@ -1,17 +1,46 @@ | ||
release: | ||
prerelease: auto | ||
|
||
env: | ||
- CGO_ENABLED=0 | ||
|
||
builds: | ||
- binary: golicenses | ||
env: | ||
- CGO_ENABLED=0 | ||
- id: linux-build | ||
binary: golicenses | ||
goos: | ||
- darwin | ||
- linux | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.buildTime={{.Date}}`. | ||
ldflags: &build-ldflags -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.buildTime={{.Date}}`. | ||
|
||
- id: darwin-build | ||
binary: golicenses | ||
goos: | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
ldflags: *build-ldflags | ||
|
||
- id: windows-build | ||
binary: golicenses | ||
goos: | ||
- windows | ||
goarch: | ||
- amd64 | ||
ldflags: *build-ldflags | ||
|
||
archives: | ||
- format: tar.gz | ||
- id: linux-archives | ||
builds: | ||
- linux-build | ||
|
||
- id: darwin-archives | ||
builds: | ||
- darwin-build | ||
|
||
- id: windows-archives | ||
format: zip | ||
builds: | ||
- windows-build |