Skip to content

Commit 4423ea6

Browse files
committed
Go 1.21
And minor `Makefile` improvements.
1 parent 3623ae4 commit 4423ea6

File tree

6 files changed

+51
-30
lines changed

6 files changed

+51
-30
lines changed

.github/actions/setup/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ runs:
66
steps:
77
- uses: actions/setup-go@v3
88
with:
9-
go-version: 1.19.x
9+
go-version: 1.21.x

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
run: make test-unit
2929

3030
- shell: bash
31-
run: make test-e2e
31+
run: make test-e2e

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.ci
22
.env
33
.vscode
4-
_output/
5-
coverage*
4+
bin/
5+
coverage*

.goreleaser.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
project_name: path-helper
3-
dist: ./_output/dist
3+
dist: ./bin/dist
44

55
builds:
66
- id: linux
@@ -9,23 +9,24 @@ builds:
99
goos:
1010
- linux
1111
env:
12-
- CGO_ENABLED=0
13-
- GO111MODULE=on
12+
- GOFLAGS="-v -a"
13+
- CGO_LDFLAGS="-s -w"
1414
flags:
1515
- -a
16-
- -mod=vendor
16+
- -v
1717
goarch:
1818
- amd64
19+
1920
- id: darwin
2021
binary: path-helper
2122
main: cmd/path-helper/main.go
2223
goos:
2324
- darwin
2425
env:
25-
- CGO_ENABLED=0
26-
- GO111MODULE=on
26+
- GOFLAGS="-v -a"
27+
- CGO_LDFLAGS="-s -w"
2728
flags:
2829
- -a
29-
- -mod=vendor
30+
- -v
3031
goarch:
31-
- amd64
32+
- amd64

Makefile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
APP = path-helper
2-
OUTPUT_DIR ?= _output
2+
OUTPUT_DIR ?= bin
33
VERSION ?= $(shell cat ./version)
44

55
BIN ?= $(OUTPUT_DIR)/$(APP)
6-
CMD ?= cmd/$(APP)/*
7-
PKG ?= pkg/$(APP)/*
6+
CMD ?= ./cmd/$(APP)/...
7+
PKG ?= ./pkg/$(APP)/...
8+
9+
GOFLAGS ?= -v -a
10+
CGO_LDFLAGS ?= -s -w
811

9-
E2E_DIR ?= test/e2e
1012
GOFLAGS_TEST ?= -failfast -race -coverprofile=coverage.txt -covermode=atomic -cover -v
11-
GOFLAGS ?= -v -a -ldflags=-s -mod=vendor
13+
14+
BATS_CORE ?= test/e2e/bats/core/bin/bats
15+
E2E_DIR ?= test/e2e
16+
E2E_TEST_GLOB ?= *.bats
17+
E2E_TESTS = $(E2E_DIR)/$(E2E_TEST_GLOB)
1218

1319
ARGS ?=
1420

1521
.EXPORT_ALL_VARIABLES:
1622

1723
default: build
1824

19-
.PHONY: $(BIN)
2025
$(BIN):
2126
go build -o $(BIN) $(CMD)
27+
2228
build: $(BIN)
2329

2430
.PHONY: run
@@ -30,17 +36,17 @@ install: build
3036

3137
.PHONY: clean
3238
clean:
33-
rm -rf $(OUTPUT_DIR) > /dev/null
39+
rm -rf $(OUTPUT_DIR) >/dev/null
3440

3541
test: test-unit test-e2e
3642

3743
.PHONY: test-unit
3844
test-unit:
39-
go test $(GOFLAGS_TEST) pkg/$(APP)/*
45+
go test $(GOFLAGS_TEST) $(CMD) $(PKG)
4046

4147
.PHONY: test-e2e
42-
test-e2e:
43-
./test/e2e/bats/core/bin/bats --recursive $(E2E_DIR)/*.bats
48+
test-e2e: $(BIN)
49+
$(BATS_CORE) --trace --verbose-run --recursive $(E2E_TESTS)
4450

4551
codecov:
4652
mkdir .ci || true

test/e2e/path-helper.bats

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,48 @@
11
#!/usr/bin/env bats
22

3-
BASE_DIR="./test/paths.d"
4-
PATH_HELPER="./_output/path-helper -p $BASE_DIR -m $BASE_DIR"
3+
declare -r BIN="${BIN:-}"
4+
5+
BASE_DIR="${PWD}/test/paths.d"
6+
PATH_HELPER="${BIN} -p ${BASE_DIR} -m ${BASE_DIR}"
57

68
PATHS="/a/a/a:/b/b/b:/c/c/c:/d/d/d"
79
PATHS_DUP="/a/a/a:/b/b/b:/c/c/c:/d/d/d:/d/d/d"
810

9-
EXPR="PATH=\"$PATHS\" ; MANPATH=\"$PATHS\" ; export PATH MANPATH ;"
10-
EXPR_DUP="PATH=\"$PATHS_DUP\" ; MANPATH=\"$PATHS_DUP\" ; export PATH MANPATH ;"
11+
EXPR="PATH=\"${PATHS}\" ; MANPATH=\"${PATHS}\" ; export PATH MANPATH ;"
12+
EXPR_DUP="PATH=\"${PATHS_DUP}\" ; MANPATH=\"${PATHS_DUP}\" ; export PATH MANPATH ;"
1113

1214
@test "without-duplicates-and-witout-not-founds" {
13-
run $PATH_HELPER
15+
[ -f "${BIN}" && -n "${PATH_HELPER}" && -d "${BASE_DIR}" ]
16+
17+
run ${PATH_HELPER}
18+
1419
[ "$status" = 0 ]
1520
[ "$output" = "PATH=\"\" ; MANPATH=\"\" ; export PATH MANPATH ;" ]
1621
}
1722

1823
@test "with-duplicates" {
19-
run $PATH_HELPER -s=false
24+
[ -f "${BIN}" && -n "${PATH_HELPER}" && -d "${BASE_DIR}" ]
25+
26+
run ${PATH_HELPER} -s=false
27+
2028
[ "$status" = 0 ]
2129
[ "$output" = "PATH=\"\" ; MANPATH=\"\" ; export PATH MANPATH ;" ]
2230
}
2331

2432
@test "with-not-founds" {
25-
run $PATH_HELPER -d=false
33+
[ -f "${BIN}" && -n "${PATH_HELPER}" && -d "${BASE_DIR}" ]
34+
35+
run ${PATH_HELPER} -d=false
36+
2637
[ "$status" = 0 ]
2738
[ "$output" = "$EXPR" ]
2839
}
2940

3041
@test "with-duplicates-and-with-not-founds" {
31-
run $PATH_HELPER -s=false -d=false
42+
[ -f "${BIN}" && -n "${PATH_HELPER}" && -d "${BASE_DIR}" ]
43+
44+
run ${PATH_HELPER} -s=false -d=false
45+
3246
[ "$status" = 0 ]
3347
[ "$output" = "$EXPR_DUP" ]
3448
}

0 commit comments

Comments
 (0)