Skip to content

Commit

Permalink
Refactor component and add appcat package
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Bigler <nicolas.bigler@vshn.ch>
  • Loading branch information
TheBigLee committed Oct 4, 2023
1 parent 786d434 commit 33fc133
Show file tree
Hide file tree
Showing 377 changed files with 2,450 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 }}
51 changes: 51 additions & 0 deletions .github/workflows/package-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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 }}
test:
runs-on: ubuntu-latest
strategy:
matrix:
instance:
- defaults
defaults:
run:
working-directory: ${{ env.PACKAGE_NAME }}
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.PACKAGE_NAME }}
- name: Compile component
run: make -C package test -e instance=${{ matrix.instance }}
golden:
runs-on: ubuntu-latest
strategy:
matrix:
instance:
- defaults
defaults:
run:
working-directory: ${{ env.PACKAGE_NAME }}
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.PACKAGE_NAME }}
- name: Golden diff
run: make -C package golden-diff -e instance=${{ matrix.instance }}
11 changes: 11 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ 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
- name: Change version in package
run: |
sed -i "s/componentVersion: .*/componentVersion: ${{ github.ref }}/g" package/main.yaml
- uses: EndBug/add-and-commit@v7
with:
default_author: user_info
message: "Update component version in package to ${{ github.ref }}"
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
Loading

0 comments on commit 33fc133

Please sign in to comment.