Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Superset repackaging as beta release/helm packages build, test, lint, helm-docs, publication #1

Merged
merged 8 commits into from
Jun 6, 2024
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
9 changes: 9 additions & 0 deletions .ct.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
lint-conf: .lintconf.yaml
remote: origin
target-branch: main
chart-dirs:
- .
chart-repos:
- superset=https://apache.github.io/superset
- bitnami=https://charts.bitnami.com/bitnami
debug: true
40 changes: 40 additions & 0 deletions .github/actions/free-disk-space/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Copyright 2024 tosit.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: Free disk space
description: Free Github runnner disk space

runs:
using: composite
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true



42 changes: 42 additions & 0 deletions .github/actions/helm-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright 2024 tosit.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: helm-docs
description: Auto-generates documentation from helm chart

inputs:
# chart_name:
# description: Helm chart name
# required: true
helm_docs_version:
description: helm-docs version
required: false
default: "1.13.1"

runs:
using: composite
steps:

- name: Install helm-docs
run: |
wget https://github.com/norwoodj/helm-docs/releases/download/v${{ inputs.helm_docs_version }}/helm-docs_${{ inputs.helm_docs_version }}_Linux_x86_64.deb
sudo apt install ./helm-docs_${{ inputs.helm_docs_version }}_Linux_x86_64.deb
rm -f helm-docs_${{ inputs.helm_docs_version }}_Linux_x86_64.deb
shell: bash




37 changes: 37 additions & 0 deletions .github/actions/setup-kind/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Copyright 2024 tosit.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: Setup kind
description: Deploy kind cluster

runs:
using: composite
steps:
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
with:
# https://github.com/helm/kind-action?tab=readme-ov-file#inputs
verbosity: 10
cluster_name: "kind-ci-${{ github.job }}"
ignore_failed_clean: true # Ignore the post delete cluster action failing
wait: "180s" # Max timeout to wait Kind becomes ready

- name: Print Kind cluster state
run: |
kubectl cluster-info
kubectl get pods -A
kubectl describe node
shell: bash
139 changes: 139 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#
# Copyright 2024 tosit.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: ci

on:
pull_request:
branches:
- main
paths:
- ".github/workflows/**"
- ".github/actions/**"

- ".ct.yml"
- ".lintconf.yaml"

- "**/**"

- "!README.md"
- "!**/README.md"
- "!docs/**"

push:
branches:
- '**'
- '!gh-pages'
paths:
- ".github/workflows/**"
- ".github/actions/**"

- ".ct.yml"
- ".lintconf.yaml"

- "**/**"

- "!README.md"
- "!**/README.md"
- "!docs/**"

workflow_dispatch:

permissions:
contents: write

# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
# Only cancel in-progress jobs or runs for the current workflow - matches against branch & tags
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:

helm-lint:
runs-on: "ubuntu-latest"
steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup helm
uses: azure/setup-helm@v4.2.0
with:
version: v3.15.1

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.6.1

- name: Run chart-testing (list-changed) ✅
id: list-changed
run: |
changed=$(ct list-changed --config .ct.yml --print-config)
if [[ -n "$changed" ]]; then
echo "list_changed=$(echo ${changed} | tr -d \')" >> "$GITHUB_OUTPUT"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Run chart-testing (lint) ✅
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --config .ct.yml --check-version-increment=false --print-config

- name: Free up disk space 🧹
if: steps.list-changed.outputs.changed == 'true'
uses: ./.github/actions/free-disk-space

- name: Set up kind cluster ✅
if: steps.list-changed.outputs.changed == 'true'
uses: ./.github/actions/setup-kind

- name: Run chart-testing (install) ✅
if: steps.list-changed.outputs.changed == 'true'
run: ct install --config .ct.yml --print-config

- name: Install helm-docs
if: steps.list-changed.outputs.changed == 'true'
uses: ./.github/actions/helm-docs

- name: Generate helm docs
if: steps.list-changed.outputs.changed == 'true'
run: |
echo "Generate docs from charts: ${{ steps.list-changed.outputs.list_changed }}"
helm-docs --chart-to-generate $(echo "${{ steps.list-changed.outputs.list_changed }}" | tr " " ",")

- name: Commit helm docs changes
# Github token from forked repo does not have permission to push to target repo
# Skip the step for PRs from forked repos
if: |
${{ steps.list-changed.outputs.changed == 'true'
&& ((github.event_name == 'push') || (github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.repository)) }}
uses: EndBug/add-and-commit@v9
with:
pull: "--rebase --autostash"
add: "**/README.md"
message: '[helm-docs] Update readme'
author_name: github-actions[bot]
author_email: 41898282+github-actions[bot]@users.noreply.github.com

102 changes: 102 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#
# Copyright 2024 tosit.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: publish

on:
workflow_call:
inputs:
chart_name:
description: Helm chart version
required: true
type: string
version:
description: Helm chart version
required: true
type: string

env:
release_tag_name: ${{ inputs.chart_name }}-v${{ inputs.version }}
chart_package_name: ${{ inputs.chart_name }}-${{ inputs.version }}.tgz
cr_release_name_template: "{{ .Name }}-v{{ .Version }}"

defaults:
run:
shell: bash

jobs:

helm-chart-publish:
name: "Publish (${{ inputs.chart_name }}-${{ inputs.version }})"
runs-on: "ubuntu-latest"
steps:
- name: Checkout release tag ${{ env.release_tag_name }} ⚡️
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.release_tag_name }}

- name: Setup helm
uses: azure/setup-helm@v4.2.0
with:
version: v3.15.1

- name: Add chart dependencies
run: |
helm repo add superset https://apache.github.io/superset
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update

- name: Install chart-releaser (cr)
uses: helm/chart-releaser-action@v1.6.0
with:
install_only: true

- name: Package helm chart ${{ inputs.chart_name }} (${{ inputs.version }})
run: |
helm dependency build ${{ inputs.chart_name }}
cr package ${{ inputs.chart_name }}

- name: Upload Chart package to Github release
run: |
gh release upload ${{ env.release_tag_name }} ./.cr-release-packages/${{ env.chart_package_name }} --clobber
env:
GH_TOKEN: ${{ github.token }}
shell: bash

- name: Checkout gh-pages branch ⚡️
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: gh-pages
path: gh-pages

- name: Update helm chart index.yaml
run: |
cr index -i gh-pages/index.yaml \
-r ${GITHUB_REPOSITORY#*/} \
-o ${{ github.repository_owner }} \
--release-name-template "${{ env.cr_release_name_template }}"
shell: bash

- name: Commit helm chart index.yaml changes into gh-pages branch
uses: EndBug/add-and-commit@v9
with:
cwd: gh-pages
pull: "--rebase --autostash"
message: '[${{ inputs.chart_name }}-${{ inputs.version }}] - Update index.yaml'
author_name: github-actions[bot]
author_email: 41898282+github-actions[bot]@users.noreply.github.com
Loading