Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ go.work.sum
.env

# Editor/IDE
# .idea/
.idea/
# .vscode/
155 changes: 155 additions & 0 deletions .golangci.yml
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$
4 changes: 4 additions & 0 deletions .tool-versions
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
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@

This repository contains reusable common CLD Changesets such as MCMS, Datastore, JD and more which are used in CLD to perform deployments.

### `cre`

Directory [`cre`](./cre) holds CRE-related changesets and operations.

**`cre_workflow_deploy`:** resolves pre-built workflow WASM, workflow config, and **`project.yaml`** (GitHub release, URL, or local), writes **`workflow.yaml`** and **`context.yaml`**, and runs `cre workflow deploy` via the framework [`operations`](https://pkg.go.dev/github.com/smartcontractkit/chainlink-deployments-framework/operations) API.

- **Changeset:** `cre/changesets.CREWorkflowDeployChangeset`
- **Input:** `cre/operations.CREWorkflowDeployInput` — pipeline YAML supplies `project` ([`cre/artifacts.ConfigSource`](https://pkg.go.dev/github.com/smartcontractkit/chainlink-deployments-framework/cre/artifacts#ConfigSource)), `deploymentRegistry`, and the workflow bundle (binary, config, name). RPCs and `cre-cli` settings live in the user-provided `project.yaml`.
- **Operation:** `cre/operations.CREWorkflowDeployOp`

Domain resolvers can be pass-through; pipeline YAML must include `donFamily`, `project`, and the workflow bundle fields.

#### Package layout

| Package | Purpose |
|---------|---------|
| `cre/changesets` | CLD changesets (e.g. `CREWorkflowDeployChangeset`) |
| `cre/operations` | Idempotent CLD operations invoked by changesets; also defines shared CRE deploy types (`CREWorkflowDeployInput`, `CREDeployDeps`) |

## Usage

```bash
$ go get github.com/smartcontractkit/cld-changesets
go get github.com/smartcontractkit/cld-changesets
```

## Contributing
Expand Down
24 changes: 24 additions & 0 deletions Taskfile.yml
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}}
65 changes: 65 additions & 0 deletions cre/changesets/workflow_deploy.go
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
}
Comment thread
ecPablo marked this conversation as resolved.
Loading
Loading