|
1 | 1 |
|
2 | | -GO=$(shell which go) |
3 | | - |
4 | | -RELEASE_FOLDER=dist/release |
5 | | - |
6 | | -CHECKSUM=$(shell which sha256sum) |
7 | | - |
8 | | -VOLUME_MOUNTS=-v "$(CURDIR):/v" |
9 | | -SIGN?=docker run --rm -i $(VOLUME_MOUNTS) -e SM_API_KEY -e SM_CLIENT_CERT_PASSWORD -e SM_CLIENT_CERT_FILE -v "$(SM_CLIENT_CERT_FILE):$(SM_CLIENT_CERT_FILE)" -w "/v" registry.mirantis.com/prodeng/digicert-keytools-jsign:latest sign |
10 | | - |
11 | | -GOLANGCI_LINT?=docker run -t --rm -v "$(CURDIR):/data" -w "/data" golangci/golangci-lint:latest golangci-lint |
12 | | - |
13 | | -SEGMENT_TOKEN?="" |
14 | | - |
15 | 2 | .PHONY: clean |
16 | 3 | clean: |
17 | 4 | rm -fr dist |
18 | 5 |
|
19 | | -# Sign release binaries (Windows) |
20 | | -# (build may need to be run in a separate make run) |
21 | | -.PHONY: sign-release |
22 | | -sign-release: $(RELEASE_FOLDER) |
23 | | - for f in `find $(RELEASE_FOLDER)/*.exe`; do echo $(SIGN) "$$f"; done |
| 6 | +# TODO: Digicert signing will be reimplemented in GitHub Actions. |
24 | 7 |
|
25 | | -# Force a clean build of the artifacts by first cleaning |
26 | | -# and then building |
27 | | -.PHONY: build-release |
28 | | -build-release: clean $(RELEASE_FOLDER) |
29 | | -# build all the binaries for release, using goreleaser, but |
30 | | -# don't use any of the other features of goreleaser - because |
31 | | -# we need to use digicert to sign the binaries first, and |
32 | | -# goreleaser doesn't allow for that (some pro features may |
33 | | -# allow it in a round about way.) |
34 | | -# |
35 | | -# If you are using more than one tag for a commit, then use |
36 | | -# the GORELEASER_CURRENT_TAG env var to clarify the version to |
37 | | -# avoid having the wrong tag version applied |
38 | | -$(RELEASE_FOLDER): |
39 | | - SEGMENT_TOKEN=${SEGMENT_TOKEN} goreleaser build --clean --config=.goreleaser.release.yml |
40 | | - |
41 | | -.PHONY: create-checksum |
42 | | -create-checksum: |
43 | | - cd $(RELEASE_FOLDER) && \ |
44 | | - for f in *; do \ |
45 | | - $(CHECKSUM) $$f > $$f.sha256; \ |
46 | | - done |
47 | | - |
48 | | -.PHONY: verify-checksum |
49 | | -verify-checksum: |
50 | | - for f in $(RELEASE_FOLDER)/*.sha256; do \ |
51 | | - $(CHECKSUM) -c $$f; \ |
52 | | - echo "Verified checksum for $$f"; \ |
53 | | - done |
54 | | - |
55 | | -# clean out any existing release build |
56 | | -.PHONY: clean-release |
57 | | -clean-release: |
58 | | - rm -fr $(RELEASE_FOLDER) |
59 | | - |
60 | | -# Local build of the plugin. This saves time building platforms that you |
61 | | -# won't test locally. To use it, find the path to your build binary path |
62 | | -# and alias it. |
| 8 | +# Local build of the plugin. This saves time building only the host platform. |
| 9 | +# Uses native Go commands to avoid Goreleaser dependency. |
63 | 10 | .PHONY: local |
64 | 11 | local: |
65 | | - SEGMENT_TOKEN=${SEGMENT_TOKEN} goreleaser build --clean --single-target --skip=validate --snapshot --config .goreleaser.local.yml |
| 12 | + mkdir -p dist |
| 13 | + GOOS=$(shell go env GOOS) GOARCH=$(shell go env GOARCH) \ |
| 14 | + output_name="dist/launchpad_$${GOOS}_$${GOARCH}"; \ |
| 15 | + if [ "$${GOOS}" = "windows" ]; then \ |
| 16 | + output_name="$${output_name}.exe"; \ |
| 17 | + fi; \ |
| 18 | + go build -o "$${output_name}" ./main.go && \ |
| 19 | + ./$${output_name} --help |
66 | 20 |
|
67 | 21 | # run linting |
68 | 22 | .PHONY: lint |
69 | 23 | lint: |
70 | | - $(GOLANGCI_LINT) run |
| 24 | + golangci-lint run |
| 25 | + |
| 26 | +# security scanning |
| 27 | +.PHONY: security-scan |
| 28 | +security-scan: |
| 29 | + govulncheck ./... |
71 | 30 |
|
72 | 31 | # Testing related targets |
73 | 32 |
|
74 | 33 | # TEST_FLAGS can be set in CI to e.g. -short to skip tests that need network/OCI |
75 | 34 | TEST_FLAGS?= |
76 | 35 | .PHONY: unit-test |
77 | 36 | unit-test: |
78 | | - $(GO) test -v --tags 'testing' $(TEST_FLAGS) ./pkg/... |
| 37 | + go test -v --tags 'testing' $(TEST_FLAGS) ./pkg/... |
79 | 38 |
|
80 | 39 | .PHONY: functional-test |
81 | 40 | functional-test: |
|
0 commit comments