Skip to content

Commit c9f5002

Browse files
authored
Build & CI updates (#116)
A few small tweaks: - Simplify makefile - Cancel in-progress CI jobs when new commits are pushed to a non-main branch - Drop manual codeql config now that GitHub supports automagical configuration
1 parent cbbc296 commit c9f5002

File tree

4 files changed

+20
-99
lines changed

4 files changed

+20
-99
lines changed

.github/workflows/codeql.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

.github/workflows/lint.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
pull_request:
77
branches: [main] # pull requests AGAINST main
88

9+
# cancel CI runs when a new commit is pushed to any branch except main
10+
concurrency:
11+
group: "lint-${{ github.ref }}"
12+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
13+
914
jobs:
1015
golangci:
1116
name: Lint
@@ -17,4 +22,4 @@ jobs:
1722
go-version: '1.20'
1823
- uses: golangci/[email protected]
1924
with:
20-
version: v1.51.1
25+
version: v1.52.2

.github/workflows/test.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
pull_request:
1212
branches: [main]
1313

14+
# cancel CI runs when a new commit is pushed to any branch except main
15+
concurrency:
16+
group: "test-${{ github.ref }}"
17+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
18+
1419
jobs:
1520
test:
1621
name: Test

Makefile

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ COVERAGE_PATH ?= coverage.txt
1111
COVERAGE_ARGS ?= -covermode=atomic -coverprofile=$(COVERAGE_PATH)
1212
TEST_ARGS ?= -race
1313

14-
# Tool dependencies
15-
TOOL_BIN_DIR ?= $(shell go env GOPATH)/bin
16-
TOOL_GOLINT := $(TOOL_BIN_DIR)/golint
17-
TOOL_STATICCHECK := $(TOOL_BIN_DIR)/staticcheck
14+
# 3rd party tools
15+
GOLINT := go run golang.org/x/lint/golint@latest
16+
REFLEX := go run github.com/cespare/[email protected]
17+
STATICCHECK := go run honnef.co/go/tools/cmd/staticcheck@2023.1.3
1818

1919

2020
# =============================================================================
@@ -58,11 +58,11 @@ testcover: testci
5858
go tool cover -html=$(COVERAGE_PATH)
5959
.PHONY: testcover
6060

61-
lint: $(TOOL_GOLINT) $(TOOL_STATICCHECK)
61+
lint:
6262
test -z "$$(gofmt -d -s -e .)" || (echo "Error: gofmt failed"; gofmt -d -s -e . ; exit 1)
6363
go vet ./...
64-
$(TOOL_GOLINT) -set_exit_status ./...
65-
$(TOOL_STATICCHECK) ./...
64+
$(GOLINT) -set_exit_status ./...
65+
$(STATICCHECK) ./...
6666
.PHONY: lint
6767

6868

@@ -73,8 +73,8 @@ run: build
7373
$(DIST_PATH)/go-httpbin
7474
.PHONY: run
7575

76-
watch: $(TOOL_REFLEX)
77-
reflex -s -r '\.(go|html)$$' make run
76+
watch:
77+
$(REFLEX) -s -r '\.(go|html)$$' make run
7878
.PHONY: watch
7979

8080

@@ -91,18 +91,3 @@ imagepush:
9191
docker buildx build --push --platform linux/amd64,linux/arm64 -t $(DOCKER_TAG) .
9292
docker buildx rm httpbin
9393
.PHONY: imagepush
94-
95-
96-
# =============================================================================
97-
# dependencies
98-
#
99-
# Deps are installed outside of working dir to avoid polluting go modules
100-
# =============================================================================
101-
$(TOOL_GOLINT):
102-
go install golang.org/x/lint/golint@latest
103-
104-
$(TOOL_REFLEX):
105-
go install github.com/cespare/[email protected]
106-
107-
$(TOOL_STATICCHECK):
108-
go install honnef.co/go/tools/cmd/[email protected]

0 commit comments

Comments
 (0)