Skip to content
Open
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
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ insert_final_newline = false

[Makefile]
indent_style = tab

; Ignore golden test outputs
[tests/golden/**]
indent_size = unset
indent_style = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
24 changes: 24 additions & 0 deletions .github/workflows/auto-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Autorelease
on:
pull_request:
types:
- synchronize
- labeled
- unlabeled
- closed

permissions:
contents: write
issues: write
pull-requests: write
actions: write

jobs:
create-release-tag:
runs-on: ubuntu-latest
steps:
- name: Create new tag
uses: projectsyn/pr-label-tag-action@v1
with:
trigger: |
Release
5 changes: 3 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ on:
push:
tags:
- v*
workflow_dispatch:
Comment thread
vshntea marked this conversation as resolved.
Resolved

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
with:
fetch-depth: "0"
- name: Build changelog from PRs with labels
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v1
uses: mikepenz/release-changelog-builder-action@v5
with:
configuration: ".github/changelog-configuration.json"
# PreReleases still get a changelog, but the next full release gets a diff since the last full release,
Expand Down
45 changes: 40 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Pull Request
on:
push:
pull_request:
branches:
- master
workflow_dispatch:

env:
COMPONENT_NAME: helm-chart

jobs:
linting:
Expand All @@ -12,15 +15,47 @@ jobs:
command:
- lint_jsonnet
- lint_yaml
- docs-vale
- lint_adoc
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
- name: Run ${{ matrix.command }}
run: make ${{ matrix.command }}
editorconfig:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
- uses: snow-actions/eclint@v1.0.1
with:
args: 'check'
test:
runs-on: ubuntu-latest
strategy:
matrix:
instance:
- defaults
- with_values
defaults:
run:
working-directory: ${{ env.COMPONENT_NAME }}
steps:
- uses: actions/checkout@v5
with:
path: ${{ env.COMPONENT_NAME }}
- name: Compile component
run: make test -e instance=${{ matrix.instance }}
golden:
runs-on: ubuntu-latest
strategy:
matrix:
instance:
- defaults
- with_values
defaults:
run:
working-directory: ${{ env.COMPONENT_NAME }}
steps:
- uses: actions/checkout@v5
with:
path: ${{ env.COMPONENT_NAME }}
- name: Golden diff
run: make golden-diff -e instance=${{ matrix.instance }}
24 changes: 16 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
_archive/
_public/
.cache/
helmcharts/
manifests/
vendor/
jsonnetfile.lock.json
build
# Commodore
/.cache
/dependencies
helmcharts
/manifests
/vendor
/jsonnetfile.lock.json
/crds
/compiled

# Antora
/_archive
/_public

# Additional entries
/.idea/
7 changes: 0 additions & 7 deletions .sync.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,20 @@ rules:
line-length:
max: 80
level: warning

# Forbid octal literals until we've fully migrated to reclass-rs
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true

# Restrict truthy values to set which is parsed as boolean by reclass-rs
truthy:
allowed-values: ['true', 'false', 'True', 'False', 'TRUE', 'FALSE']
check-keys: true

ignore: |
dependencies/
helmcharts/
manifests/
vendor/
compiled/
87 changes: 59 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,81 @@ SHELL := bash
.DELETE_ON_ERROR:
.SUFFIXES:

DOCKER_CMD ?= docker
DOCKER_ARGS ?= run --rm --user "$$(id -u)" -v "$${PWD}:/component" --workdir /component
include Makefile.vars.mk
include Makefile.custom.mk

JSONNET_FILES ?= $(shell find . -type f -not -path './vendor/*' \( -name '*.*jsonnet' -or -name '*.libsonnet' \))
JSONNETFMT_ARGS ?= --in-place --pad-arrays
JSONNET_IMAGE ?= docker.io/bitnami/jsonnet:latest
JSONNET_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) --entrypoint=jsonnetfmt $(JSONNET_IMAGE)

YAML_FILES ?= $(shell find . -type f -not -path './vendor/*' \( -name '*.yaml' -or -name '*.yml' \))
YAMLLINT_ARGS ?= --no-warnings
YAMLLINT_CONFIG ?= .yamllint.yml
YAMLLINT_IMAGE ?= docker.io/cytopia/yamllint:latest
YAMLLINT_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(YAMLLINT_IMAGE)

VALE_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) --volume "$${PWD}"/docs/modules:/pages vshn/vale:2.1.1
VALE_ARGS ?= --minAlertLevel=error --config=/pages/ROOT/pages/.vale.ini /pages

ANTORA_PREVIEW_CMD ?= $(DOCKER_CMD) run --rm --publish 2020:2020 --volume "${PWD}":/antora vshn/antora-preview:2.3.3 --style=syn --antora=docs
.PHONY: help
help: ## Show this help
@grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "(: ).*?## "}; {gsub(/\\:/,":", $$1)}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

.PHONY: all
all: lint open
all: lint

.PHONY: lint
lint: lint_jsonnet lint_yaml docs-vale
lint: lint_jsonnet lint_yaml lint_adoc lint_kubent ## All-in-one linting

.PHONY: lint_jsonnet
lint_jsonnet: $(JSONNET_FILES)
lint_jsonnet: $(JSONNET_FILES) ## Lint jsonnet files
$(JSONNET_DOCKER) $(JSONNETFMT_ARGS) --test -- $?

.PHONY: lint_yaml
lint_yaml: $(YAML_FILES)
$(YAMLLINT_DOCKER) -f parsable -c $(YAMLLINT_CONFIG) $(YAMLLINT_ARGS) -- $?
lint_yaml: ## Lint yaml files
$(YAMLLINT_DOCKER) -f parsable -c $(YAMLLINT_CONFIG) $(YAMLLINT_ARGS) -- .

.PHONY: lint_adoc
lint_adoc: ## Lint documentation
$(VALE_CMD) $(VALE_ARGS)
.PHONY: lint_kubent
lint_kubent: ## Check for deprecated Kubernetes API versions
$(KUBENT_DOCKER) $(KUBENT_ARGS) -f $(KUBENT_FILES)

.PHONY: format
format: format_jsonnet
format: format_jsonnet ## All-in-one formatting

.PHONY: format_jsonnet
format_jsonnet: $(JSONNET_FILES)
format_jsonnet: $(JSONNET_FILES) ## Format jsonnet files
$(JSONNET_DOCKER) $(JSONNETFMT_ARGS) -- $?

.PHONY: docs-serve
docs-serve:
docs-serve: ## Preview the documentation
$(ANTORA_PREVIEW_CMD)

.PHONY: docs-vale
docs-vale:
$(VALE_CMD) $(VALE_ARGS)
.PHONY: compile
.compile:
mkdir -p dependencies
$(COMPILE_CMD)

.PHONY: test
test: commodore_args += -f tests/$(instance).yml
test: .compile ## Compile the component
.PHONY: gen-golden
gen-golden: commodore_args += -f tests/$(instance).yml
gen-golden: clean .compile ## Update the reference version for target `golden-diff`.
@rm -rf tests/golden/$(instance)
@mkdir -p tests/golden/$(instance)
@cp -R compiled/. tests/golden/$(instance)/.

.PHONY: golden-diff
golden-diff: commodore_args += -f tests/$(instance).yml
golden-diff: clean .compile ## Diff compile output against the reference version. Review output and run `make gen-golden golden-diff` if this target fails.
@git diff --exit-code --minimal --no-index -- tests/golden/$(instance) compiled/

.PHONY: golden-diff-all
golden-diff-all: recursive_target=golden-diff
golden-diff-all: $(test_instances) ## Run golden-diff for all instances. Note: this doesn't work when running make with multiple parallel jobs (-j != 1).

.PHONY: gen-golden-all
gen-golden-all: recursive_target=gen-golden
gen-golden-all: $(test_instances) ## Run gen-golden for all instances. Note: this doesn't work when running make with multiple parallel jobs (-j != 1).

.PHONY: lint_kubent_all
lint_kubent_all: recursive_target=lint_kubent
lint_kubent_all: $(test_instances) ## Lint deprecated Kubernetes API versions for all golden test instances. Will exit on first error. Note: this doesn't work when running make with multiple parallel jobs (-j != 1).

.PHONY: $(test_instances)
$(test_instances):
$(MAKE) $(recursive_target) -e instance=$(basename $(@F))

.PHONY: clean
clean: ## Clean the project
rm -rf .cache compiled dependencies vendor helmcharts jsonnetfile*.json || true
2 changes: 2 additions & 0 deletions Makefile.custom.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Configure instance alias for commodore component compile
commodore_args += --alias $(instance)
53 changes: 53 additions & 0 deletions Makefile.vars.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# The component name is hard-coded from the template
COMPONENT_NAME ?= helm-chart

git_dir ?= $(shell git rev-parse --git-common-dir)
compiled_path ?= compiled/$(COMPONENT_NAME)/$(COMPONENT_NAME)
root_volume ?= -v "$${PWD}:/$(COMPONENT_NAME)"
compiled_volume ?= -v "$${PWD}/$(compiled_path):/$(COMPONENT_NAME)"
commodore_args ?= --search-paths . -n $(COMPONENT_NAME)

ifneq "$(git_dir)" ".git"
git_volume ?= -v "$(git_dir):$(git_dir):ro"
antora_git_volume ?= -v "$(git_dir):/preview/antora/.git:ro"
else
git_volume ?=
antora_git_volume ?= -v "${PWD}/.git:/preview/antora/.git:ro"
endif

ifneq "$(shell which docker 2>/dev/null)" ""
DOCKER_CMD ?= $(shell which docker)
DOCKER_USERNS ?= ""
else
DOCKER_CMD ?= podman
DOCKER_USERNS ?= keep-id
endif
DOCKER_ARGS ?= run --rm -u "$$(id -u):$$(id -g)" --userns=$(DOCKER_USERNS) -w /$(COMPONENT_NAME) -e HOME="/$(COMPONENT_NAME)"

JSONNET_FILES ?= $(shell find . -type f -not -path './vendor/*' \( -name '*.*jsonnet' -or -name '*.libsonnet' \))
JSONNETFMT_ARGS ?= --in-place --pad-arrays
JSONNET_IMAGE ?= ghcr.io/projectsyn/jsonnet:latest
JSONNET_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(root_volume) --entrypoint=jsonnetfmt $(JSONNET_IMAGE)

YAMLLINT_ARGS ?= --no-warnings
YAMLLINT_CONFIG ?= .yamllint.yml
YAMLLINT_IMAGE ?= docker.io/cytopia/yamllint:latest
YAMLLINT_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(root_volume) $(YAMLLINT_IMAGE)

VALE_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(root_volume) --volume "$${PWD}"/docs/modules:/pages ghcr.io/vshn/vale:2.15.5
VALE_ARGS ?= --minAlertLevel=error --config=/pages/ROOT/pages/.vale.ini /pages

ANTORA_PREVIEW_CMD ?= $(DOCKER_CMD) run --rm --publish 35729:35729 --publish 2020:2020 $(antora_git_volume) --volume "${PWD}/docs":/preview/antora/docs ghcr.io/vshn/antora-preview:3.1.2.3 --style=syn --antora=docs

COMMODORE_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(git_volume) $(root_volume) docker.io/projectsyn/commodore:latest
COMPILE_CMD ?= $(COMMODORE_CMD) component compile . $(commodore_args)
JB_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) --entrypoint /usr/local/bin/jb docker.io/projectsyn/commodore:latest install
GOLDEN_FILES ?= $(shell find tests/golden/$(instance) -type f)

KUBENT_FILES ?= $(shell echo "$(GOLDEN_FILES)" | sed 's/ /,/g')
KUBENT_ARGS ?= -c=false --helm3=false -e
KUBENT_IMAGE ?= ghcr.io/doitintl/kube-no-trouble:latest
KUBENT_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(root_volume) --entrypoint=/app/kubent $(KUBENT_IMAGE)

instance ?= defaults
test_instances = tests/defaults.yml tests/with_values.yml
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
# Commodore Component: helm-chart

This is a [Commodore][commodore] Component for helm charts.
This is a [Commodore][commodore] Component for helm-chart.

This repository is part of Project Syn.
For documentation on Project Syn and this component, see https://syn.tools.
This can be used to deploy a helm chart to the cluster.
The component is multi-tenant, multi-instance and multi-version aware: each
instance gets its own namespace and can pin its own chart version.

By default the component installs the OCI chart `test-helm-chart` from
`oci://ghcr.io/appuio/test-helm-chart/test-helm-chart`.

## Documentation

Documentation for this component is written using [Asciidoc][asciidoc] and [Antora][antora].
It is located in the [docs/](docs) folder.
The [Divio documentation structure](https://documentation.divio.com/) is used to organize its content.
It can be found in the [`docs`](docs) folder.
We use the [Divio documentation structure](https://documentation.divio.com/) to organize our documentation.

Run the `make docs-serve` command in the root of the project, and then browse to http://localhost:2020 to see a preview of the current state of the documentation.

After writing the documentation, please use the `make docs-vale` command and correct any warnings raised by the tool.

## Testing

The component is tested with two instances, `defaults` and `with_values`:

- `make test -e instance=defaults`
- `make test -e instance=with_values`

Run `make gen-golden-all` to regenerate the golden test outputs.

## Contributing and license

This library is licensed under [BSD-3-Clause](LICENSE).
For information about how to contribute see [CONTRIBUTING](CONTRIBUTING.md).
For information about how to contribute, see [CONTRIBUTING](CONTRIBUTING.md).

[commodore]: https://docs.syn.tools/commodore/index.html
[commodore]: https://syn.tools/commodore/
[asciidoc]: https://asciidoctor.org/
[antora]: https://antora.org/
Loading
Loading