Skip to content

Commit ae46d3e

Browse files
committed
fixup! feat: add enterprise wrapper and image + ci
1 parent e8a6b51 commit ae46d3e

File tree

8 files changed

+64
-180
lines changed

8 files changed

+64
-180
lines changed

.github/workflows/enterprise-release.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ jobs:
6868
make -j \
6969
enterprise/build/exectrace_"$version"_linux_{amd64,arm64,armv7}.tag.pushed
7070
71+
# Tag as latest and push
72+
for arch in amd64 arm64 armv7; do
73+
versioned_tag=$(cat enterprise/build/exectrace_"$version"_linux_"$arch".tag)
74+
latest_tag=$(./enterprise/scripts/image_tag.sh --arch "$arch" --version latest)
75+
76+
docker tag "$versioned_tag" "$latest_tag"
77+
docker push "$latest_tag"
78+
done
79+
7180
- name: Build and push multi-arch Docker image
7281
if: ${{ !github.event.inputs.snapshot && !github.event.inputs.dry_run }}
7382
run: |
@@ -76,3 +85,10 @@ jobs:
7685
version=$(./scripts/version.sh)
7786
make -j \
7887
enterprise/build/exectrace_"$version"_linux.tag.pushed
88+
89+
# Tag as latest and push
90+
versioned_tag=$(cat enterprise/build/exectrace_"$version"_linux.tag)
91+
latest_tag=$(./enterprise/scripts/image_tag.sh --version latest)
92+
93+
docker tag "$versioned_tag" "$latest_tag"
94+
docker push "$latest_tag"

.golangci.yaml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
# - removed testpackage
66

77
linters-settings:
8+
exhaustruct:
9+
include:
10+
# Gradually extend to cover more of the codebase.
11+
- 'httpmw\.\w+'
812
gocognit:
913
min-complexity: 46 # Min code complexity (def 30).
1014

@@ -57,7 +61,6 @@ linters-settings:
5761
# - importShadow
5862
- indexAlloc
5963
- initClause
60-
- ioutilDeprecated
6164
- mapKey
6265
- methodExprCall
6366
# - nestingReduce
@@ -74,7 +77,7 @@ linters-settings:
7477
- regexpMust
7578
- regexpPattern
7679
# - regexpSimplify
77-
# - ruleguard
80+
- ruleguard
7881
- singleCaseSwitch
7982
- sloppyLen
8083
# - sloppyReassign
@@ -103,6 +106,10 @@ linters-settings:
103106
# - whyNoLint
104107
# - wrapperFunc
105108
# - yodaStyleExpr
109+
#settings:
110+
# ruleguard:
111+
# failOn: all
112+
# rules: "${configDir}/scripts/rules.go"
106113

107114
staticcheck:
108115
# https://staticcheck.io/docs/options#checks
@@ -115,7 +122,8 @@ linters-settings:
115122
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
116123

117124
gocyclo:
118-
min-complexity: 50
125+
# goal: 30
126+
min-complexity: 47
119127

