Skip to content

Commit 5a09cde

Browse files
authored
Use shared Task definitions (#5)
* remove hack/common * use common task definitions * tidy * adapt ci GHA to task * fix tests * adapt publish and release GHAs * add 'api/<version>' tag for nested module
1 parent a5f56e1 commit 5a09cde

37 files changed

+128
-1178
lines changed

.github/workflows/ci.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,26 @@ jobs:
1515
steps:
1616
- name: Checkout code
1717
uses: actions/checkout@v4
18+
with:
19+
submodules: recursive
1820

1921
- name: Set up Go
2022
uses: actions/setup-go@v5
2123
with:
2224
go-version-file: go.mod
2325

24-
- name: make tidy
26+
- name: Install Task
27+
uses: arduino/setup-task@v2
28+
with:
29+
version: 3.x
30+
31+
- name: task generate
2532
run: |
26-
make tidy
33+
task generate
2734
git diff --exit-code
2835
29-
- name: make verify
30-
run: make verify
36+
- name: task validate
37+
run: task validate
3138

32-
- name: make test
33-
run: make test
39+
- name: task test
40+
run: task test

.github/workflows/publish.yaml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ jobs:
2323
ssh-key: ${{ secrets.PUSH_KEY }}
2424
fetch-tags: true
2525
fetch-depth: 0
26+
submodules: recursive
27+
28+
- name: Install Task
29+
uses: arduino/setup-task@v2
30+
with:
31+
version: 3.x
2632

2733
- name: Read and validate VERSION
2834
id: version
2935
run: |
30-
VERSION=$(cat VERSION)
36+
VERSION=$(task version)
3137
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]]; then
3238
echo "Invalid version format in VERSION file: $VERSION"
3339
exit 1
@@ -68,24 +74,14 @@ jobs:
6874
with:
6975
go-version-file: go.mod
7076

71-
- name: Build the ${{ github.repository }}
77+
- name: Build and Push Images
7278
run: |
73-
make prepare-release
74-
make build
75-
76-
- name: Build Images
77-
run: |
78-
IMAGE_REGISTRY=ghcr.io/openmcp-project make image-build
79-
80-
- name: setup OCM
81-
uses: open-component-model/ocm-setup-action@main
79+
task build:img:all
8280
83-
- name: Create OCM CTF
81+
- name: Package and Push Helm Charts
8482
run: |
85-
ocm add componentversions --create \
86-
--file ctf component-constructor.yaml \
87-
--settings settings.yaml -- VERSION=${{ env.version }}
83+
task build:helm:all
8884
89-
- name: Push CTF
85+
- name: Build and Push OCM Component
9086
run: |
91-
ocm transfer ctf --overwrite ./ctf ${{ env.OCI_URL }}
87+
task build:ocm:all

.github/workflows/release.yaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ jobs:
1919
ssh-key: ${{ secrets.PUSH_KEY }}
2020
fetch-tags: true
2121
fetch-depth: 0
22+
submodules: recursive
23+
24+
- name: Install Task
25+
uses: arduino/setup-task@v2
26+
with:
27+
version: 3.x
2228

2329
- name: Read and validate VERSION
2430
id: version
2531
run: |
26-
VERSION=$(cat VERSION)
32+
VERSION=$(task version)
2733
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]]; then
2834
echo "Invalid version format in VERSION file: $VERSION"
2935
exit 1
@@ -64,6 +70,22 @@ jobs:
6470
git tag -a "${{ env.version }}" -m "Release ${{ env.version }}"
6571
git push origin "${{ env.version }}"
6672
73+
- name: Create Git tag for api submodule
74+
if: ${{ env.SKIP != 'true' }}
75+
run: |
76+
AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
77+
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
78+
echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>"
79+
80+
echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV
81+
echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV
82+
83+
git config user.name "$AUTHOR_NAME"
84+
git config user.email "$AUTHOR_EMAIL"
85+
86+
git tag -a "api/${{ env.version }}" -m "Release ${{ env.version }}"
87+
git push origin "api/${{ env.version }}"
88+
6789
- name: Create GitHub release
6890
if: ${{ env.SKIP != 'true' }}
6991
uses: softprops/action-gh-release@v2
@@ -79,7 +101,7 @@ jobs:
79101
- name: Push dev VERSION
80102
if: ${{ env.SKIP != 'true' }}
81103
run: |
82-
echo "${{ env.version }}-dev" > VERSION
104+
task release:set-version -- "${{ env.version }}-dev"
83105
git config user.name "${{ env.AUTHOR_NAME }}"
84106
git config user.email "${{ env.AUTHOR_EMAIL }}"
85107
git add VERSION

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ components/
3333
/**/cover.*.html
3434

