diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index bc7c1fcb267a84f14cbbacaaa034832cc5aaf357..0000000000000000000000000000000000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,74 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "main" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "main" ] - schedule: - - cron: '28 8 * * 6' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'go' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # âšī¸ Command-line programs to run using the OS shell. - # đ See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 315e7fe220bd3c51196940a07e606391c734c099..c191eee963d27704ad9403cbd0ddea128481b056 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -6,6 +6,11 @@ on: pull_request: branches: [main] # pull requests AGAINST main +# cancel CI runs when a new commit is pushed to any branch except main +concurrency: + group: "lint-${{ github.ref }}" + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: golangci: name: Lint @@ -17,4 +22,4 @@ jobs: go-version: '1.20' - uses: golangci/golangci-lint-action@v3.4.0 with: - version: v1.51.1 + version: v1.52.2 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a1c920c9b24b8b9044a371a27ec783b39abf89db..4d6052be91e19122d66369ec6f0b862e3dcd6519 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,6 +11,11 @@ on: pull_request: branches: [main] +# cancel CI runs when a new commit is pushed to any branch except main +concurrency: + group: "test-${{ github.ref }}" + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: test: name: Test diff --git a/Makefile b/Makefile index 214324e07ea700df91c0adacd0d4aaeef91e9774..9a10cbeab04eb44e99841f69c55c6531d633215a 100644 --- a/Makefile +++ b/Makefile @@ -11,10 +11,10 @@ COVERAGE_PATH ?= coverage.txt COVERAGE_ARGS ?= -covermode=atomic -coverprofile=$(COVERAGE_PATH) TEST_ARGS ?= -race -# Tool dependencies -TOOL_BIN_DIR ?= $(shell go env GOPATH)/bin -TOOL_GOLINT := $(TOOL_BIN_DIR)/golint -TOOL_STATICCHECK := $(TOOL_BIN_DIR)/staticcheck +# 3rd party tools +GOLINT := go run golang.org/x/lint/golint@latest +REFLEX := go run github.com/cespare/reflex@v0.3.1 +STATICCHECK := go run honnef.co/go/tools/cmd/staticcheck@2023.1.3 # ============================================================================= @@ -58,11 +58,11 @@ testcover: testci go tool cover -html=$(COVERAGE_PATH) .PHONY: testcover -lint: $(TOOL_GOLINT) $(TOOL_STATICCHECK) +lint: test -z "$$(gofmt -d -s -e .)" || (echo "Error: gofmt failed"; gofmt -d -s -e . ; exit 1) go vet ./... - $(TOOL_GOLINT) -set_exit_status ./... - $(TOOL_STATICCHECK) ./... + $(GOLINT) -set_exit_status ./... + $(STATICCHECK) ./... .PHONY: lint @@ -73,8 +73,8 @@ run: build $(DIST_PATH)/go-httpbin .PHONY: run -watch: $(TOOL_REFLEX) - reflex -s -r '\.(go|html)$$' make run +watch: + $(REFLEX) -s -r '\.(go|html)$$' make run .PHONY: watch @@ -91,18 +91,3 @@ imagepush: docker buildx build --push --platform linux/amd64,linux/arm64 -t $(DOCKER_TAG) . docker buildx rm httpbin .PHONY: imagepush - - -# ============================================================================= -# dependencies -# -# Deps are installed outside of working dir to avoid polluting go modules -# ============================================================================= -$(TOOL_GOLINT): - go install golang.org/x/lint/golint@latest - -$(TOOL_REFLEX): - go install github.com/cespare/reflex@0.3.1 - -$(TOOL_STATICCHECK): - go install honnef.co/go/tools/cmd/staticcheck@v0.3.0