120128
importas:
121129
no-unaliased: true
@@ -193,16 +201,22 @@ issues:
193201
linters:
194202
# We use assertions rather than explicitly checking errors in tests
195203
- errcheck
204+
- forcetypeassert
205+
- exhaustruct # This is unhelpful in tests.
206+
- path: scripts/*
207+
linters:
208+
- exhaustruct
196209

197210
fix: true
198211
max-issues-per-linter: 0
199212
max-same-issues: 0
200213

201214
run:
202-
concurrency: 4
203215
skip-dirs:
204216
- node_modules
205-
timeout: 5m
217+
skip-files:
218+
- scripts/rules.go
219+
timeout: 10m
206220

207221
# Over time, add more and more linters from
208222
# https://golangci-lint.run/usage/linters/ as the code improves.
@@ -212,11 +226,11 @@ linters:
212226
- asciicheck
213227
- bidichk
214228
- bodyclose
215-
- deadcode
216229
- dogsled
217230
- errcheck
218231
- errname
219232
- errorlint
233+
- exhaustruct
220234
- exportloopref
221235
- forcetypeassert
222236
- gocritic
@@ -244,9 +258,15 @@ linters:
244258

245259
- staticcheck
246260
- tenv
247-
# - testpackage
261+
# In Go, it's possible for a package to test it's internal functionality
262+
# without testing any exported functions. This is enabled to promote
263+
# decomposing a package before testing it's internals. A function caller
264+
# should be able to test most of the functionality from exported functions.
265+
#
266+
# There are edge-cases to this rule, but they should be carefully considered
267+
# to avoid structural inconsistency.
268+
#- testpackage
248269
- tparallel
249270
- typecheck
250271
- unconvert
251272
- unused
252-
- varcheck

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ fmt: fmt/go fmt/prettier
3737

3838
.PHONY: fmt/go
3939
fmt/go:
40-
go fmt ./... ./enterprise/...
40+
go fmt ./...
41+
cd enterprise
42+
go fmt ./...
4143

4244
.PHONY: fmt/prettier
4345
fmt/prettier:
@@ -53,13 +55,16 @@ lint/go: lint/go/linux lint/go/other
5355
.PHONY: lint/go/linux
5456
lint/go/linux:
5557
# Config file: .golangci.yml
56-
golangci-lint run ./... ./enterprise/...
58+
golangci-lint run ./...
59+
cd enterprise
60+
golangci-lint run ./...
5761

5862
.PHONY: lint/go/other
5963
lint/go/other:
6064
# The windows and darwin builds include the same files.
6165
# Config file: .golangci.yml
62-
GOOS=windows golangci-lint run ./... ./enterprise/...
66+
GOOS=windows golangci-lint run ./...
67+
# Enterprise dir does not support Windows or Darwin.
6368

6469
.PHONY: lint/c
6570
lint/c: ci/.clang-image
@@ -76,13 +81,17 @@ test: test/go
7681
.PHONY: test/go
7782
test/go:
7883
go clean -testcache
79-
gotestsum --debug -- -v -short ./... ./enterprise/...
84+
gotestsum --debug -- -v -short ./...
85+
cd enterprise
86+
gotestsum --debug -- -v -short ./...
8087

8188
# test/go-sudo is equivalent to test/go but runs the test binary using sudo.
8289
# Some tests are skipped if not running as root.
8390
.PHONY: test/go-sudo
8491
test/go-sudo:
8592
go clean -testcache
86-
gotestsum --debug -- -exec sudo -v -short ./... ./enterprise/...
93+
gotestsum --debug -- -exec sudo -v -short ./...
94+
cd enterprise
95+
gotestsum --debug -- -exec sudo -v -short ./...
8796

8897
include Makefile.enterprise

bpf_eb.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ import (
1212
var NativeEndian = binary.BigEndian
1313

1414
// The compiled BPF program on big endian processors.
15+
//
1516
//go:embed bpf/handler-bpfeb.o
1617
var bpfProgram []byte

bpf_el.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ import (
1212
var NativeEndian = binary.LittleEndian
1313

1414
// The compiled BPF program on little endian processors.
15+
//
1516
//go:embed bpf/handler-bpfel.o
1617
var bpfProgram []byte

cmd/exectrace/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ func rootCmd() *cobra.Command {
3535
Short: "exectrace logs all exec calls on the system.",
3636
Run: func(cmd *cobra.Command, args []string) {
3737
if outputFormat != "text" && outputFormat != "json" {
38+
//nolint:revive
3839
log.Fatalf(`output format must be "text" or "json", got %q`, outputFormat)
3940
}
4041

4142
err := run(pidNS, outputFormat)
4243
if err != nil {
44+
//nolint:revive
4345
log.Fatalf("run exectrace: %+v", err)
4446
}
4547
},
@@ -69,6 +71,7 @@ func run(pidNS uint32, outputFormat string) error {
6971
log.Print("signal received, closing tracer")
7072
err := t.Close()
7173
if err != nil {
74+
//nolint:revive
7275
log.Fatalf("error closing tracer: %+v", err)
7376
}
7477
}()

enterprise/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This is a multui-arch Dockerfile, so it cannot have ANY "RUN" commands as it's
1+
# This is a multi-arch Dockerfile, so it cannot have ANY "RUN" commands as it's
22
# cross-compiled. All binaries are cross-compiled using the host's Go toolchain
33
# and then copied into the build context.
44
#

enterprise/scripts/publish_release.sh

Lines changed: 0 additions & 166 deletions
This file was deleted.

0 commit comments

Comments
 (0)