Skip to content

Commit a54b479

Browse files
authored
⚒️ Build tooling (#2)
* Build tooling based on goyek * Test targets + GH workflow * Shell starters for goyek * Update deps * Tidy up tasks + tidy deps task * Tidy project deps * Don't force default target of wasm32-wasip2 The tests are failing with wasm32-wasip2 target set globally for cargo. Switching to using it just in the build script. * Proper loading rules for e2e tests * Working ko deploy * Publish works with all artifacts * Match make and goyek tasks * Tidy deps * Update codegen & geps * Automate getting the make targets * Add missing helpers_gen * Add boilerplate script * nitpick fixes of build boot script * Migrate to Golangci-list v2 * Update triggering for GH workflows * Update golangci-lint to Knative version
1 parent bfdff6d commit a54b479

File tree

53 files changed

+1962
-559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1962
-559
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IMAGE_BASENAME=ghcr.io/cardil/knative-serving-wasm

.github/workflows/goyek.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Goyek
2+
3+
on:
4+
push:
5+
branches: [ 'main', 'release-*' ]
6+
7+
pull_request:
8+
branches: [ 'main', 'release-*' ]
9+
10+
jobs:
11+
goyek:
12+
name: build test
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-go@v5
17+
with:
18+
go-version: '^1.23.0'
19+
20+
- uses: actions-rust-lang/setup-rust-toolchain@v1
21+
with:
22+
target: wasm32-wasip2
23+
components: rustfmt
24+
25+
- run: make ARGS=-v build test

.github/workflows/knative-go-build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
name: Build
77

88
on:
9+
push:
10+
branches: [ 'main', 'release-*' ]
11+
912
pull_request:
1013
branches: [ 'main', 'release-*' ]
1114

.github/workflows/knative-style.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
name: Code Style
77

88
on:
9+
push:
10+
branches: [ 'main', 'release-*' ]
11+
912
pull_request:
1013
branches: [ 'main', 'release-*' ]
1114

.github/workflows/knative-verify.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
name: Verify
1919

2020
on:
21+
push:
22+
branches: [ 'main', 'release-*' ]
23+
2124
pull_request:
2225
branches: [ 'main', 'release-*' ]
2326

.golangci.yaml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1+
version: "2"
12
run:
2-
timeout: 5m
3-
43
build-tags:
54
- e2e
6-
7-
skip-dirs:
8-
- pkg/client
9-
105
linters:
11-
enable:
12-
- asciicheck
13-
- errorlint
14-
- gosec
15-
- prealloc
16-
- revive
17-
- stylecheck
18-
- tparallel
19-
- unconvert
20-
- unparam
6+
default: all
217
disable:
228
- errcheck
9+
- wrapcheck
10+
- exhaustruct
11+
- depguard
12+
- ireturn
13+
- wsl
14+
exclusions:
15+
generated: lax
16+
presets:
17+
- comments
18+
- common-false-positives
19+
- legacy
20+
- std-error-handling
21+
22+
formatters:
23+
exclusions:
24+
generated: lax

Makefile

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
.PHONY: clean
2-
clean:
3-
go run github.com/google/ko@latest delete -f config/
1+
# Those are callable targets
2+
TASKS = $(shell go run ./build/ --list)
43

5-
.PHONY: deploy
6-
deploy:
7-
go run github.com/google/ko@latest apply -f config/
4+
.PHONY: all
5+
all: build
86

9-
.PHONY: update-deps
10-
update: update-deps update-codegen
7+
.PHONY: $(TASKS)
8+
$(TASKS):
9+
@go run ./build/ $(ARGS) $@
1110

12-
.PHONY: update-deps
13-
update-deps:
14-
hack/update-deps.sh --upgrade
15-
16-
.PHONY: update-codegen
17-
update-codegen:
18-
hack/update-codegen.sh
11+
.PHONY: help
12+
help:
13+
@go run ./build/ --help

build/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
output

build/boot/main.go

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package boot
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
"time"
7+
8+
"github.com/goyek/goyek/v2"
9+
"github.com/goyek/goyek/v2/middleware"
10+
"github.com/goyek/x/color"
11+
flag "github.com/spf13/pflag"
12+
)
13+
14+
// Params are reusable flags used by the build pipeline.
15+
type Params struct {
16+
V bool
17+
DryRun bool
18+
LongRun time.Duration
19+
NoDeps bool
20+
Skip string
21+
NoColor bool
22+
Options []goyek.Option
23+
}
24+
25+
type Option func(*Params)
26+
27+
// Main is an extension of goyek.Main which additionally
28+
// defines flags and uses the most useful middlewares.
29+
func Main(opts ...Option) {
30+
p := Params{
31+
LongRun: time.Minute,
32+
}
33+
for _, opt := range opts {
34+
opt(&p)
35+
}
36+
flag.BoolVarP(&p.V, "verbose", "v", p.V, "print all tasks as they are run")
37+
flag.BoolVar(&p.DryRun, "dry-run", p.DryRun, "print all tasks without executing actions")
38+
flag.DurationVar(&p.LongRun, "long-run", p.LongRun, "print when a task takes longer")
39+
flag.BoolVar(&p.NoDeps, "no-deps", p.NoDeps, "do not process dependencies")
40+
flag.StringVarP(&p.Skip, "skip", "s", p.Skip, "skip processing the `comma-separated tasks`")
41+
flag.BoolVar(&p.NoColor, "no-color", p.NoColor, "disable colorizing output")
42+
list := flag.Bool("list", false, "list all targets")
43+
flag.CommandLine.SetOutput(goyek.Output())
44+
flag.Usage = usage
45+
flag.Parse()
46+
47+
if *list {
48+
for _, task := range goyek.Tasks() {
49+
fmt.Println(task.Name())
50+
}
51+
return
52+
}
53+
54+
if p.DryRun {
55+
p.V = true // needed to report the task status
56+
}
57+
58+
goyek.UseExecutor(color.ReportFlow)
59+
60+
if p.DryRun {
61+
goyek.Use(middleware.DryRun)
62+
}
63+
goyek.Use(color.ReportStatus)
64+
if p.V {
65+
goyek.Use(middleware.BufferParallel)
66+
} else {
67+
goyek.Use(middleware.SilentNonFailed)
68+
}
69+
if p.LongRun > 0 {
70+
goyek.Use(middleware.ReportLongRun(p.LongRun))
71+
}
72+
if p.NoColor {
73+
color.NoColor()
74+
}
75+
76+
gopts := make([]goyek.Option, 0, 2+len(p.Options))
77+
if p.NoDeps {
78+
gopts = append(gopts, goyek.NoDeps())
79+
}
80+
if p.Skip != "" {
81+
skippedTasks := strings.Split(p.Skip, ",")
82+
gopts = append(gopts, goyek.Skip(skippedTasks...))
83+
}
84+
gopts = append(gopts, p.Options...)
85+
86+
goyek.SetUsage(usage)
87+
goyek.SetLogger(&color.CodeLineLogger{})
88+
goyek.Main(flag.Args(), gopts...)
89+
}
90+
91+
func usage() {
92+
_, _ = fmt.Fprintln(goyek.Output(), "Usage: ./goyek [flags] [--] [tasks]")
93+
_, _ = fmt.Fprintln(goyek.Output())
94+
goyek.Print()
95+
_, _ = fmt.Fprintln(goyek.Output())
96+
_, _ = fmt.Fprintln(goyek.Output(), "Flags:")
97+
flag.PrintDefaults()
98+
}

