Skip to content

Commit efc28bb

Browse files
committed
Move values, sdk, and metadata to chainlink-protos
1 parent 3351427 commit efc28bb

48 files changed

Lines changed: 7886 additions & 32 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: 'Setup CRE Environment'
2+
description: 'Sets up tools and dependencies for CRE validation and fixing'
3+
inputs:
4+
install-buf:
5+
description: 'Whether to install buf CLI'
6+
required: false
7+
default: 'true'
8+
install-go-tools:
9+
description: 'Whether to install Go tools (asdf, task, protoc)'
10+
required: false
11+
default: 'true'
12+
13+
outputs:
14+
cre_changed:
15+
description: 'Whether CRE files were modified'
16+
value: ${{ steps.changes.outputs.cre_changed }}
17+
18+
runs:
19+
using: 'composite'
20+
steps:
21+
- name: Fetch origin/main for comparison
22+
shell: bash
23+
run: |
24+
git fetch origin main:main --depth=1
25+
26+
- name: Check if cre/ files were modified
27+
id: changes
28+
shell: bash
29+
run: |
30+
# Get the list of changed files
31+
CHANGED_FILES=$(git diff --name-only origin/main)
32+
33+
if [ $? -ne 0 ]; then
34+
echo "::error::Failed to get diff against origin/main"
35+
exit 1
36+
fi
37+
38+
echo "Changed files:"
39+
echo "$CHANGED_FILES"
40+
41+
# Check if any files are in the cre/ directory
42+
if echo "$CHANGED_FILES" | grep -q '^cre/'; then
43+
echo "cre_changed=true" >> $GITHUB_OUTPUT
44+
echo "CRE files were modified"
45+
else
46+
echo "cre_changed=false" >> $GITHUB_OUTPUT
47+
echo "No CRE files were modified"
48+
fi
49+
50+
- name: Set tool versions for CRE
51+
if: steps.changes.outputs.cre_changed == 'true'
52+
id: tool-versions
53+
uses: smartcontractkit/tool-versions-to-env-action@aabd5efbaf28005284e846c5cf3a02f2cba2f4c2 # v1.0.8
54+
55+
- name: Cache Dependencies for CRE
56+
if: steps.changes.outputs.cre_changed == 'true'
57+
id: cache-deps
58+
uses: actions/cache@v4
59+
with:
60+
path: |
61+
/usr/local/bin/buf
62+
/usr/local/bin/task
63+
~/go/bin
64+
~/.asdf
65+
key: ${{ runner.os }}-cre-deps-${{ steps.tool-versions.outputs.golang_version }}-${{ hashFiles('cre/**/go.mod', 'cre/**/go.sum') }}
66+
67+
- name: Install buf CLI (v1.45.0) for CRE
68+
if: steps.changes.outputs.cre_changed == 'true' && inputs.install-buf == 'true'
69+
shell: bash
70+
run: |
71+
echo "Installing buf CLI v1.45.0..."
72+
curl -sSL https://github.com/bufbuild/buf/releases/download/v1.45.0/buf-$(uname -s)-$(uname -m) -o /usr/local/bin/buf
73+
chmod +x /usr/local/bin/buf
74+
75+
- name: Set up Go for CRE
76+
if: steps.changes.outputs.cre_changed == 'true' && inputs.install-go-tools == 'true'
77+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.0.0
78+
with:
79+
go-version: ${{ steps.tool-versions.outputs.golang_version }}
80+
81+
- name: Install asdf and Plugins for CRE
82+
if: steps.changes.outputs.cre_changed == 'true' && inputs.install-go-tools == 'true'
83+
uses: asdf-vm/actions/plugins-add@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 #v3.0.2
84+
with:
85+
asdf_branch: v0.16.7
86+
87+
- name: Setup asdf environment
88+
if: steps.changes.outputs.cre_changed == 'true' && inputs.install-go-tools == 'true'
89+
shell: bash
90+
run: |
91+
# Add asdf to PATH for this and subsequent steps
92+
echo "$HOME/.asdf/bin" >> $GITHUB_PATH
93+
echo "$HOME/.asdf/shims" >> $GITHUB_PATH
94+
95+
# Debug: Check if asdf exists after cache/install
96+
echo "Checking asdf installation..."
97+
if [ -d "$HOME/.asdf" ]; then
98+
echo "✓ $HOME/.asdf directory exists"
99+
ls -la "$HOME/.asdf/"
100+
else
101+
echo "✗ $HOME/.asdf directory does not exist"
102+
fi
103+
104+
if [ -f "$HOME/.asdf/bin/asdf" ]; then
105+
echo "✓ asdf binary exists"
106+
else
107+
echo "✗ asdf binary does not exist"
108+
fi
109+
110+
# Source asdf if it exists
111+
if [ -f "$HOME/.asdf/asdf.sh" ]; then
112+
echo "✓ Sourcing asdf.sh"
113+
source "$HOME/.asdf/asdf.sh"
114+
fi
115+
116+
- name: Install task CLI for CRE
117+
if: steps.changes.outputs.cre_changed == 'true' && inputs.install-go-tools == 'true'
118+
shell: bash
119+
run: |
120+
asdf install task
121+
122+
- name: Install protoc-gen-go for CRE
123+
if: steps.changes.outputs.cre_changed == 'true' && inputs.install-go-tools == 'true'
124+
shell: bash
125+
run: |
126+
go install google.golang.org/protobuf/cmd/protoc-gen-go@v${{ steps.tool-versions.outputs.protoc-gen-go_version }}
127+
128+
- name: Install protoc for CRE
129+
if: steps.changes.outputs.cre_changed == 'true' && inputs.install-go-tools == 'true'
130+
shell: bash
131+
run: |
132+
asdf install protoc

