Skip to content

Commit bac45ed

Browse files
committed
Refactor Makefile, GH workflows and other project housekeeping tasks
1 parent 76cc0c8 commit bac45ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4944
-1043
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Check Codegen
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '**/*.md'
8+
9+
jobs:
10+
check-codegen:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v5
14+
- uses: actions/setup-go@v5
15+
with:
16+
go-version-file: 'go.mod'
17+
- name: Run make generate
18+
run: make generate
19+
- name: Run make docs
20+
run: make docs
21+
- name: Run make helm
22+
run: make helm
23+
- name: Run fmt
24+
run: make fmt
25+
- name: Compare the expected and actual generated/* directories
26+
run: |
27+
if [ "$(git diff | wc -l)" -gt "0" ]; then
28+
echo "Detected uncommitted changes after build. Consider running 'make generate && make docs && make helm'."
29+
echo "See status below:"
30+
git diff
31+
exit 1
32+
fi

.github/workflows/checks.yaml

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

.github/workflows/ci.yaml

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

.github/workflows/goreleaser.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
################################################################################
2-
# This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> #
3-
# Edit Makefile.maker.yaml instead. #
4-
################################################################################
5-
6-
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company
7-
# SPDX-License-Identifier: Apache-2.0
8-
91
name: goreleaser
102
"on":
113
push:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Kustomize Validation
2+
3+
on:
4+
pull_request:
5+
types: [ assigned, opened, synchronize, reopened ]
6+
paths-ignore:
7+
- 'docs/**'
8+
- '**/*.md'
9+
10+
jobs:
11+
kustomize-validation:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v5
16+
- uses: imranismail/setup-kustomize@v2
17+
with:
18+
kustomize-version: '5.0.0'
19+
- run: |
20+
./hack/validate-kustomize.sh

.github/workflows/lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '**/*.md'
8+
9+
jobs:
10+
lint:
11+
name: Run on Ubuntu
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Clone the code
15+
uses: actions/checkout@v5
16+
17+
- name: Setup Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version-file: go.mod
21+
22+
- name: Run linter
23+
uses: golangci/golangci-lint-action@v8
24+
with:
25+
version: v2.1
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Release Helm Chart
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- 'v*.*.*'
12+
paths-ignore:
13+
- 'docs/**'
14+
- '**/*.md'
15+
pull_request:
16+
branches:
17+
- main
18+
paths-ignore:
19+
- 'docs/**'
20+
- '**/*.md'
21+
types: [labeled, opened, synchronize, reopened]
22+
23+
jobs:
24+
helm-chart:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: write
29+
30+
if: |
31+
github.event_name == 'push' ||
32+
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-charts')) ||
33+
(github.event_name == 'release' && github.event.action == 'published')
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v5
37+
38+
- name: Set up Helm
39+
uses: azure/setup-helm@v4
40+
with:
41+
version: v3.16.2
42+
43+
- name: Determine chart version
44+
id: chart_version
45+
run: |
46+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
47+
# Use SHA for main branch
48+
CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)"
49+
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
50+
# Use tag version (strip 'v' prefix)
51+
CHART_VERSION="${GITHUB_REF#refs/tags/v}"
52+
else
53+
# Use PR SHA for dry run
54+
CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)"
55+
fi
56+
echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT
57+
58+
- name: Install Kustomize
59+
run: |
60+
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
61+
mv kustomize /usr/local/bin
62+
63+
- name: Package Helm chart with crds folder in template
64+
run: |
65+
helm package dist/chart --version ${{ steps.chart_version.outputs.version }}-crds
66+
67+
- name: Prepare CRDs folder
68+
run: |
69+
mkdir -p dist/chart/crds
70+
kustomize build config/default | yq ea 'select(.kind == "CustomResourceDefinition")' > dist/chart/crds/crds.yaml
71+
rm -rf dist/chart/templates/crd
72+
73+
- name: Package Helm chart with removed crds folder from template folder
74+
run: |
75+
helm package dist/chart --version ${{ steps.chart_version.outputs.version }}
76+
77+
- name: Log in to GitHub Container Registry
78+
run: |
79+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
80+
81+
- name: Push Helm chart to GHCR
82+
run: |
83+
helm push network-operator-${{ steps.chart_version.outputs.version }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
84+
helm push network-operator-${{ steps.chart_version.outputs.version }}-crds.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- v*
12+
paths-ignore:
13+
- 'docs/**'
14+
- '**/*.md'
15+
pull_request:
16+
paths-ignore:
17+
- 'docs/**'
18+
- '**/*.md'
19+
types: [labeled, unlabeled, opened, synchronize, reopened]
20+
21+
jobs:
22+
buildAndPush:
23+
strategy:
24+
matrix:
25+
image:
26+
- name: network-operator-controller-manager
27+
target: manager
28+
permissions:
29+
contents: read
30+
packages: write
31+
# Condition: Run on push to main, published release, OR PR with 'ok-to-image' label
32+
if: |
33+
github.event_name == 'push' ||
34+
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-image')) ||
35+
(github.event_name == 'release' && github.event.action == 'published')
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v5
39+
- uses: docker/metadata-action@v5
40+
id: meta
41+
with:
42+
images: |
43+
ghcr.io/${{ github.repository_owner }}/${{ matrix.image.name }}
44+
tags: |
45+
type=semver,pattern={{version}}
46+
type=schedule
47+
type=ref,event=branch
48+
type=ref,event=tag
49+
type=ref,event=pr
50+
type=sha
51+
flavor: |
52+
latest=${{ github.ref == 'refs/heads/main' }}
53+
- name: Set up QEMU
54+
uses: docker/setup-qemu-action@v3
55+
with:
56+
platforms: all
57+
# workaround for self-hosted runner
58+
# https://github.com/mumoshu/actions-runner-controller-ci/commit/e91c8c0f6ca82aa7618010c6d2f417aa46c4a4bf
59+
- name: Set up Docker Context for Buildx
60+
id: buildx-context
61+
run: |
62+
docker context create builders
63+
- name: Set up Docker Buildx
64+
timeout-minutes: 5
65+
uses: docker/setup-buildx-action@v3
66+
with:
67+
version: latest
68+
endpoint: builders # self-hosted
69+
- name: Login to GHCR
70+
if: github.event_name != 'pull_request'
71+
uses: docker/login-action@v3
72+
with:
73+
registry: ghcr.io
74+
username: ${{ github.actor }}
75+
password: ${{ secrets.GITHUB_TOKEN }}
76+
- name: Build and push
77+
timeout-minutes: 40
78+
uses: docker/build-push-action@v6
79+
with:
80+
context: .
81+
platforms: linux/amd64,linux/arm64
82+
push: ${{ github.event_name != 'pull_request' }}
83+
tags: ${{ steps.meta.outputs.tags }}
84+
labels: ${{ steps.meta.outputs.labels }}
85+
target: ${{ matrix.image.target }}

.github/workflows/reuse.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
2-
# SPDX-License-Identifier: Apache-2.0
3-
41
name: REUSE Compliance
52
on:
63
push:

0 commit comments

Comments
 (0)