-
Notifications
You must be signed in to change notification settings - Fork 472
/
Copy pathjustfile
66 lines (52 loc) · 2.64 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
set quiet
import? '../sdk-codegen/utils.just'
# ensure tools installed with `go install` are available to call
export PATH := home_directory() + "/go/bin:" + env('PATH')
_default:
just --list --unsorted
# ⭐ run all unit tests, or pass a package name (./invoice) to only run those tests
test *args="./...":
go run scripts/test_with_stripe_mock/main.go -race {{ args }}
# check for potential mistakes (slow)
lint: install
go vet ./...
staticcheck
# don't depend on `install` in this step! Before formatting, our `go` code isn't syntactically valid
# ⭐ format all files
format: _normalize-imports install
scripts/gofmt.sh
goimports -w example/generated_examples_test.go
# verify, but don't modify, the formatting of the files
format-check:
scripts/gofmt.sh check
# ensures all client structs are properly registered
check-api-clients:
go run scripts/check_api_clients/main.go
ci-test: test bench check-api-clients
# compile the project
build:
go build ./...
# install dependencies (including those needed for development). Mostly called by other recipes
install:
go get -t
go install honnef.co/go/tools/cmd/[email protected]
go install golang.org/x/tools/cmd/[email protected]
# run benchmarking to check for performance regressions
bench:
go test -race -bench . -run "Benchmark" ./form
# called by tooling. It updates the package version in the `VERSION` file and `stripe.go`
[private]
update-version version: && _normalize-imports
echo "{{ version }}" > VERSION
perl -pi -e 's|const clientversion = "[.\d\-\w]+"|const clientversion = "{{ version }}"|' stripe.go
# go imports use the package's major version in the path, so we need to update them
# we also generate files with a placeholder `[MAJOR_VERSION]` that we need to replace
# we can pull the major version out of the `VERSION` file
# NOTE: because we run this _after_ other recipes that modify `VERSION`, it's important that we only read the file in the argument evaluation
# (if it's a top-level variable, it's read when the file is parsed, which is too early)
# arguments are only evaluated when the recipe starts
# so, setting it as the default means we get both the variable and the lazy evaluation we need
_normalize-imports major_version=replace_regex(`cat VERSION`, '\..*', ""):
perl -pi -e 's|github.com/stripe/stripe-go/v\d+|github.com/stripe/stripe-go/v{{ major_version }}|' README.md
perl -pi -e 's|github.com/stripe/stripe-go/v\d+|github.com/stripe/stripe-go/v{{ major_version }}|' go.mod
find . -name '*.go' -exec perl -pi -e 's|github.com/stripe/stripe-go/(v\d+\|\[MAJOR_VERSION\])|github.com/stripe/stripe-go/v{{ major_version }}|' {} +