.github/workflows/cre-validations.yml

Lines changed: 127 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,145 @@ on:
55
types: [opened, reopened, synchronize]
66

77
permissions:
8-
contents: read
8+
contents: write
99
pull-requests: write
1010

1111
jobs:
12-
buf-cre:
12+
cre-tests:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
check:
18+
- name: "lint"
19+
cmd: "buf lint cre"
20+
needs_buf: true
21+
needs_go: false
22+
- name: "breaking"
23+
cmd: "buf breaking cre --against \".git#branch=main,subdir=cre\" --exclude-path node_modules"
24+
needs_buf: true
25+
needs_go: false
26+
- name: "gofmt"
27+
cmd: "gofmt -l cre"
28+
needs_buf: false
29+
needs_go: true
30+
- name: "go-test"
31+
cmd: "cd cre/go && go test ./..."
32+
needs_buf: false
33+
needs_go: true
34+
- name: "verify-run"
35+
cmd: "cd cre/verify && go run ."
36+
needs_buf: false
37+
needs_go: true
38+
- name: "verify-test"
39+
cmd: "cd cre/verify && go test ./..."
40+
needs_buf: false
41+
needs_go: true
42+
43+
steps:
44+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
45+
with:
46+
persist-credentials: true
47+
ref: ${{ github.head_ref || github.ref_name }}
48+
49+
- name: Setup CRE Environment
50+
id: setup
51+
uses: ./.github/actions/setup-cre
52+
with:
53+
install-buf: ${{ matrix.check.needs_buf }}
54+
install-go-tools: ${{ matrix.check.needs_go }}
55+
56+
- name: Run ${{ matrix.check.name }} check
57+
if: steps.setup.outputs.cre_changed == 'true'
58+
run: ${{ matrix.check.cmd }}
59+
60+
fix-cre:
1361
runs-on: ubuntu-latest
62+
outputs:
63+
commit_made: ${{ steps.auto-fix-completed.outputs.commit_made || steps.no-changes.outputs.commit_made }}
1464
steps:
15-
- uses: actions/checkout@v4 # v4.1.7
65+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
66+
with:
67+
persist-credentials: true
68+
ref: ${{ github.head_ref || github.ref_name }}
69+
70+
- name: Setup Environment
71+
id: setup
72+
uses: ./.github/actions/setup-cre
73+
with:
74+
install-buf: 'true'
75+
install-go-tools: 'true'
1676

