diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..3f6e468e --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Lint +on: + push: + pull_request: + +jobs: + lint: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '~1.19' + - name: Clone the code + uses: actions/checkout@v4 + - name: Run linter + uses: golangci/golangci-lint-action@v3 + with: + version: v1.51.2 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..eb4ff13e --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,3 @@ +run: + deadline: 5m + allow-parallel-runners: true diff --git a/.jobserv.yml b/.jobserv.yml index f4952541..5d8df7c0 100644 --- a/.jobserv.yml +++ b/.jobserv.yml @@ -1,13 +1,5 @@ timeout: 30 triggers: - - name: pull-request - type: github_pr - runs: - - name: unit-test - container: golangci/golangci-lint:v1.51.2 - host-tag: amd64 - script: unit-test - - name: create-release type: git_poller params: diff --git a/Makefile b/Makefile index 8ba1a593..314edd89 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,6 @@ COMMIT?=$(shell git describe HEAD)$(shell git diff --quiet || echo '+dirty') # Use linker flags to provide commit info LDFLAGS=-ldflags "-X=github.com/foundriesio/fioctl/subcommands/version.Commit=$(COMMIT)" -linter:=$(shell which golangci-lint 2>/dev/null || echo $(HOME)/go/bin/golangci-lint) - build: fioctl-linux-amd64 fioctl-linux-arm64 fioctl-windows-amd64 fioctl-darwin-amd64 fioctl-darwin-arm64 @true @@ -24,12 +22,25 @@ fioctl-%: go build $(LDFLAGS) -o bin/$@ main.go @if [ "$@" = "fioctl-windows-amd64" ]; then mv bin/$@ bin/$@.exe; fi +GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint +install-linter: + echo "[WARN] Installing golangci binary version v1.51.2 into the project's bin/ directory for this check" + @curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.51.2 + +has-linter: + @test -x $(GOLANGCI_LINT) || (echo '[ERROR] Please install go linter using "make install-linter"' && exit 1) + +lint-check: has-linter ## Run linter + $(GOLANGCI_LINT) run + +lint-fix: has-linter ## Run golangci-lint linter and perform fixes + $(GOLANGCI_LINT) run --fix + format: @gofmt -l -w ./ check: @test -z $(shell gofmt -l ./ | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make format'" - @test -x $(linter) || (echo "Please install linter from https://github.com/golangci/golangci-lint/releases/tag/v1.51.2 to $(HOME)/go/bin") - $(linter) run + make lint-check # Use the image for Dockerfile.build to build and install the tool. container-init: diff --git a/subcommands/keys/ca_show.go b/subcommands/keys/ca_show.go index 9b1ba47f..122f45ea 100644 --- a/subcommands/keys/ca_show.go +++ b/subcommands/keys/ca_show.go @@ -169,6 +169,7 @@ func prettyPrint(cert string) { case *ecdsa.PublicKey: fmt.Println("\t\tNIST CURVE:", pub.Curve.Params().Name) fmt.Print("\t\t\t") + for idx, b := range elliptic.Marshal(pub.Curve, pub.X, pub.Y) { fmt.Printf("%02x:", b) if (idx+1)%15 == 0 {