build/go.mod

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
module github.com/cardil/knative-serving-wasm/build
2+
3+
go 1.24.0
4+
5+
require (
6+
github.com/cardil/ghet v0.1.1
7+
github.com/cardil/knative-serving-wasm v0.0.0
8+
github.com/goyek/goyek/v2 v2.3.0
9+
github.com/goyek/x v0.3.0
10+
github.com/joho/godotenv v1.5.1
11+
github.com/spf13/pflag v1.0.6
12+
)
13+
14+
replace github.com/cardil/knative-serving-wasm => ..
15+
16+
require (
17+
dario.cat/mergo v1.0.0 // indirect
18+
emperror.dev/errors v0.8.1 // indirect
19+
github.com/1set/gut v0.0.0-20201117175203-a82363231997 // indirect
20+
github.com/andybalholm/brotli v1.1.0 // indirect
21+
github.com/atotto/clipboard v0.1.4 // indirect
22+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
23+
github.com/blendle/zapdriver v1.3.1 // indirect
24+
github.com/bodgit/plumbing v1.3.0 // indirect
25+
github.com/bodgit/sevenzip v1.5.0 // indirect
26+
github.com/bodgit/windows v1.0.1 // indirect
27+
github.com/charmbracelet/bubbles v0.18.0 // indirect
28+
github.com/charmbracelet/bubbletea v0.25.0 // indirect
29+
github.com/charmbracelet/harmonica v0.2.0 // indirect
30+
github.com/charmbracelet/lipgloss v0.10.0 // indirect
31+
github.com/containerd/console v1.0.4 // indirect
32+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
33+
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
34+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
35+
github.com/erikgeiser/promptkit v0.9.0 // indirect
36+
github.com/fatih/color v1.18.0 // indirect
37+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
38+
github.com/go-logr/logr v1.4.3 // indirect
39+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
40+
github.com/go-openapi/jsonreference v0.21.0 // indirect
41+
github.com/go-openapi/swag v0.23.0 // indirect
42+
github.com/gogo/protobuf v1.3.2 // indirect
43+
github.com/golang/snappy v0.0.4 // indirect
44+
github.com/google/gnostic-models v0.6.9 // indirect
45+
github.com/google/go-cmp v0.7.0 // indirect
46+
github.com/google/go-github/v48 v48.2.0 // indirect
47+
github.com/google/go-querystring v1.1.0 // indirect
48+
github.com/google/uuid v1.6.0 // indirect
49+
github.com/gookit/color v1.5.4 // indirect
50+
github.com/hashicorp/errwrap v1.1.0 // indirect
51+
github.com/hashicorp/go-multierror v1.1.1 // indirect
52+
github.com/josharian/intern v1.0.0 // indirect
53+
github.com/json-iterator/go v1.1.12 // indirect
54+
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f // indirect
55+
github.com/klauspost/compress v1.18.0 // indirect
56+
github.com/klauspost/pgzip v1.2.6 // indirect
57+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
58+
github.com/mailru/easyjson v0.9.0 // indirect
59+
github.com/mattn/go-colorable v0.1.13 // indirect
60+
github.com/mattn/go-isatty v0.0.20 // indirect
61+
github.com/mattn/go-localereader v0.0.2-0.20220822084749-2491eb6c1c75 // indirect
62+
github.com/mattn/go-runewidth v0.0.15 // indirect
63+
github.com/mattn/go-shellwords v1.0.12 // indirect
64+
github.com/mholt/archiver/v4 v4.0.0-alpha.8 // indirect
65+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
66+
github.com/modern-go/reflect2 v1.0.2 // indirect
67+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
68+
github.com/muesli/cancelreader v0.2.2 // indirect
69+
github.com/muesli/reflow v0.3.0 // indirect
70+
github.com/muesli/termenv v0.15.2 // indirect
71+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
72+
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 // indirect
73+
github.com/pierrec/lz4/v4 v4.1.21 // indirect
74+
github.com/pkg/errors v0.9.1 // indirect
75+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
76+
github.com/rivo/uniseg v0.4.7 // indirect
77+
github.com/stretchr/testify v1.10.0 // indirect
78+
github.com/therootcompany/xz v1.0.1 // indirect
79+
github.com/u-root/u-root v0.14.0 // indirect
80+
github.com/ulikunitz/xz v0.5.11 // indirect
81+
github.com/x448/float16 v0.8.4 // indirect
82+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
83+
go.uber.org/multierr v1.11.0 // indirect
84+
go.uber.org/zap v1.27.0 // indirect
85+
go.yaml.in/yaml/v2 v2.4.2 // indirect
86+
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
87+
golang.org/x/crypto v0.39.0 // indirect
88+
golang.org/x/net v0.41.0 // indirect
89+
golang.org/x/oauth2 v0.30.0 // indirect
90+
golang.org/x/sync v0.15.0 // indirect
91+
golang.org/x/sys v0.33.0 // indirect
92+
golang.org/x/term v0.32.0 // indirect
93+
golang.org/x/text v0.26.0 // indirect
94+
golang.org/x/time v0.10.0 // indirect
95+
google.golang.org/protobuf v1.36.6 // indirect
96+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
97+
gopkg.in/inf.v0 v0.9.1 // indirect
98+
gopkg.in/yaml.v3 v3.0.1 // indirect
99+
k8s.io/api v0.33.1 // indirect
100+
k8s.io/apimachinery v0.33.1 // indirect
101+
k8s.io/client-go v0.33.1 // indirect
102+
k8s.io/klog/v2 v2.130.1 // indirect
103+
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
104+
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect
105+
knative.dev/client/pkg v0.0.0-20241128155143-441372aea16b // indirect
106+
knative.dev/pkg v0.0.0-20250627014006-8481e7eef7f6 // indirect
107+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
108+
sigs.k8s.io/randfill v1.0.0 // indirect
109+
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
110+
sigs.k8s.io/yaml v1.5.0 // indirect
111+
)

0 commit comments

Comments
 (0)