3535
*.tmp
36+
.task/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "hack/common"]
2+
path = hack/common
3+
url = https://github.com/openmcp-project/build

Makefile

Lines changed: 0 additions & 165 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./hack/common/Makefile

Taskfile.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
version: 3
2+
3+
# vars: # cannot be specified here due to https://github.com/go-task/task/issues/2108
4+
# NESTED_MODULES: api
5+
# API_DIRS: '{{.ROOT_DIR}}/api/core/v1alpha1/...'
6+
# MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests'
7+
# CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/constants/... {{.ROOT_DIR}}/api/errors/... {{.ROOT_DIR}}/api/install/... {{.ROOT_DIR}}/api/v1alpha1/... {{.ROOT_DIR}}/api/core/v1alpha1/...'
8+
# COMPONENTS: 'mcp-operator'
9+
# REPO_URL: 'https://github.com/openmcp-project/mcp-operator'
10+
# GENERATE_DOCS_INDEX: "true"
11+
12+
includes:
13+
shared:
14+
taskfile: hack/common/Taskfile_controller.yaml
15+
flatten: true
16+
excludes: # put task names in here which are overwritten in this file
17+
- generate:code
18+
- validate:test
19+
vars:
20+
NESTED_MODULES: api
21+
API_DIRS: '{{.ROOT_DIR}}/api/core/v1alpha1/...'
22+
MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests'
23+
CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/constants/... {{.ROOT_DIR}}/api/errors/... {{.ROOT_DIR}}/api/install/... {{.ROOT_DIR}}/api/v1alpha1/... {{.ROOT_DIR}}/api/core/v1alpha1/...'
24+
COMPONENTS: 'mcp-operator'
25+
REPO_URL: 'https://github.com/openmcp-project/mcp-operator'
26+
GENERATE_DOCS_INDEX: "true"
27+
common: # imported a second time so that overwriting task definitions can call the overwritten task with a 'c:' prefix
28+
taskfile: hack/common/Taskfile_controller.yaml
29+
internal: true
30+
aliases:
31+
- c
32+
vars:
33+
NESTED_MODULES: api
34+
API_DIRS: '{{.ROOT_DIR}}/api/core/v1alpha1/...'
35+
MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests'
36+
CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/constants/... {{.ROOT_DIR}}/api/errors/... {{.ROOT_DIR}}/api/install/... {{.ROOT_DIR}}/api/v1alpha1/... {{.ROOT_DIR}}/api/core/v1alpha1/...'
37+
COMPONENTS: 'mcp-operator'
38+
REPO_URL: 'https://github.com/openmcp-project/mcp-operator'
39+
GENERATE_DOCS_INDEX: "true"
40+
41+
tasks:
42+
generate:code: # overwrites shared code task to add external API fetching
43+
desc: " Generate code (mainly DeepCopy functions) and fetches external APIs."
44+
aliases:
45+
- gen:code
46+
- g:code
47+
run: once
48+
cmds:
49+
- task: external-apis
50+
- task: c:generate:code
51+
52+
external-apis:
53+
desc: " Fetch external APIs."
54+
run: once
55+
method: checksum
56+
sources:
57+
- hack/external-apis/*
58+
cmds:
59+
- 'go run {{.ROOT_DIR}}/hack/external-apis/main.go'
60+
internal: true
61+
62+
validate:test: # overwrites the test task to add a dependency towards envtest
63+
desc: " Run all tests."
64+
aliases:
65+
- val:test
66+
- v:test
67+
run: once
68+
deps:
69+
- tools:envtest
70+
cmds:
71+
- task: c:validate:test

api/go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/openmcp-project/mcp-operator/api
22

3-
go 1.23.0
4-
5-
toolchain go1.23.6
3+
go 1.23.5
64

75
require (
86
github.com/onsi/ginkgo/v2 v2.22.2

0 commit comments

Comments
 (0)