Skip to content

Commit

Permalink
Add chart repository (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
borchero authored Jul 31, 2022
1 parent bf77fad commit 9cb1664
Show file tree
Hide file tree
Showing 23 changed files with 810 additions and 51 deletions.
135 changes: 135 additions & 0 deletions .github/workflows/application-build-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Build and Test Container Image
on:
release:
types:
- published
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
file-changes:
name: Gather File Changes
runs-on: ubuntu-20.04
outputs:
chart: ${{ steps.changes.outputs.chart }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Gather File Changes
uses: dorny/paths-filter@v2
id: changes
with:
list-files: none
filters: |
chart:
- chart/**
build-image:
name: Build Image
needs:
- file-changes
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Assemble Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
# We want to set the following tags:
# - `main` if executed for build on main branch
# - SemVer when running for a release
tags: |
type=ref,enable=${{ github.ref_name == 'main' }},event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
# Only push when building for a tag or the main branch
if: github.ref_type == 'tag' || (github.ref_type == 'branch' && github.ref_name == 'main')
- name: Build Multi-Platform Image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
# Only push when building for a tag or the main branch
push:
${{ github.ref_type == 'tag' || (github.ref_type == 'branch' && github.ref_name ==
'main') }}
tags: ${{ steps.meta.outputs.tags }}
# Only export and upload the image if used for testing
- name: Export Image for Test Platform
if: needs.file-changes.outputs.chart == 'true' && github.ref_type != 'tag'
uses: docker/build-push-action@v3
with:
context: .
push: false
outputs: type=oci,dest=/tmp/image.tar
- name: Upload Image for Testing
uses: actions/upload-artifact@v2
if: needs.file-changes.outputs.chart == 'true' && github.ref_type != 'tag'
with:
name: docker-image
path: /tmp/image.tar

e2e-tests:
name: Test Helm Chart
needs:
- file-changes
- build-image
runs-on: ubuntu-20.04
if: needs.file-changes.outputs.chart == 'true' && github.ref_type != 'tag'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Install Bats
run: npm install -g [email protected]
shell: bash
- name: Download Image for Testing
uses: actions/download-artifact@v2
with:
name: docker-image
path: /tmp
- name: Setup Kubernetes Cluster
uses: container-tools/[email protected]
with:
config: chart/tests/kind/actions.yaml
- name: Load Docker Image
run: |
docker load -i /tmp/image.tar
docker image ls
IMAGE_ID=$(docker load -i /tmp/image.tar | rev | cut -d' ' -f1 | rev)
docker tag $IMAGE_ID $KIND_REGISTRY/switchboard:dev
docker push $KIND_REGISTRY/switchboard:dev
- name: Specify Image Tag
uses: mikefarah/[email protected]
with:
cmd: |
yq -i '
.image.name = "${{ env.KIND_REGISTRY }}/switchboard" |
.image.tag = "dev"
' chart/tests/values/base.yaml
- name: Run Tests
run: bats ./tests -t
working-directory: ./chart
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
name: Check Code
on:
pull_request:
branches:
- main
paths-ignore:
- chart/**
push:
branches:
- "*"
- main
paths-ignore:
- chart/**

jobs:
lint:
name: Run Linting
runs-on: ubuntu-20.04
container: golangci/golangci-lint:v1.45
steps:
Expand All @@ -16,6 +24,7 @@ jobs:
golangci-lint run --exclude-use-default=false -E goimports -E revive --timeout 10m ./...

test:
name: Run Unit Tests
runs-on: ubuntu-20.04
steps:
- name: Checkout
Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/build-image.yaml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/chart-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Check Helm Chart
on:
pull_request:
branches:
- main
paths:
- chart/**
push:
branches:
- main
paths:
- chart/**

jobs:
lint:
name: Run Linting
runs-on: ubuntu-20.04
container: alpine/helm:3.8.2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Lint Chart
run: helm lint
working-directory: ./chart

check-docs:
name: Check Docs
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ">=1.18.0"
- name: Download helm-docs
run: go install github.com/norwoodj/helm-docs/cmd/[email protected]
- name: Generate README
run: helm-docs
working-directory: ./chart
- name: Check for changes
run: helm-docs -o README.tmp.md && diff README.md README.tmp.md
working-directory: ./chart
34 changes: 34 additions & 0 deletions .github/workflows/chart-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Helm Chart
on:
release:
types:
- published

jobs:
publish:
name: Package and Upload
runs-on: ubuntu-20.04
container: alpine/helm:3.8.2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to GitHub OCI Registry
run: |
echo ${{ github.token }} | \
helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
- name: Install yq
run: apk add yq
- name: Download Dependencies
run: helm dependency build
- name: Package Chart
run: |
VERSION=${{ github.ref_name }}
helm package . \
--app-version ${VERSION#v} \
--version ${VERSION#v}
working-directory: ./chart
- name: Push Chart
run: |
VERSION=${{ github.ref_name }}
helm push switchboard-${VERSION#v}.tgz oci://ghcr.io/${{ github.actor }}/charts
working-directory: ./chart
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@

# Tests
cover.out

# Charts
Chart.lock
/chart/charts
*.tgz
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
KIND_CLUSTER_NAME ?= switchboard-tests
SED = sed -i '' -E

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
Expand All @@ -23,15 +24,26 @@ help: ## Display this help.
generate: controller-gen ## Generate code for custom resources
$(CONTROLLER_GEN) object paths="./..."

.PHONY: docs
docs: ## Generate helm docs in chart/README.md
cd $(CURDIR)/chart
helm-docs
$(SED) '/external-dns\.sources/d' README.md
$(SED) '/external-dns\.crd/d' README.md
$(SED) '/cert-manager\.installCRDs/d' README.md

.PHONY: lint
lint: ## Lint the code with golangci-lint.
golangci-lint run --exclude-use-default=false -E goimports -E revive --timeout 10m ./...

.PHONY: test
test: ## Run tests
test: ## Run unit tests
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \
go test ./... -coverprofile cover.out

e2e-tests: create-cluster ## Run end-to-end tests
cd $(CURDIR)/chart && bats tests -t

#--------------------------------------------------------------------------------------------------
##@ Build

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ helm install switchboard oci://ghcr.io/borchero/charts/switchboard
```

For a full installation guide, consult the
[Switchboard Helm chart documentation](https://github.com/borchero/switchboard-chart).
[Switchboard Helm chart documentation](./chart/README.md).

## Usage

Expand Down Expand Up @@ -83,8 +83,8 @@ Integrations are entirely independent of each other. Enabling an integration cau
generate an integration-specific resource (typically a CRD) for each ingress route that it
processes.

Consult the [Switchboard Helm chart documentation](https://github.com/borchero/switchboard-chart)
for an overview of how to enable individual integrations.
Consult the [Switchboard Helm chart documentation](./chart/README.md) for an overview of how to
enable individual integrations.

#### Cert-Manager

Expand Down
25 changes: 25 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v2
type: application
name: switchboard
version: 0.0.0
appVersion: 0.0.0
home: https://github.com/borchero/switchboard
sources:
- https://github.com/borchero/switchboard
keywords:
- dns
- tls
- external-dns
- cert-manager
- traefik
- dnsendpoint

dependencies:
- name: external-dns
version: 6.5.2
repository: https://charts.bitnami.com/bitnami
condition: external-dns.install
- name: cert-manager
version: 1.8.0
repository: https://charts.jetstack.io
condition: cert-manager.install
Loading

0 comments on commit 9cb1664

Please sign in to comment.