Change to brewkit

This commit is contained in:
2025-10-23 12:32:21 +03:00
parent a74a4d46ee
commit 85a8ccb57d
4 changed files with 5 additions and 8 deletions
+4
View File
@@ -0,0 +1,4 @@
{
gobuilder: "golang:1.24-alpine",
golangcilint: "golangci/golangci-lint:v2.1-alpine",
}
+107
View File
@@ -0,0 +1,107 @@
local images = import 'images.libsonnet';
local cache = std.native('cache');
local copy = std.native('copy');
local copyFrom = std.native('copyFrom');
local gosources = [
"go.mod",
"go.sum",
"cmd",
"pkg",
];
local gocache = [
cache("go-build", "/app/cache"),
cache("go-mod", "/go/pkg/mod"),
];
{
project(appIDs):: {
apiVersion: "brewkit/v1",
targets: {
all: ["modules", "build", "check"],
} + {
modules: ["gotidy", "modulesvendor"],
gotidy: {
from: "gobase",
workdir: "/app",
cache: gocache,
ssh: {},
command: "go mod tidy",
output: {
artifact: "/app/go.*",
"local": ".",
},
},
modulesvendor: {
from: "gotidy",
workdir: "/app",
cache: gocache,
command: "go mod vendor",
output: {
artifact: "/app/vendor",
"local": "vendor",
},
},
build: [appID for appID in appIDs],
} + {
[appID]: {
from: "gobase",
workdir: "/app",
cache: gocache,
dependsOn: ["modules"],
command: "go build -trimpath -v -o ./bin/" + appID + " ./cmd/" + appID,
output: {
artifact: "/app/bin/" + appID,
"local": "./bin"
}
}
for appID in appIDs
} + {
check: ["test", "lint"],
test: {
from: "gobase",
workdir: "/app",
cache: gocache,
command: "go test ./..."
},
lint: {
from: images.golangcilint,
workdir: "/app",
cache: gocache,
copy: [
copyFrom("gosources", "/app", "/app"),
copy(".golangci.yml", ".golangci.yml"),
],
env: {
GOCACHE: "/app/cache/go-build",
GOLANGCI_LINT_CACHE: "/app/cache/go-build",
},
command: "golangci-lint run"
},
} + {
gobase: {
from: images.gobuilder,
workdir: "/app",
env: {
GOCACHE: "/app/cache/go-build",
CGO_ENABLED: "0"
},
copy: copyFrom('gosources', '/app', '/app')
},
gosources: {
from: "scratch",
workdir: "/app",
copy: [copy(source, source) for source in gosources]
},
}
}
}