-
Notifications
You must be signed in to change notification settings - Fork 200
/
devbox.json
75 lines (74 loc) · 3.74 KB
/
devbox.json
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
67
68
69
70
71
72
73
74
75
{
"name": "devbox",
"description": "Instant, easy, and predictable development environments",
"packages": {
"go": "latest",
"runx:golangci/golangci-lint": "latest",
"runx:mvdan/gofumpt": "latest",
},
"env": {
"GOENV": "off",
"PATH": "$PATH:$PWD/dist",
},
"shell": {
"init_hook": [
// Remove Go environment variables that might've been inherited from the
// user's environment and could affect the build.
"test -z $FISH_VERSION && \\",
"unset CGO_ENABLED GO111MODULE GOARCH GOFLAGS GOMOD GOOS GOROOT GOTOOLCHAIN GOWORK || \\",
"set --erase CGO_ENABLED GO111MODULE GOARCH GOFLAGS GOMOD GOOS GOROOT GOTOOLCHAIN GOWORK",
],
"scripts": {
// Build devbox for the current platform
"build": "go build -o dist/devbox ./cmd/devbox",
"build-darwin-amd64": "GOOS=darwin GOARCH=amd64 go build -o dist/devbox-darwin-amd64 ./cmd/devbox",
"build-darwin-arm64": "GOOS=darwin GOARCH=arm64 go build -o dist/devbox-darwin-arm64 ./cmd/devbox",
"build-linux-amd64": "GOOS=linux GOARCH=amd64 go build -o dist/devbox-linux-amd64 ./cmd/devbox",
"build-linux-arm64": "GOOS=linux GOARCH=arm64 go build -o dist/devbox-linux-arm64 ./cmd/devbox",
"build-all": [
"devbox run build-darwin-amd64",
"devbox run build-darwin-arm64",
"devbox run build-linux-amd64",
"devbox run build-linux-arm64",
],
// Open VSCode
"code": "code .",
"lint": "golangci-lint run --timeout 5m && scripts/gofumpt.sh",
"fmt": "scripts/gofumpt.sh",
"test": "go test -race -cover ./...",
"test-projects-only": "DEVBOX_RUN_PROJECT_TESTS=1 go test -v -timeout ${DEVBOX_GOLANG_TEST_TIMEOUT:-30m} ./... -run \"TestExamples|TestScriptsWithProjects\"",
"update-examples": "devbox run build && go run testscripts/testrunner/updater/main.go",
// Updates the Flake's vendorHash: First run `go mod vendor` to vendor
// the dependencies, then hash the vendor directory with Nix.
// The hash is saved to the `vendor-hash` file, which is then
// read into the Nix Flake.
"update-hash": [
// realpath to work-around nix hash not liking symlinks
"vendor=$(realpath $(mktemp -d))",
"trap \"rm -rf $vendor\" EXIT",
"go mod vendor -o $vendor",
"nix hash path $vendor >vendor-hash",
],
"tidy": ["go mod tidy", "devbox run update-hash"],
// docker-testscripts runs the testscripts with Docker to exercise
// Linux-specific tests. It invokes the test binary directly, so any extra
// test runner flags must have their "-test." prefix.
//
// For example, to only run Python tests:
//
// devbox run docker-testscripts -test.run ^TestScripts$/python
"docker-testscripts": [
"cd testscripts",
// The Dockerfile looks for a testscripts-$TARGETOS-$TARGETARCH binary
// to run the tests. Pre-compiling a static test binary lets us avoid
// polluting the container with a Go toolchain or shared libraries that
// might interfere with linker tests.
"trap 'rm -f testscripts-linux-amd64 testscripts-linux-arm64' EXIT",
"GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go test -c -o testscripts-linux-amd64",
"GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go test -c -o testscripts-linux-arm64",
"image=$(docker build --quiet --tag devbox-testscripts-ubuntu:noble --platform linux/amd64 .)",
"docker run --rm --mount type=volume,src=devbox-testscripts-amd64,dst=/nix --platform linux/amd64 -e DEVBOX_RUN_FAILING_TESTS -e DEVBOX_RUN_PROJECT_TESTS -e DEVBOX_DEBUG $image \"$@\"",
],
},
},
}