-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend ccip helm chart to use ccip-scripts for contract deployment (#614
) ## Motivation Enable automated E2E testing via providing a workflow to automate deployment of ccip contracts and jobs within devspace/helm setup. ## Solution Added a batch job that will install scripts and contracts as part of `helm install/upgrade` command. To provide more context I posted GH comments alongside the source code --------- Co-authored-by: chainchad <96362174+chainchad@users.noreply.github.com>
- Loading branch information
1 parent
7f6bc20
commit a6bdf8e
Showing
11 changed files
with
277 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Helm | ||
charts/ | ||
requirements.lock | ||
.rendered |
This file contains 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 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 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,57 @@ | ||
{{- if $.Values.ccip.deployContractsAndJobs }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ccip-scripts-config | ||
data: | ||
config.json: | | ||
{ | ||
"EnvName": "{{$.Release.Namespace}}", | ||
"DONCreds": { | ||
"Env": "{{$.Release.Namespace}}", | ||
"Bootstrap": { | ||
{{- with (index $.Values.chainlink.nodes 0) }} | ||
"URL": "http://app-{{.name}}.{{$.Release.Namespace}}.svc.cluster.local:{{$.Values.chainlink.web_port}}", | ||
"Email": "notreal@fakeemail.ch", | ||
"Password": "fj293fbBnlQ!f9vNs", | ||
"InternalIP": "{{$.Release.Name}}-{{.name}}", | ||
{{- end}} | ||
"HTTPTimeout": null | ||
}, | ||
"Nodes": [ | ||
{{- range $index, $cfg := $.Values.chainlink.nodes }} | ||
{{- if ne $index 0}} | ||
{{- $nameWithoutHyphen := $cfg.name | replace "-" "" }} | ||
{{- if ne $index 1 }},{{- end }}{ | ||
"URL": "http://app-{{$cfg.name}}.{{$.Release.Namespace}}.svc.cluster.local:{{$.Values.chainlink.web_port}}", | ||
"Email": "notreal@fakeemail.ch", | ||
"Password": "fj293fbBnlQ!f9vNs", | ||
"InternalIP": "{{$.Release.Name}}-{{$cfg.name}}", | ||
"HTTPTimeout": null | ||
} | ||
{{- end}} | ||
{{- end}} | ||
] | ||
}, | ||
{{- $networkIDs := list }} | ||
{{- range $index, $cfg :=$.Values.ccip.chains }} | ||
{{- $networkIDs = append $networkIDs $cfg.ChainId }} | ||
{{- end }} | ||
{{- $delimiter := "," }} | ||
{{- $foldedString := join $delimiter $networkIDs }} | ||
"ChainPairs":[{{- printf $foldedString | quote }}], | ||
"CCIPChains": { | ||
{{- range $index, $cfg := $.Values.ccip.chains }} | ||
{{- if ne $index 0 }},{{- end }}"{{$cfg.ChainId}}":{ | ||
"NetworkURL": "ws://geth-{{$cfg.NetworkId}}.{{$.Release.Namespace}}.svc.cluster.local:{{$.Values.geth.wsRpcPort}}", | ||
"WalletKey": {{$cfg.WalletKey | quote}}, | ||
"DeployLink": {{$cfg.DeployLink}}, | ||
"DeployWETH": {{$cfg.DeployWETH}}, | ||
"ChainConfig": {{$cfg.ChainConfig | toJson}} | ||
} | ||
{{- end}} | ||
}, | ||
"LaneDeploySettings": {{$.Values.ccip.LaneDeploySettings | toJson }} | ||
} | ||
{{- end }} |
This file contains 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,71 @@ | ||
{{- if $.Values.ccip.deployContractsAndJobs }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: ccip-scripts-deployer | ||
labels: | ||
app: ccip-scripts-deployer | ||
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
annotations: | ||
prometheus.io/scrape: 'true' | ||
# This is what defines this resource as a hook. Without this line, the | ||
# job is considered part of the release. | ||
"helm.sh/hook": post-install,post-upgrade | ||
"helm.sh/hook-weight": "0" | ||
"helm.sh/hook-delete-policy": before-hook-creation | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: ccip-scripts-deployer | ||
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
annotations: | ||
prometheus.io/scrape: 'true' | ||
spec: | ||
initContainers: | ||
- name: wait-for-nodes | ||
image: {{.Values.ccip.ccipScriptsImage}} | ||
volumeMounts: | ||
- name: scripts-volume | ||
mountPath: /scripts | ||
securityContext: | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsUser: 999 | ||
runAsGroup: 999 | ||
runAsNonRoot: true | ||
command: | ||
- bash | ||
- /scripts/wait_for_endpoint.sh | ||
{{- with (index $.Values.chainlink.nodes 0) }} | ||
- "http://app-{{.name}}.{{$.Release.Namespace}}.svc.cluster.local:{{$.Values.chainlink.web_port}}" | ||
{{- end }} | ||
containers: | ||
- name: ccip-scripts | ||
image: {{.Values.ccip.ccipScriptsImage}} | ||
env: | ||
- name: CONFIG_JSON_PATH | ||
value: /data/config.json | ||
command: [ "pilot.test", "-test.v" ] | ||
volumeMounts: | ||
- name: config-volume | ||
mountPath: /data | ||
securityContext: | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsUser: 999 | ||
runAsGroup: 999 | ||
runAsNonRoot: true | ||
restartPolicy: Never | ||
volumes: | ||
- name: config-volume | ||
configMap: | ||
name: ccip-scripts-config | ||
- name: scripts-volume | ||
configMap: | ||
defaultMode: 0755 | ||
name: ccip-scripts-scripts | ||
backoffLimit: 0 | ||
{{- end}} |
38 changes: 38 additions & 0 deletions
38
charts/chainlink-cluster/templates/ccip-scripts-scripts-cm.yaml
This file contains 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,38 @@ | ||
{{- if $.Values.ccip.deployContractsAndJobs }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ccip-scripts-scripts | ||
data: | ||
wait_for_endpoint.sh: | | ||
#!/bin/bash | ||
# Define your endpoint URL | ||
ENDPOINT_URL="${1}" | ||
if [ "${ENDPOINT_URL}" = "" ]; then | ||
echo "Need an argument for the ENDPOINT_URL in argument 1" | ||
exit 1 | ||
fi | ||
# Function to check if the endpoint returns a 200 status code | ||
check_endpoint() { | ||
status_code=$(curl -s -o /dev/null -w "%{http_code}" "$ENDPOINT_URL") | ||
if [ "$status_code" == "200" ]; then | ||
echo "Endpoint is ready!" | ||
exit 0 | ||
else | ||
echo "Endpoint is not yet ready, status code: $status_code" | ||
return 1 | ||
fi | ||
} | ||
# Main loop to periodically check the endpoint | ||
echo "Waiting for endpoint to be ready..." | ||
while ! check_endpoint; do | ||
sleep 5 | ||
done | ||
echo "Endpoint is ready!" | ||
{{- end }} |
This file contains 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 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 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 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
Oops, something went wrong.