-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add CRE workflow deploy changeset and operation #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5451cbd
feat: add CRE workflow deploy changeset and operation
ecPablo 3f03b92
fix: bump go mod and add logs for resolved files for debugging
ecPablo 6c50bc1
chore: bump cldf
ecPablo f735b39
chore: bump grpc vulnerable pkg
ecPablo d58d77d
Update cre/operations/workflow_deploy_test.go
ecPablo 2c5ec40
Update cre/changesets/workflow_deploy_test.go
ecPablo 02cd2c9
chore: bump json parser vulnerable pkg
ecPablo 98c586f
fix: address copilot comments
ecPablo 9119d35
fix: docker vulnerability
ecPablo c40fb35
fix: use variadic args
ecPablo a6fb937
fix: address review comments:
ecPablo 0797b7a
fix: remove redundant arg in test params so we default to good and on…
ecPablo 265ac18
fix: remove omitempty
ecPablo 1ac6552
Update cre/operations/workflow_deploy.go
ecPablo 2139e6a
Update cre/changesets/workflow_deploy.go
ecPablo c2e74da
Update .golangci.yml
ecPablo 4691676
Update go.mod
ecPablo 25b7a3f
fix: remove direct usage of stdout and use infof to print a direct st…
ecPablo cf8fb13
chore: go mod fixes
ecPablo f1df95f
Update cre/changesets/workflow_deploy_test.go
ecPablo 2e6c7e8
Update go.mod
ecPablo 94debeb
fix: linting errors
ecPablo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,5 +28,5 @@ go.work.sum | |
| .env | ||
|
|
||
| # Editor/IDE | ||
| # .idea/ | ||
| .idea/ | ||
| # .vscode/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| version: "2" | ||
| run: | ||
| timeout: 10m | ||
| linters: | ||
| enable: | ||
| - asciicheck | ||
| - bidichk | ||
| - bodyclose | ||
| - containedctx | ||
| - copyloopvar | ||
| - decorder | ||
| - depguard | ||
| - dogsled | ||
| - dupword | ||
| - durationcheck | ||
| - errchkjson | ||
| - errname | ||
| - errorlint | ||
| - exhaustive | ||
| - fatcontext | ||
| - goconst | ||
| - gosec | ||
| - intrange | ||
| - loggercheck | ||
| - makezero | ||
| - mirror | ||
| - misspell | ||
| - nilerr | ||
| - nilnil | ||
| - nlreturn | ||
| - noctx | ||
| - paralleltest | ||
| - perfsprint | ||
| - prealloc | ||
| - reassign | ||
| - revive | ||
| - spancheck | ||
| - staticcheck | ||
| - testifylint | ||
| - thelper | ||
| - unconvert | ||
| - unparam | ||
| - usestdlibvars | ||
| - wastedassign | ||
| - whitespace | ||
| settings: | ||
| depguard: | ||
| rules: | ||
| main: | ||
| list-mode: lax | ||
| deny: | ||
| - pkg: github.com/gofrs/uuid | ||
| desc: Use github.com/google/uuid instead | ||
| - pkg: github.com/satori/go.uuid | ||
| desc: Use github.com/google/uuid instead | ||
| - pkg: github.com/test-go/testify/assert | ||
| desc: Use github.com/stretchr/testify/assert instead | ||
| - pkg: github.com/test-go/testify/mock | ||
| desc: Use github.com/stretchr/testify/mock instead | ||
| - pkg: github.com/test-go/testify/require | ||
| desc: Use github.com/stretchr/testify/require instead | ||
| - pkg: go.uber.org/multierr | ||
| desc: Use the standard library instead, for example https://pkg.go.dev/errors#Join | ||
| - pkg: gopkg.in/guregu/null.v1 | ||
| desc: Use gopkg.in/guregu/null.v4 instead | ||
| - pkg: gopkg.in/guregu/null.v2 | ||
| desc: Use gopkg.in/guregu/null.v4 instead | ||
| - pkg: gopkg.in/guregu/null.v3 | ||
| desc: Use gopkg.in/guregu/null.v4 instead | ||
| - pkg: github.com/pelletier/go-toml$ | ||
| desc: Use github.com/pelletier/go-toml/v2 instead | ||
| - pkg: github.com/smartcontractkit/chainlink/v2/core/logger | ||
| desc: Use github.com/smartcontractkit/chainlink-deployments-framework/pkg/logger instead | ||
| - pkg: github.com/pkg/errors | ||
| desc: Use the standard library instead, for example https://pkg.go.dev/fmt#Errorf | ||
| - pkg: github.com/smartcontractkit/chainlink/v2 | ||
| desc: You must not import this package. There is no alternative. | ||
| - pkg: github.com/smartcontractkit/chainlink/deployment | ||
| desc: You must not import this package. There is no alternative. | ||
| - pkg: github.com/smartcontractkit/chainlink-common/pkg/logger | ||
| desc: Use github.com/smartcontractkit/chainlink-deployments-framework/pkg/logger instead | ||
| - pkg: github.com/smartcontractkit/chainlink-common | ||
| desc: We want to avoid importing this package as it has regular breaking changes. | ||
| goconst: | ||
| min-len: 5 | ||
| govet: | ||
| enable: | ||
| - shadow | ||
| nlreturn: | ||
| block-size: 2 | ||
| revive: | ||
| confidence: 1 | ||
| rules: | ||
| - name: atomic | ||
| - name: constant-logical-expr | ||
| - name: context-as-argument | ||
| - name: context-keys-type | ||
| - name: defer | ||
| - name: dot-imports | ||
| - name: empty-block | ||
| - name: error-return | ||
| - name: error-strings | ||
| - name: error-naming | ||
| - name: errorf | ||
| - name: get-return | ||
| - name: identical-branches | ||
| - name: if-return | ||
| - name: increment-decrement | ||
| - name: indent-error-flow | ||
| - name: var-naming | ||
| - name: var-declaration | ||
| - name: package-comments | ||
| - name: range | ||
| - name: receiver-naming | ||
| - name: time-naming | ||
| - name: unexported-return | ||
| - name: string-of-int | ||
| - name: struct-tag | ||
| - name: superfluous-else | ||
| - name: unconditional-recursion | ||
| - name: unreachable-code | ||
| - name: redefines-builtin-id | ||
| - name: waitgroup-by-value | ||
| exclusions: | ||
| generated: lax | ||
| presets: | ||
| - comments | ||
| - common-false-positives | ||
| - legacy | ||
| - std-error-handling | ||
| rules: | ||
| - linters: | ||
| - goconst | ||
| path: (.+)_test\.go | ||
| - linters: | ||
| - staticcheck | ||
| text: "SA1019:.*aws-sdk-go.*is deprecated" | ||
| path: (.+)\.go | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ | ||
| formatters: | ||
| enable: | ||
| - goimports | ||
| settings: | ||
| goimports: | ||
| local-prefixes: | ||
| - github.com/smartcontractkit/cld-changesets | ||
| exclusions: | ||
| generated: lax | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| golang 1.26.1 | ||
| golangci-lint 2.11.4 | ||
| mockery 3.6.3 | ||
| task 3.48.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # https://taskfile.dev | ||
|
|
||
| version: "3" | ||
|
|
||
| tasks: | ||
| lint: | ||
| desc: Runs the linter | ||
| cmds: | ||
| - golangci-lint run {{.CLI_ARGS}} | ||
|
|
||
| lint:verbose: | ||
| desc: Runs the linter in verbose mode | ||
| cmds: | ||
| - golangci-lint run --verbose | ||
|
|
||
| lint:fix: | ||
| desc: Runs the linter in fix mode | ||
| cmds: | ||
| - golangci-lint run --fix | ||
|
|
||
| test: | ||
| desc: Run tests | ||
| cmds: | ||
| - go test ./... {{.CLI_ARGS}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Package changesets provides CRE workflow changesets that can be applied to deployment environments. | ||
| package changesets | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| creops "github.com/smartcontractkit/cld-changesets/cre/operations" | ||
|
|
||
| cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" | ||
| cfgenv "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/config/env" | ||
| fwops "github.com/smartcontractkit/chainlink-deployments-framework/operations" | ||
| ) | ||
|
|
||
| // CREWorkflowDeployChangeset resolves workflow artifacts and runs the CRE CLI workflow deploy command. | ||
| type CREWorkflowDeployChangeset struct{} | ||
|
|
||
| // VerifyPreconditions ensures the environment can run CRE and input is valid. | ||
| func (CREWorkflowDeployChangeset) VerifyPreconditions(e cldf.Environment, input creops.CREWorkflowDeployInput) error { | ||
| if e.CRERunner == nil { | ||
| return errors.New("cre runner is not available in this environment") | ||
| } | ||
| if e.CRERunner.CLI() == nil { | ||
| return errors.New("cre CLI runner is not configured") | ||
| } | ||
| if err := input.Validate(); err != nil { | ||
| return err | ||
| } | ||
| if err := input.Project.Validate(); err != nil { | ||
| return fmt.Errorf("project: %w", err) | ||
| } | ||
| if strings.TrimSpace(input.DeploymentRegistry) == "" { | ||
| return errors.New("deploymentRegistry is required") | ||
| } | ||
| if strings.TrimSpace(input.DonFamily) == "" { | ||
| return errors.New("donFamily is required") | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // Apply loads CRE config and runs the CRE workflow deploy operation. | ||
| func (CREWorkflowDeployChangeset) Apply(e cldf.Environment, input creops.CREWorkflowDeployInput) (cldf.ChangesetOutput, error) { | ||
| envCfg, err := cfgenv.LoadEnv() | ||
| if err != nil { | ||
| return cldf.ChangesetOutput{}, fmt.Errorf("load CRE env config: %w", err) | ||
| } | ||
|
|
||
| deps := creops.CREDeployDeps{ | ||
| CLI: e.CRERunner.CLI(), | ||
| CRECfg: envCfg.CRE, | ||
| EVMDeployerKey: envCfg.Onchain.EVM.DeployerKey, | ||
| } | ||
|
|
||
| report, err := fwops.ExecuteOperation(e.OperationsBundle, creops.CREWorkflowDeployOp, deps, input) | ||
| out := cldf.ChangesetOutput{ | ||
| Reports: []fwops.Report[any, any]{report.ToGenericReport()}, | ||
| } | ||
| if err != nil { | ||
| return out, err | ||
| } | ||
|
|
||
| return out, nil | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.