17-
- name: Install buf CLI (v1.45.0, SHA bee67191e0a207d52b6c7f0ac9d3d1210898d2f9)
77+
- name: Auto-fix & regenerate
78+
if: steps.setup.outputs.cre_changed == 'true'
1879
run: |
19-
if ! command -v buf >/dev/null; then
20-
echo "Installing buf CLI v1.45.0..."
21-
curl -sSL https://github.com/bufbuild/buf/releases/download/v1.45.0/buf-$(uname -s)-$(uname -m) -o /usr/local/bin/buf
22-
chmod +x /usr/local/bin/buf
23-
else
24-
echo "buf CLI already available."
25-
fi
80+
buf format -w cre
81+
gofmt -w cre
82+
83+
cd cre/go
84+
go generate ./...
85+
go mod tidy
86+
cd -
87+
cd cre/verify
88+
go generate ./...
89+
go mod tidy
90+
2691
27-
- name: Check if cre/ files were modified
28-
id: changes
92+
- name: Detect regen changes
93+
if: steps.setup.outputs.cre_changed == 'true'
94+
id: detect-regen
2995
run: |
30-
if git diff --name-only origin/main...HEAD | grep '^cre/'; then
31-
echo "cre_changed=true" >> $GITHUB_OUTPUT
96+
if [[ -n "$(git status --porcelain)" ]]; then
97+
echo "changed=true" >> "$GITHUB_OUTPUT"
3298
else
33-
echo "cre_changed=false" >> $GITHUB_OUTPUT
99+
echo "changed=false" >> "$GITHUB_OUTPUT"
34100
fi
35101
36-
- name: Set tool versions
37-
if: steps.changes.outputs.cre_changed == 'true'
38-
id: tool-versions
39-
uses: smartcontractkit/tool-versions-to-env-action@v1.0.8
40-
41-
- name: Run buf lint for cre
42-
if: steps.changes.outputs.cre_changed == 'true'
43-
run: buf lint cre
102+
- name: Commit auto-fix changes
103+
if: steps.setup.outputs.cre_changed == 'true' && steps.detect-regen.outputs.changed == 'true'
104+
run: |
105+
git config --local user.email "action@github.com"
106+
git config --local user.name "GitHub Action"
107+
git add .
108+
git commit -m "Auto-fix: buf format, gofmt, go generate, go mod tidy [skip ci]"
109+
git push
44110
45-
- name: Run buf breaking for cre
46-
if: steps.changes.outputs.cre_changed == 'true'
47-
run: buf breaking cre --against ".git#branch=main,subdir=cre" --exclude-path node_modules
111+
- name: Auto-fix completed
112+
if: steps.setup.outputs.cre_changed == 'true' && steps.detect-regen.outputs.changed == 'true'
113+
id: auto-fix-completed
114+
run: |
115+
echo "commit_made=true" >> "$GITHUB_OUTPUT"
116+
echo "::notice::Auto-fix changes have been committed. The new commit will trigger a fresh workflow run with the fixes applied."
117+
exit 1
48118
49-
- name: Skip buf checks — no cre/ changes
50-
if: steps.changes.outputs.cre_changed == 'false'
51-
run: echo "No changes to cre/ — skipping buf lint and breaking checks."
119+
- name: No changes needed
120+
if: steps.setup.outputs.cre_changed == 'false' || steps.detect-regen.outputs.changed == 'false'
121+
id: no-changes
122+
run: |
123+
echo "commit_made=false" >> "$GITHUB_OUTPUT"
124+
if [[ "${{ steps.setup.outputs.cre_changed }}" == "false" ]]; then
125+
echo "::notice::No CRE files were modified, skipping auto-fix."
126+
else
127+
echo "::notice::No formatting or generation changes needed."
128+
fi
52129
130+
buf-cre:
131+
needs: [cre-tests, fix-cre]
132+
if: always()
133+
runs-on: ubuntu-latest
134+
steps:
135+
- name: Check results
136+
run: |
137+
echo "cre-tests result: ${{ needs.cre-tests.result }}"
138+
echo "fix-cre commit made: ${{ needs.fix-cre.outputs.commit_made }}"
139+
140+
if [[ "${{ needs.cre-tests.result }}" == "success" ]]; then
141+
echo "::notice::✅ All CRE tests passed successfully"
142+
exit 0
143+
elif [[ "${{ needs.fix-cre.outputs.commit_made }}" == "true" ]]; then
144+
echo "::notice::🔧 Auto-fix commit was made - workflow will re-run automatically with fixes applied"
145+
exit 1
146+
else
147+
echo "::error::❌ CRE tests failed and no automatic fix is available"
148+
exit 1
149+
fi

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
*.log
33

44
# Compiled binaries
5-
bin/
6-
dist/
5+
**/bin/
6+
**/dist/
77

88
# Editor files
99
.vscode

cre/go/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Run `make` to generate all the necessary files for the Go SDK.
2+
3+
Ideally, all genreated files would live in their SDKs repository (or a shared one like chainlink-common).
4+
The basic values, sdk, and tools are installed here in Go validation on protos CRE metadata.
5+
6+
Furthermore, since the value wrappers should never drift from the values protos, and are simply thin wrappers, it make sense to have them here.
7+
8+
Anything beyond that should be in the SDKs repository, and not in chainlink protos.

cre/go/generate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package cre
2+
3+
//go:generate go run ./installer/bootstrap
4+
//go:generate go run ./installer

cre/go/go.mod

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module github.com/smartcontractkit/chainlink-protos/cre/go
2+
3+
go 1.24.5
4+
5+
require (
6+
github.com/go-viper/mapstructure/v2 v2.4.0
7+
github.com/shopspring/decimal v1.4.0
8+
github.com/stretchr/testify v1.10.0
9+
google.golang.org/protobuf v1.36.7
10+
)
11+
12+
require (
13+
github.com/davecgh/go-spew v1.1.1 // indirect
14+
github.com/pmezard/go-difflib v1.0.0 // indirect
15+
gopkg.in/yaml.v3 v3.0.1 // indirect
16+
)

cre/go/go.sum

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
4+
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
5+
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
6+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
7+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
8+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9+
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
10+
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
11+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
12+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
13+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
14+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
15+
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
16+
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
17+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
18+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
19+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
20+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Code generated by github.com/smartcontractkit/chainlink-protos/cre/go/installer/bootstrap. DO NOT EDIT.\n")
2+
package pkg
3+
4+
{{ range . }}
5+
const {{.VarName}} = `{{.Content}}`
6+
{{ end }}
7+
8+
9+
var allFiles = []*embeddedFile{
10+
{{- range . }}
11+
{
12+
name: "{{.FileName}}",
13+
content: {{.VarName}},
14+
},
15+
{{- end }}
16+
}

0 commit comments

Comments
 (0)