diff --git a/.github/chart_schema.yaml b/.github/chart_schema.yaml new file mode 100644 index 0000000..af357f4 --- /dev/null +++ b/.github/chart_schema.yaml @@ -0,0 +1,37 @@ +name: str() +home: str(required=False) +version: str() +apiVersion: str() +appVersion: any(str(), num(), required=False) +description: str(required=False) +keywords: list(str(), required=False) +sources: list(str(), required=False) +maintainers: list(include('maintainer'), required=False) +dependencies: list(include('dependency'), required=False) +icon: str(required=False) +engine: str(required=False) +condition: str(required=False) +tags: str(required=False) +deprecated: bool(required=False) +kubeVersion: str(required=False) +annotations: map(str(), str(), required=False) +type: str(required=False) +--- +maintainer: + name: str() + email: str(required=False) + url: str(required=False) +--- +dependency: + name: str() + version: str() + repository: str(required=False) + condition: str(required=False) + tags: list(str(), required=False) + enabled: bool(required=False) + import-values: any(list(str()), list(include('import-value')), required=False) + alias: str(required=False) +--- +import-value: + child: str() + parent: str() \ No newline at end of file diff --git a/.github/lintconf.yaml b/.github/lintconf.yaml new file mode 100644 index 0000000..6789bc5 --- /dev/null +++ b/.github/lintconf.yaml @@ -0,0 +1,42 @@ +--- +rules: + braces: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + colons: + max-spaces-before: 0 + max-spaces-after: 1 + commas: + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: + require-starting-space: true + min-spaces-from-content: 2 + document-end: disable + document-start: disable # No --- to start a file + empty-lines: + max: 2 + max-start: 0 + max-end: 0 + hyphens: + max-spaces-after: 1 + indentation: + spaces: consistent + indent-sequences: whatever # - list indentation will handle both indentation and without + check-multi-line-strings: false + key-duplicates: enable + line-length: disable # Lines can be any length + new-line-at-end-of-file: enable + new-lines: + type: unix + trailing-spaces: enable + truthy: + level: warning \ No newline at end of file diff --git a/.github/workflows/publish-chart.yaml b/.github/workflows/publish-chart.yaml new file mode 100644 index 0000000..9aee48b --- /dev/null +++ b/.github/workflows/publish-chart.yaml @@ -0,0 +1,101 @@ +name: Lint, test and publish charts + +on: + push: + branches: [ main ] + paths: + - 'charts/**' + +jobs: + helm-chart-testing: + name: chart-testing + runs-on: ubuntu-latest + environment: test + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: v3.12.1 + + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.0 + + - name: Helm registry login + run: | + helm registry login ghcr.io/scroll-tech/helm/scroll-sdk --username ${{ github.actor }} --password ${{ secrets.HELM_GITHUB_PASSWORD }} + env: + HELM_GITHUB_PASSWORD: "${{ secrets.HELM_GITHUB_PASSWORD }}" + + # List chart change except scroll-sdk + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --excluded-charts scroll-sdk --target-branch ${{ github.event.repository.default_branch }} ) + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Run chart-testing (lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --config ct.yaml --excluded-charts scroll-sdk --target-branch ${{ github.event.repository.default_branch }} + + publish-ghcr: + name: publish-to-github + runs-on: ubuntu-latest + needs: + - helm-chart-testing + outputs: + charts: ${{ steps.list-changed.outputs.changed }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: dorny/paths-filter@v2 + id: filter + with: + base: ${{ github.event.repository.default_branch }} + list-files: shell + filters: | + addedOrModified: + - added|modified: 'charts/**' + + - name: Helm registry login + run: | + helm registry login ghcr.io/scroll-tech/helm/scroll-sdk --username ${{ github.actor }} --password ${{ secrets.HELM_GITHUB_PASSWORD }} + env: + HELM_GITHUB_PASSWORD: "${{ secrets.HELM_GITHUB_PASSWORD }}" + + - name: Push chart to ghcr + if: steps.filter.outputs.addedOrModified == 'true' + env: + HELM_EXPERIMENTAL_OCI: 1 + run: | + set -x + CHARTS=() + PATHS=(${{ steps.filter.outputs.addedOrModified_files }}) + echo ${PATHS} + # Get only the chart paths + for i in "${PATHS[@]}" + do + chart=$(echo $i | awk -F "/" '{print $2}') + done + # Remove duplicates + CHARTS=( `for i in ${CHARTS[@]}; do echo $i; done | sort -u` ) + echo "CHARTS: ${CHARTS[@]}" + for chart in ${CHARTS[@]}; do + helm dependencies build charts/$chart + helm package charts/$chart + export CHART_VERSION=$(grep 'version:' charts/$chart/Chart.yaml | head -n1 | awk '{ print $2 }') + helm push $chart-${CHART_VERSION}.tgz oci://ghcr.io/scroll-tech/scroll-sdk/helm + done diff --git a/.github/workflows/publish-dev-chart.yaml b/.github/workflows/publish-dev-chart.yaml new file mode 100644 index 0000000..6765665 --- /dev/null +++ b/.github/workflows/publish-dev-chart.yaml @@ -0,0 +1,103 @@ +name: Lint, test and publish dev charts + +on: + push: + paths: + - 'charts/**' + +env: + HELM_REGISTRY: ghcr.io/scroll-tech/scroll-sdk/helm/dev + +jobs: + helm-chart-testing-not-scroll-sdk: + name: chart-testing-without-scroll-sdk + runs-on: ubuntu-latest + environment: test + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: v3.12.1 + + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.0 + + - name: Helm registry login + run: | + helm registry login ghcr.io/scroll-tech/helm/scroll-sdk --username ${{ github.actor }} --password ${{ secrets.HELM_GITHUB_PASSWORD }} + env: + HELM_GITHUB_PASSWORD: "${{ secrets.HELM_GITHUB_PASSWORD }}" + + # List chart change except scroll-sdk + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --excluded-charts scroll-sdk --target-branch ${{ github.event.repository.default_branch }} ) + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Run chart-testing (lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --config ct.yaml --excluded-charts scroll-sdk --target-branch ${{ github.event.repository.default_branch }} + + publish-ghcr-not-scroll-sdk: + name: publish-to-github-without-scroll-sdk + runs-on: ubuntu-latest + needs: + - helm-chart-testing-not-scroll-sdk + outputs: + charts: ${{ steps.list-changed.outputs.changed }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: dorny/paths-filter@v2 + id: filter + with: + base: ${{ github.event.repository.default_branch }} + list-files: shell + filters: | + addedOrModified: + - added|modified: 'charts/**' + + - name: Helm registry login + run: | + helm registry login ghcr.io/scroll-tech/helm/scroll-sdk --username ${{ github.actor }} --password ${{ secrets.HELM_GITHUB_PASSWORD }} + env: + HELM_GITHUB_PASSWORD: "${{ secrets.HELM_GITHUB_PASSWORD }}" + + - name: Push chart to ghcr + if: steps.filter.outputs.addedOrModified == 'true' + env: + HELM_EXPERIMENTAL_OCI: 1 + run: | + set -x + CHARTS=() + PATHS=(${{ steps.filter.outputs.addedOrModified_files }}) + echo ${PATHS} + # Get only the chart paths + for i in "${PATHS[@]}" + do + chart=$(echo $i | awk -F "/" '{print $2}') + done + # Remove duplicates + CHARTS=( `for i in ${CHARTS[@]}; do echo $i; done | sort -u` ) + echo "CHARTS: ${CHARTS[@]}" + for chart in ${CHARTS[@]}; do + helm dependencies build charts/$chart + helm package charts/$chart + export CHART_VERSION=$(grep 'version:' charts/$chart/Chart.yaml | head -n1 | awk '{ print $2 }') + helm push $chart-${CHART_VERSION}.tgz oci://${HELM_REGISTRY} + done diff --git a/.gitignore b/.gitignore index 9c0348c..e0082f6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,7 @@ target/ config.json keys/ + +# Helm chart related +*.lock +*.tgz \ No newline at end of file diff --git a/charts/scroll-proving-sdk/Chart.yaml b/charts/scroll-proving-sdk/Chart.yaml new file mode 100644 index 0000000..f4ef8c0 --- /dev/null +++ b/charts/scroll-proving-sdk/Chart.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: v2 +description: Example chart for showing how to package a service built using the scroll-proving-sdk library +name: scroll-proving-sdk +version: 0.0.3 +appVersion: v0.1.0 +kubeVersion: ">=1.22.0-0" +maintainers: + - name: scroll-tech + email: sebastien@scroll.io +dependencies: + - name: common + repository: "oci://ghcr.io/scroll-tech/scroll-sdk/helm" + version: 1.5.1 diff --git a/charts/scroll-proving-sdk/README.md b/charts/scroll-proving-sdk/README.md new file mode 100644 index 0000000..1f09f51 --- /dev/null +++ b/charts/scroll-proving-sdk/README.md @@ -0,0 +1,63 @@ +# scroll-proving-sdk + +![Version: 0.0.3](https://img.shields.io/badge/Version-0.0.3-informational?style=flat-square) ![AppVersion: v0.1.0](https://img.shields.io/badge/AppVersion-v0.1.0-informational?style=flat-square) + +Example chart for showing how to package a service built using the scroll-proving-sdk library + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| scroll-tech | | | + +## Requirements + +Kubernetes: `>=1.22.0-0` + +| Repository | Name | Version | +|------------|------|---------| +| oci://ghcr.io/scroll-tech/scroll-sdk/helm | common | 1.5.1 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| command[0] | string | `"/bin/sh"` | | +| command[1] | string | `"-c"` | | +| command[2] | string | `"exec cloud --config /sdk_prover/config.json"` | | +| defaultProbes.custom | bool | `true` | | +| defaultProbes.enabled | bool | `true` | | +| defaultProbes.spec.httpGet.path | string | `"/"` | | +| defaultProbes.spec.httpGet.port | int | `80` | | +| global.fullnameOverride | string | `"scroll-proving-sdk"` | | +| global.nameOverride | string | `"scroll-proving-sdk"` | | +| image.pullPolicy | string | `"Always"` | | +| image.repository | string | `"scrolltech/sdk-cloud-prover"` | | +| image.tag | string | `"sindri-2791edca"` | | +| persistence.app_name.enabled | bool | `true` | | +| persistence.app_name.mountPath | string | `"/sdk_prover/"` | | +| persistence.app_name.name | string | `"scroll-proving-sdk-config"` | | +| persistence.app_name.type | string | `"configMap"` | | +| probes.liveness.<<.custom | bool | `true` | | +| probes.liveness.<<.enabled | bool | `true` | | +| probes.liveness.<<.spec.httpGet.path | string | `"/"` | | +| probes.liveness.<<.spec.httpGet.port | int | `80` | | +| probes.readiness.<<.custom | bool | `true` | | +| probes.readiness.<<.enabled | bool | `true` | | +| probes.readiness.<<.spec.httpGet.path | string | `"/"` | | +| probes.readiness.<<.spec.httpGet.port | int | `80` | | +| probes.startup.<<.custom | bool | `true` | | +| probes.startup.<<.enabled | bool | `true` | | +| probes.startup.<<.spec.httpGet.path | string | `"/"` | | +| probes.startup.<<.spec.httpGet.port | int | `80` | | +| resources.limits.cpu | string | `"100m"` | | +| resources.limits.memory | string | `"500Mi"` | | +| resources.requests.cpu | string | `"50m"` | | +| resources.requests.memory | string | `"100Mi"` | | +| scrollConfig | string | `"{}\n"` | | +| service.main.enabled | bool | `true` | | +| service.main.ports.http.enabled | bool | `true` | | +| service.main.ports.http.port | int | `80` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2) diff --git a/charts/scroll-proving-sdk/index.yaml b/charts/scroll-proving-sdk/index.yaml new file mode 100644 index 0000000..4466a03 --- /dev/null +++ b/charts/scroll-proving-sdk/index.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +entries: + common: + - apiVersion: v2 + created: "2024-08-05T16:32:51.061701+02:00" + description: Function library for Helm charts + digest: e75d90ca3a07e1b5ed4677c893ab007ba85c67d7ff60cca217b4ab0776050d0d + keywords: + - common + - library + kubeVersion: '>=1.22.0-0' + maintainers: + - email: sebastien@scroll.io + name: sebastien + name: common + type: library + urls: + - charts/common-1.5.1.tgz + version: 1.5.1 +generated: "2024-08-05T16:32:51.059889+02:00" diff --git a/charts/scroll-proving-sdk/templates/common.yaml b/charts/scroll-proving-sdk/templates/common.yaml new file mode 100644 index 0000000..ed32775 --- /dev/null +++ b/charts/scroll-proving-sdk/templates/common.yaml @@ -0,0 +1,14 @@ +--- +{{- include "scroll.common.loader.init" . }} + +{{- define "app-template.hardcodedValues" -}} +# Set the nameOverride based on the release name if no override has been set +{{ if not .Values.global.nameOverride }} +global: + nameOverride: "{{ .Release.Name }}" +{{ end }} +{{- end -}} +{{- $_ := mergeOverwrite .Values (include "app-template.hardcodedValues" . | fromYaml) -}} + +{{/* Render the templates */}} +{{ include "scroll.common.loader.generate" . }} diff --git a/charts/scroll-proving-sdk/templates/config-file.yaml b/charts/scroll-proving-sdk/templates/config-file.yaml new file mode 100644 index 0000000..0d8136b --- /dev/null +++ b/charts/scroll-proving-sdk/templates/config-file.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: scroll-proving-sdk-config + labels: + {{- include "scroll-sdk.labels" $ | nindent 4 }} +data: + config.json: | +{{ .Values.scrollConfig | indent 4 }} diff --git a/charts/scroll-proving-sdk/templates/helpers.tpl b/charts/scroll-proving-sdk/templates/helpers.tpl new file mode 100644 index 0000000..d762ba1 --- /dev/null +++ b/charts/scroll-proving-sdk/templates/helpers.tpl @@ -0,0 +1,47 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "scroll-sdk.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "scroll-sdk.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} +{{/* +Create chart name and build as used by the chart label. +*/}} +{{- define "scroll-sdk.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} +{{/* +Common labels +*/}} +{{- define "scroll-sdk.labels" -}} +helm.sh/chart: {{ include "scroll-sdk.chart" . }} +{{ include "scroll-sdk.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/build: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} +{{/* +Selector labels +*/}} +{{- define "scroll-sdk.selectorLabels" -}} +app.kubernetes.io/name: {{ include "scroll-sdk.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/scroll-proving-sdk/values.yaml b/charts/scroll-proving-sdk/values.yaml new file mode 100644 index 0000000..7c128a0 --- /dev/null +++ b/charts/scroll-proving-sdk/values.yaml @@ -0,0 +1,82 @@ +--- +global: + nameOverride: &app_name scroll-proving-sdk + fullnameOverride: *app_name + +image: + repository: scrolltech/sdk-cloud-prover + pullPolicy: Always + tag: sindri-2791edca + +command: + - "/bin/sh" + - "-c" + - "exec cloud --config /sdk_prover/config.json" + +resources: + requests: + memory: "100Mi" + cpu: "50m" + limits: + memory: "500Mi" + cpu: "100m" + +persistence: + *app_name: + enabled: true + type: configMap + mountPath: /sdk_prover/ + name: scroll-proving-sdk-config + +service: + main: + enabled: true + ports: + http: + enabled: true + port: 80 + +defaultProbes: &default_probes + enabled: true + custom: true + spec: + httpGet: + path: "/" + port: 80 + +probes: + liveness: + <<: *default_probes + readiness: + <<: *default_probes + startup: + <<: *default_probes + +# scrollConfig should be overwritten the config in json format. See the example below. +scrollConfig: | + {} +# { +# "prover_name_prefix": "sindri_", +# "keys_dir": "keys", +# "coordinator": { +# "base_url": "https://coordinator-api.scrollsdk", +# "retry_count": 3, +# "retry_wait_time_sec": 5, +# "connection_timeout_sec": 60 +# }, +# "l2geth": { +# "endpoint": "https://l2-rpc.scrollsdk" +# }, +# "prover": { +# "circuit_type": 3, +# "circuit_version": "v0.13.1", +# "n_workers": 1, +# "cloud": { +# "base_url": "https://sindri.app/api/v1/", +# "api_key": , +# "retry_count": 3, +# "retry_wait_time_sec": 5, +# "connection_timeout_sec": 60 +# } +# } +# } diff --git a/charts/scroll-proving-sdk/values/production.yaml b/charts/scroll-proving-sdk/values/production.yaml new file mode 100644 index 0000000..bd8ee52 --- /dev/null +++ b/charts/scroll-proving-sdk/values/production.yaml @@ -0,0 +1,26 @@ +scrollConfig: | + { + "prover_name_prefix": "sindri_", + "keys_dir": "keys", + "coordinator": { + "base_url": "https://coordinator-api.scrollsdk", + "retry_count": 3, + "retry_wait_time_sec": 5, + "connection_timeout_sec": 60 + }, + "l2geth": { + "endpoint": "https://l2-rpc.scrollsdk" + }, + "prover": { + "circuit_type": 3, + "circuit_version": "v0.13.1", + "n_workers": 1, + "cloud": { + "base_url": "https://sindri.app/api/v1/", + "api_key": , + "retry_count": 3, + "retry_wait_time_sec": 5, + "connection_timeout_sec": 60 + } + } + } diff --git a/ct.yaml b/ct.yaml new file mode 100644 index 0000000..5a22705 --- /dev/null +++ b/ct.yaml @@ -0,0 +1,7 @@ +remote: origin +target-branch: main +chart-dirs: + - charts +validate-maintainers: true +check-version-increment: true +debug: true