diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a56bbf9..e5340c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,14 +21,13 @@ permissions: jobs: build-and-verify: - uses: Open-CMSIS-Pack/workflows-and-actions-collection/.github/workflows/build-and-verify.yml@v1.0.0 + uses: Open-CMSIS-Pack/workflows-and-actions-collection/.github/workflows/build-and-verify.yml@v1.0.1 secrets: QLTY_COVERAGE_TOKEN: ${{ secrets.QLTY_COVERAGE_TOKEN }} with: program: cbuild2cmake go-version-file: ./go.mod - enable-code-climate: true - artifact-retention-days: 7 + enable-qlty-coverage: true publish-test-results: name: "Publish Tests Results" diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index af44d8a..368a2fc 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -12,7 +12,7 @@ permissions: read-all jobs: markdown-check: - uses: Open-CMSIS-Pack/workflows-and-actions-collection/.github/workflows/markdown-lint.yml@v1.0.0 + uses: Open-CMSIS-Pack/workflows-and-actions-collection/.github/workflows/markdown-lint.yml@v1.0.1 with: lint-config: '.github/markdownlint.jsonc' link-check-config: '.github/markdown-link-check.jsonc' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6814e30..1a6309d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,11 +12,11 @@ on: jobs: build-and-verify: - uses: Open-CMSIS-Pack/workflows-and-actions-collection/.github/workflows/build-and-verify.yml@v1.0.0 + uses: Open-CMSIS-Pack/workflows-and-actions-collection/.github/workflows/build-and-verify.yml@v1.0.1 with: program: cbuild2cmake go-version-file: ./go.mod - enable-code-climate: false + enable-qlty-coverage: false goreleaser: needs: [ build-and-verify ] diff --git a/.github/workflows/update-workflows.yml b/.github/workflows/update-workflows.yml index 7ebfb9a..756d55a 100644 --- a/.github/workflows/update-workflows.yml +++ b/.github/workflows/update-workflows.yml @@ -11,6 +11,6 @@ permissions: jobs: update-workflows: - uses: Open-CMSIS-Pack/workflows-and-actions-collection/.github/workflows/update-workflow.yml@v1.0.0 + uses: Open-CMSIS-Pack/workflows-and-actions-collection/.github/workflows/update-workflow.yml@v1.0.1 secrets: - TOKEN_ACCESS: ${{ secrets.GITHUB_TOKEN }} + TOKEN_ACCESS: ${{ secrets.GRASCI_WORKFLOW_UPDATE }} diff --git a/makefile b/makefile index 0cb07ee..f0958c9 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,10 @@ OS ?= $(shell uname) # Having this will allow CI scripts to build for many OS's and ARCH's -ARCH := $(or $(ARCH),amd64) +ARCH ?= $(shell uname -m) + +# Retrieve version from git history +VERSION ?= $(shell git describe --tags 2>/dev/null || echo unknown) # Path to lint tool GOLINTER ?= golangci-lint @@ -20,6 +23,14 @@ else # Default to Linux OS=linux endif +ifneq (,$(findstring x86_64,$(ARCH))) + ARCH=amd64 +else ifneq (,$(findstring aarch64,$(ARCH))) + ARCH=arm64 +else ifneq (,$(findstring unknown,$(ARCH))) + # fallback + ARCH=amd64 +endif SOURCES := $(wildcard cmd/cbuild2cmake/*.go) $(wildcard pkg/*/*.go) @@ -53,7 +64,8 @@ all: $(PROG): $(SOURCES) @echo Building project - GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-X main.version=`git describe 2>/dev/null || echo unknown`" -o $(PROG) ./cmd/cbuild2cmake + GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-X main.version=$(VERSION)" -o $(PROG) ./cmd/cbuild2cmake + build: $(PROG) @@ -67,21 +79,22 @@ format: $(GOFORMATTER) -s -w . format-check: - mkdir -p build && $(GOFORMATTER) -d . | tee build/format-check.out - test ! -s build/format-check.out + $(GOFORMATTER) -d . | tee format-check.out + test ! -s format-check.out .PHONY: test release config test: $(SOURCES) - mkdir -p build && GOOS=$(OS) GOARCH=$(ARCH) go test $(ARGS) -v ./... -coverprofile build/cover.out + GOOS=$(OS) GOARCH=$(ARCH) go test $(ARGS) -v ./... -coverprofile ./cover.out test-all: format-check coverage-check lint coverage-report: test - go tool cover -html=build/cover.out + go tool cover -html=./cover.out coverage-check: test + @echo "Current coverage is: $(shell go tool cover -func ./cover.out | tail -1 | awk '{print ($$3 + 0)}')"% @echo Checking if test coverage is above 80% - test `go tool cover -func build/cover.out | tail -1 | awk '{print ($$3 + 0)*10}'` -ge 800 + test `go tool cover -func ./cover.out | tail -1 | awk '{print ($$3 + 0)*10}'` -ge 800 release: test-all $(PROG) @./scripts/release @@ -93,5 +106,6 @@ config: # Install pre-commit hooks cp scripts/pre-commit .git/hooks/pre-commit + clean: - rm -rf build + rm -rf build/*