From 0810022b6eff6121f08c15825509b73c7398119a Mon Sep 17 00:00:00 2001 From: Matt Leader Date: Tue, 30 Jan 2024 16:25:40 -0500 Subject: [PATCH] Upgrade (#12) * upgrade module * fix golangci config * fix linting * gofmt helper test * add workflow * remove generator --- .github/workflows/build.yaml | 60 ++++++++++++++++++++++++++++++++++++ .golangci.yml | 26 ++++++++-------- go.mod | 10 +++--- go.sum | 19 ++++++------ interface.go | 2 ++ registry/helper_test.go | 6 ---- registry/new.go | 2 ++ registry/registry.go | 2 ++ 8 files changed, 94 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..aa52128 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,60 @@ +name: Build +on: + push: + branches: + - main + pull_request: +jobs: + golangci-lint: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.55.2 + test: + name: go test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.21.6 + - name: Set up gotestfmt + uses: GoTestTools/gotestfmt-action@v2 + - uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: go-test-${{ hashFiles('**/go.sum') }} + restore-keys: go-test- + - name: Run go test + run: | + set -euo pipefail + go generate + go test -coverprofile /tmp/coverage.out -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt + echo "# Code coverage summary" > /tmp/coverage.md + echo "|File|Type|Coverage|" >> /tmp/coverage.md + echo "|----|----|--------|" >> /tmp/coverage.md + go tool cover -func /tmp/coverage.out | sed -e 's/\s\s*/|/g' -e 's/^/|/g' -e 's/$/|/g' >> /tmp/coverage.md + + cat /tmp/coverage.md >> $GITHUB_STEP_SUMMARY + echo "::group::Code coverage summary" + go tool cover -func /tmp/coverage.out + echo "::endgroup::" + - name: Upload test log + uses: actions/upload-artifact@v3 + if: always() + with: + name: test-results + path: | + /tmp/gotest.log + /tmp/coverage.out + /tmp/coverage.md + if-no-files-found: error diff --git a/.golangci.yml b/.golangci.yml index ff3c5f5..1570663 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -75,18 +75,20 @@ linters: # endregion linters-settings: depguard: - list-type: whitelist - include-go-root: false - packages: - - go.flow.arcalot.io/ - - go.arcalot.io/ - - github.com/docker/ - - github.com/opencontainers/ - - gopkg.in/yaml.v3 - - github.com/fxamacker/cbor - - k8s.io/ - - sigs.k8s.io/ - - golang.org/ + rules: + main: + list-mode: strict + allow: + - $gostd + - go.flow.arcalot.io/ + - go.arcalot.io/ + - github.com/docker/ + - github.com/opencontainers/ + - gopkg.in/yaml.v3 + - github.com/fxamacker/cbor + - k8s.io/ + - sigs.k8s.io/ + - golang.org/ govet: enable-all: true check-shadowing: false diff --git a/go.mod b/go.mod index a034f3d..11ea1b9 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module go.flow.arcalot.io/deployer -go 1.18 +go 1.21 require ( - go.arcalot.io/assert v1.6.0 - go.arcalot.io/lang v1.0.0 - go.arcalot.io/log/v2 v2.0.0 - go.flow.arcalot.io/pluginsdk v0.5.1 + go.arcalot.io/assert v1.7.0 + go.arcalot.io/lang v1.1.0 + go.arcalot.io/log/v2 v2.1.0 + go.flow.arcalot.io/pluginsdk v0.8.0 ) diff --git a/go.sum b/go.sum index 66d9810..62d1016 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,10 @@ -go.arcalot.io/assert v1.6.0 h1:iKA8SZZ1MRblMX5QAwwY5RbpR+VNyp//4IU7vo08Xu0= -go.arcalot.io/assert v1.6.0/go.mod h1:Xy3ScX0p9IMY89gdsgexOKxnmDr0nGHG9dV7p8Uxg7w= -go.arcalot.io/lang v1.0.0 h1:mgDaieT4wWdZTnR4V7+/pgYRmzfU7VZZgIzHccuxAbY= -go.arcalot.io/lang v1.0.0/go.mod h1:ALqfYEhAzC2WoGLaycmJoNJd5NmkR7V1PSKp/c5D278= -go.arcalot.io/log/v2 v2.0.0 h1:mbmsWDVBXZNWrDzUh5JLzeGCQ59kTuMFs+pyfJGc1hk= -go.arcalot.io/log/v2 v2.0.0/go.mod h1:1V8jnFIIGwh2CtcGkHNOmy1nCo7LbazQNkUcnKYNMn4= -go.flow.arcalot.io/pluginsdk v0.5.0 h1:TRS/waCTcdoMZ9neDAcfy3zpzyDnPHRbhV+Y1kpcw3Y= -go.flow.arcalot.io/pluginsdk v0.5.0/go.mod h1:2s2f//7uOkBjr1QaiWJD/bqDIeLlINJtD1BhiY4aGPM= -go.flow.arcalot.io/pluginsdk v0.5.1 h1:ebb2ThAqmjmwGpDyKpd1wEDUisPqPabgARjFohy47Io= -go.flow.arcalot.io/pluginsdk v0.5.1/go.mod h1:2s2f//7uOkBjr1QaiWJD/bqDIeLlINJtD1BhiY4aGPM= +go.arcalot.io/assert v1.7.0 h1:PTLyeisNMUKpM9wXRDxResanBhuGOYO1xFK3v5b3FSw= +go.arcalot.io/assert v1.7.0/go.mod h1:nNmWPoNUHFyrPkNrD2aASm5yPuAfiWdB/4X7Lw3ykHk= +go.arcalot.io/lang v1.1.0 h1:ugglRKpd3qIMkdghAjKJxsziIgHm8QpxrzZPSXoa08I= +go.arcalot.io/lang v1.1.0/go.mod h1:2BZJO4csY7NnN/Nf1+eTdIQH4A2vxtOMneaO+PJl+Co= +go.arcalot.io/log/v2 v2.1.0 h1:lNO931hJ82LgS6WcCFCxpLWXQXPFhOkz6PyAJ/augq4= +go.arcalot.io/log/v2 v2.1.0/go.mod h1:PNWOSkkPmgS2OMlWTIlB/WqOw0yaBvDYd8ENAP80H4k= +go.flow.arcalot.io/pluginsdk v0.8.0 h1:cShsshrR17ZFLcbgi3aZvqexLttcp3JISFNqPUPuDvA= +go.flow.arcalot.io/pluginsdk v0.8.0/go.mod h1:sk7ssInR/T+Gy+RSRr+QhKqZcECFFxMyn1hPQCTZSyU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/interface.go b/interface.go index 2e68607..21e5694 100644 --- a/interface.go +++ b/interface.go @@ -9,6 +9,8 @@ import ( "go.flow.arcalot.io/pluginsdk/schema" ) +// DeploymentType is the mechanism of deployment, such as +// image or python. type DeploymentType string // ConnectorFactory is an abstraction that hides away the complexity of instantiating a Connector. Its main purpose is diff --git a/registry/helper_test.go b/registry/helper_test.go index ed19d63..afb73c3 100644 --- a/registry/helper_test.go +++ b/registry/helper_test.go @@ -12,12 +12,6 @@ import ( type testConfig struct { } -var testConfigInput = map[string]any{ - "test-type": map[string]any{ - "deployer_name": "test", - }, -} - type testNewFactory struct { } diff --git a/registry/new.go b/registry/new.go index 5043507..be9d6ad 100644 --- a/registry/new.go +++ b/registry/new.go @@ -1,3 +1,5 @@ +// Package registry provides an interface to an aggregate of deployers, +// and a factory for that aggregate. package registry import ( diff --git a/registry/registry.go b/registry/registry.go index ccfe0b8..a96ec61 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -1,3 +1,5 @@ +// Package registry provides an interface to an aggregate of deployers, +// and a factory for that aggregate. package registry import (