Skip to content
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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ includes:

Adding new specialized tasks in addition to the imported generic ones is straightforward: simply add the task definitions in the importing Taskfile.

It is also possible to exclude or overwrite generic tasks. The following example uses an `external-apis` task that should be executed as part of the generic `generate:code` task.
It is also possible to exclude or overwrite generic tasks. The following example uses an `external-apis` task that should be executed as part of the generic `generate:code` task, and it adds a envtest dependency to the `validate:test` task.

Overwriting basically works by excluding and re-defining the generic task that should be overwritten. If the generic task's logic should be kept as part of the overwritten definition, the generic file needs to be imported a second time with `internal: true`, so that the original task can be called.

Expand All @@ -128,14 +128,30 @@ includes:
tasks:
generate:code: # overwrites shared code task to add external API fetching
desc: " Generate code (mainly DeepCopy functions) and fetches external APIs."
aliases:
- gen:code
- g:code
run: once
cmds:
- task: external-apis
- task: c:generate:code

external-apis:
desc: " Fetch external APIs."
run: once
<...>
internal: true

validate:test: # overwrites the test task to add a dependency towards envtest
desc: " Run all tests."
aliases:
- val:test
- v:test
run: once
deps:
- tools:envtest
cmds:
- task: c:validate:test
```

### Makefile
Expand Down
8 changes: 5 additions & 3 deletions Taskfile_library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ vars:
YAML2JSON_VERSION: '{{ .YAML2JSON_VERSION | default "v1.3.5" }}'
OCM: '{{ .OCM | default (print .LOCALBIN "/ocm") }}'
OCM_VERSION: '{{ .OCM_VERSION | default "v0.21.0" }}'
ENVTEST: '{{ .ENVTEST | default (print .LOCALTMP "/setup-envtest") }}'
ENVTEST_VERSION: '{{ .ENVTEST_VERSION | default "release-0.16" }}'

DOCKER_BUILDER_NAME: # move to build taskfile later
sh: 'echo -n ${DOCKER_BUILDER_NAME:-"openmcp-multiarch-builder"}'
Expand Down Expand Up @@ -98,13 +100,13 @@ tasks:
desc: " Combines all code generation tasks, including formatting."
run: once
deps:
- gen:generate
- generate:generate

test:
desc: " Run all tests."
run: once
deps:
- val:test
- validate:test

validate:
desc: " Combines all validation tasks except for tests."
Expand All @@ -113,7 +115,7 @@ tasks:
- verify
- check
deps:
- val:validate
- validate:validate

version:
desc: " Print the version of the project. Use VERSION_OVERRIDE to make this task print a specific version."
Expand Down
17 changes: 17 additions & 0 deletions tasks_tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,20 @@ tasks:
- 'curl -sSfL https://ocm.software/install.sh | OCM_VERSION="{{.OCM_VERSION | trimPrefix "v"}}" bash -s "{{.tmpdir}}"'
- 'mv "{{.tmpdir}}/ocm" "{{.OCM}}"'
internal: true

envtest:
desc: " Ensure that envtest is installed."
run: once
requires:
vars:
- ENVTEST
- ENVTEST_VERSION
deps:
- localbin
status:
- 'test -x "{{.ENVTEST}}"'
- test -f {{.LOCALBIN}}/envtest_version
- 'cat {{.LOCALBIN}}/envtest_version | grep -q "{{.ENVTEST_VERSION}}"'
cmds:
- 'GOBIN="{{.LOCALBIN}}" go install sigs.k8s.io/controller-runtime/tools/setup-envtest@{{.ENVTEST_VERSION}}'
internal: true