Skip to content

Commit

Permalink
Merge pull request #238 from vshn/package_appcat
Browse files Browse the repository at this point in the history
Refactor component and add appcat package
  • Loading branch information
TheBigLee authored Oct 9, 2023
2 parents 786d434 + 1b127da commit 23dbe0e
Show file tree
Hide file tree
Showing 331 changed files with 588 additions and 1,398 deletions.
12 changes: 10 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ insert_final_newline = false
[Makefile]
indent_style = tab

# Don't check for trailing newlines in golden tests output
[**/tests/golden/**]
; Ignore golden test outputs
[/component/tests/golden/**]
indent_size = unset
indent_style = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
[/package/tests/golden/**]
indent_size = unset
indent_style = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
65 changes: 65 additions & 0 deletions .github/workflows/component-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Pull Request (component)
on:
pull_request:
branches:
- master

env:
COMPONENT_NAME: appcat

jobs:
linting:
runs-on: ubuntu-latest
strategy:
matrix:
command:
- lint_jsonnet
- lint_yaml
steps:
- uses: actions/checkout@v4
- name: Run ${{ matrix.command }}
run: make -C component ${{ matrix.command }}
test:
runs-on: ubuntu-latest
strategy:
matrix:
instance:
- defaults
- exoscale
- cloudscale
- openshift
- vshn
- apiserver
- controllers
- minio
defaults:
run:
working-directory: ${{ env.COMPONENT_NAME }}
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.COMPONENT_NAME }}
- name: Compile component
run: make -C component test -e instance=${{ matrix.instance }}
golden:
runs-on: ubuntu-latest
strategy:
matrix:
instance:
- defaults
- exoscale
- cloudscale
- openshift
- vshn
- apiserver
- controllers
- minio
defaults:
run:
working-directory: ${{ env.COMPONENT_NAME }}
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.COMPONENT_NAME }}
- name: Golden diff
run: make -C component golden-diff -e instance=${{ matrix.instance }}
21 changes: 21 additions & 0 deletions .github/workflows/package-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pull Request (package)
on:
pull_request:
branches:
- master

env:
PACKAGE_NAME: appcat

jobs:
linting:
runs-on: ubuntu-latest
strategy:
matrix:
command:
- lint_yaml
- lint_commodore
steps:
- uses: actions/checkout@v4
- name: Run ${{ matrix.command }}
run: make -C package ${{ matrix.command }}
16 changes: 16 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@ jobs:
# Ensure target branch for release is "master"
commit: master
token: ${{ secrets.GITHUB_TOKEN }}
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: 'master'
- name: set tag env
run: echo "TAG_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Change version in package
run: |
yq -i '.parameters."pkg.appcat".componentVersion = "${{ env.TAG_VERSION }} "' package/main.yaml
- uses: actions-js/push@v1.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: "Update component version in package to ${{ env.TAG_VERSION }}}"
branch: 'master'
64 changes: 6 additions & 58 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,73 +1,21 @@
name: Pull Request
name: Pull Request (global lints)

on:
pull_request:
branches:
- master

env:
COMPONENT_NAME: appcat

jobs:
linting:
runs-on: ubuntu-latest
strategy:
matrix:
command:
- lint_jsonnet
- lint_yaml
- lint_adoc
steps:
- uses: actions/checkout@v4
- name: Run ${{ matrix.command }}
run: make ${{ matrix.command }}
- name: Run Asciidoc linter
run: make lint_adoc

editorconfig:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: snow-actions/eclint@v1.0.1
with:
args: 'check'
test:
runs-on: ubuntu-latest
strategy:
matrix:
instance:
- defaults
- exoscale
- cloudscale
- openshift
- vshn
- apiserver
- controllers
- minio
defaults:
run:
working-directory: ${{ env.COMPONENT_NAME }}
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.COMPONENT_NAME }}
- name: Compile component
run: make test -e instance=${{ matrix.instance }}
golden:
runs-on: ubuntu-latest
strategy:
matrix:
instance:
- defaults
- exoscale
- cloudscale
- openshift
- vshn
- apiserver
- controllers
- minio
defaults:
run:
working-directory: ${{ env.COMPONENT_NAME }}
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.COMPONENT_NAME }}
- name: Golden diff
run: make golden-diff -e instance=${{ matrix.instance }}
args: "check"
29 changes: 21 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@
.kind
.idea

# jsonnet builder
component/jsonnetfile.json

compiled/
vendor/
dependencies/
hack/

# sloth artifacts
sloth-*-*-*
sloth-input/
sloth-output/

# Commodore
/component/.cache
/component/dependencies
/component/helmcharts
/component/manifests
/component/vendor
/component/jsonnetfile.lock.json
/component/crds
/component/compiled

/package/.cache
/package/dependencies
/package/helmcharts
/package/manifests
/package/vendor
/package/jsonnetfile.lock.json
/package/crds
/package/compiled

# Additional entries
73 changes: 3 additions & 70 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,84 +7,17 @@ SHELL := bash

include Makefile.vars.mk

.PHONY: all
all: help

.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

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

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

.PHONY: lint_yaml
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: ## Lint deprecated Kubernetes API versions
$(KUBENT_DOCKER) $(KUBENT_ARGS) -f $(KUBENT_FILES)

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

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

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

.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: generate-exoscale-plans
generate-exoscale-plans: ## Generate current plans for Exoscale
cd dev/scripts/exoscale-plans/ && \
go run main.go

.PHONY: clean
clean: ## Clean the project
rm -rf .cache compiled dependencies vendor helmcharts jsonnetfile*.json || true
31 changes: 3 additions & 28 deletions Makefile.vars.mk
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
# Commodore takes the root dir name as the component name
COMPONENT_NAME ?= appcat

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 ./dependencies --search-paths . -n $(COMPONENT_NAME)
git_dir ?= $(shell git rev-parse --git-common-dir)
root_volume ?= -v "$${PWD}:/$(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

Expand All @@ -24,26 +18,7 @@ else
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 ?= docker.io/bitnami/jsonnet:latest
JSONNET_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(root_volume) --entrypoint=jsonnetfmt $(JSONNET_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.4 --style=syn --antora=docs

COMMODORE_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(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/exoscale.yml tests/cloudscale.yml tests/openshift.yml tests/vshn.yml tests/apiserver.yml tests/controllers.yml tests/minio.yml
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
File renamed without changes.
Loading

0 comments on commit 23dbe0e

Please sign in to comment.