Skip to content

Commit

Permalink
add helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
ErdongChen61 committed Oct 26, 2024
1 parent a329bf0 commit ee8c898
Show file tree
Hide file tree
Showing 12 changed files with 411 additions and 10 deletions.
37 changes: 37 additions & 0 deletions .github/chart_schema.yaml
Original file line number Diff line number Diff line change
@@ -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()
42 changes: 42 additions & 0 deletions .github/lintconf.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 2 additions & 10 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile.cloud
file: docker/Dockerfile
push: true
tags: scrolltech/sdk-cloud-prover:${{ github.ref_name }},scrolltech/sdk-cloud-prover:latest

# - name: Build and push local Docker image
# uses: docker/build-push-action@v4
# with:
# context: .
# file: docker/Dockerfile.local
# push: true
# tags: scrolltech/sdk-local-prover:${{ github.ref_name }},scrolltech/sdk-local-prover:latest
tags: snarkify/snarkify-scroll-proving-sdk:${{ github.ref_name }},snarkify/snarkify-scroll-proving-sdk:latest
104 changes: 104 additions & 0 deletions .github/workflows/publish-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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: |
# TODO: Update this line
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: |
# TODO: Update this line
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 }')
# TODO: Update this line
helm push $chart-${CHART_VERSION}.tgz oci://ghcr.io/scroll-tech/scroll-sdk/helm
done
Empty file.
23 changes: 23 additions & 0 deletions charts/snarkify-scroll-proving-sdk/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
16 changes: 16 additions & 0 deletions charts/snarkify-scroll-proving-sdk/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: v2
description: A chart for Scroll SDK to generate proofs in Snarkify platform.
name: snarkify-scroll-proving-sdk
version: 0.0.1
kubeVersion: ">=1.22.0-0"
maintainers:
- name: snarkify
email: support@snarkify.io
dependencies:
- name: common
repository: "oci://ghcr.io/scroll-tech/scroll-sdk/helm"
version: 1.5.1
type: application


14 changes: 14 additions & 0 deletions charts/snarkify-scroll-proving-sdk/templates/common.yaml
Original file line number Diff line number Diff line change
@@ -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" . }}
10 changes: 10 additions & 0 deletions charts/snarkify-scroll-proving-sdk/templates/config-file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-config
labels:
{{- include "scroll-sdk.labels" $ | nindent 4 }}
data:
config.json: |
{{ .Values.scrollConfig | indent 4 }}
47 changes: 47 additions & 0 deletions charts/snarkify-scroll-proving-sdk/templates/helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
Loading

0 comments on commit ee8c898

Please sign in to comment.