Skip to content

Commit

Permalink
fixup! feat: add enterprise wrapper and image + ci
Browse files Browse the repository at this point in the history
  • Loading branch information
deansheather committed Aug 7, 2023
1 parent e8a6b51 commit ae46d3e
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 180 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/enterprise-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ jobs:
make -j \
enterprise/build/exectrace_"$version"_linux_{amd64,arm64,armv7}.tag.pushed
# Tag as latest and push
for arch in amd64 arm64 armv7; do
versioned_tag=$(cat enterprise/build/exectrace_"$version"_linux_"$arch".tag)
latest_tag=$(./enterprise/scripts/image_tag.sh --arch "$arch" --version latest)
docker tag "$versioned_tag" "$latest_tag"
docker push "$latest_tag"
done
- name: Build and push multi-arch Docker image
if: ${{ !github.event.inputs.snapshot && !github.event.inputs.dry_run }}
run: |
Expand All @@ -76,3 +85,10 @@ jobs:
version=$(./scripts/version.sh)
make -j \
enterprise/build/exectrace_"$version"_linux.tag.pushed
# Tag as latest and push
versioned_tag=$(cat enterprise/build/exectrace_"$version"_linux.tag)
latest_tag=$(./enterprise/scripts/image_tag.sh --version latest)
docker tag "$versioned_tag" "$latest_tag"
docker push "$latest_tag"
36 changes: 28 additions & 8 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# - removed testpackage

linters-settings:
exhaustruct:
include:
# Gradually extend to cover more of the codebase.
- 'httpmw\.\w+'
gocognit:
min-complexity: 46 # Min code complexity (def 30).

Expand Down Expand Up @@ -57,7 +61,6 @@ linters-settings:
# - importShadow
- indexAlloc
- initClause
- ioutilDeprecated
- mapKey
- methodExprCall
# - nestingReduce
Expand All @@ -74,7 +77,7 @@ linters-settings:
- regexpMust
- regexpPattern
# - regexpSimplify
# - ruleguard
- ruleguard
- singleCaseSwitch
- sloppyLen
# - sloppyReassign
Expand Down Expand Up @@ -103,6 +106,10 @@ linters-settings:
# - whyNoLint
# - wrapperFunc
# - yodaStyleExpr
#settings:
# ruleguard:
# failOn: all
# rules: "${configDir}/scripts/rules.go"

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

gocyclo:
min-complexity: 50
# goal: 30
min-complexity: 47

importas:
no-unaliased: true
Expand Down Expand Up @@ -193,16 +201,22 @@ issues:
linters:
# We use assertions rather than explicitly checking errors in tests
- errcheck
- forcetypeassert
- exhaustruct # This is unhelpful in tests.
- path: scripts/*
linters:
- exhaustruct

fix: true
max-issues-per-linter: 0
max-same-issues: 0

run:
concurrency: 4
skip-dirs:
- node_modules
timeout: 5m
skip-files:
- scripts/rules.go
timeout: 10m

# Over time, add more and more linters from
# https://golangci-lint.run/usage/linters/ as the code improves.
Expand All @@ -212,11 +226,11 @@ linters:
- asciicheck
- bidichk
- bodyclose
- deadcode
- dogsled
- errcheck
- errname
- errorlint
- exhaustruct
- exportloopref
- forcetypeassert
- gocritic
Expand Down Expand Up @@ -244,9 +258,15 @@ linters:

- staticcheck
- tenv
# - testpackage
# In Go, it's possible for a package to test it's internal functionality
# without testing any exported functions. This is enabled to promote
# decomposing a package before testing it's internals. A function caller
# should be able to test most of the functionality from exported functions.
#
# There are edge-cases to this rule, but they should be carefully considered
# to avoid structural inconsistency.
#- testpackage
- tparallel
- typecheck
- unconvert
- unused
- varcheck
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ fmt: fmt/go fmt/prettier

.PHONY: fmt/go
fmt/go:
go fmt ./... ./enterprise/...
go fmt ./...
cd enterprise
go fmt ./...

.PHONY: fmt/prettier
fmt/prettier:
Expand All @@ -53,13 +55,16 @@ lint/go: lint/go/linux lint/go/other
.PHONY: lint/go/linux
lint/go/linux:
# Config file: .golangci.yml
golangci-lint run ./... ./enterprise/...
golangci-lint run ./...
cd enterprise
golangci-lint run ./...

.PHONY: lint/go/other
lint/go/other:
# The windows and darwin builds include the same files.
# Config file: .golangci.yml
GOOS=windows golangci-lint run ./... ./enterprise/...
GOOS=windows golangci-lint run ./...
# Enterprise dir does not support Windows or Darwin.

.PHONY: lint/c
lint/c: ci/.clang-image
Expand All @@ -76,13 +81,17 @@ test: test/go
.PHONY: test/go
test/go:
go clean -testcache
gotestsum --debug -- -v -short ./... ./enterprise/...
gotestsum --debug -- -v -short ./...
cd enterprise
gotestsum --debug -- -v -short ./...

# test/go-sudo is equivalent to test/go but runs the test binary using sudo.
# Some tests are skipped if not running as root.
.PHONY: test/go-sudo
test/go-sudo:
go clean -testcache
gotestsum --debug -- -exec sudo -v -short ./... ./enterprise/...
gotestsum --debug -- -exec sudo -v -short ./...
cd enterprise
gotestsum --debug -- -exec sudo -v -short ./...

include Makefile.enterprise
1 change: 1 addition & 0 deletions bpf_eb.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ import (
var NativeEndian = binary.BigEndian

// The compiled BPF program on big endian processors.
//
//go:embed bpf/handler-bpfeb.o
var bpfProgram []byte
1 change: 1 addition & 0 deletions bpf_el.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ import (
var NativeEndian = binary.LittleEndian

// The compiled BPF program on little endian processors.
//
//go:embed bpf/handler-bpfel.o
var bpfProgram []byte
3 changes: 3 additions & 0 deletions cmd/exectrace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ func rootCmd() *cobra.Command {
Short: "exectrace logs all exec calls on the system.",
Run: func(cmd *cobra.Command, args []string) {
if outputFormat != "text" && outputFormat != "json" {
//nolint:revive
log.Fatalf(`output format must be "text" or "json", got %q`, outputFormat)
}

err := run(pidNS, outputFormat)
if err != nil {
//nolint:revive
log.Fatalf("run exectrace: %+v", err)
}
},
Expand Down Expand Up @@ -69,6 +71,7 @@ func run(pidNS uint32, outputFormat string) error {
log.Print("signal received, closing tracer")
err := t.Close()
if err != nil {
//nolint:revive
log.Fatalf("error closing tracer: %+v", err)
}
}()
Expand Down
2 changes: 1 addition & 1 deletion enterprise/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is a multui-arch Dockerfile, so it cannot have ANY "RUN" commands as it's
# This is a multi-arch Dockerfile, so it cannot have ANY "RUN" commands as it's
# cross-compiled. All binaries are cross-compiled using the host's Go toolchain
# and then copied into the build context.
#
Expand Down
166 changes: 0 additions & 166 deletions enterprise/scripts/publish_release.sh

This file was deleted.

0 comments on commit ae46d3e

Please sign in to comment.