Skip to content

Commit 49e3275

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

Some content is hidden

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

66 files changed

+5174
-1278
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Check Codegen
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '**/*.md'
8+
9+
jobs:
10+
check-codegen:
11+
name: Run on Ubuntu
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v5
15+
16+
- uses: actions/setup-go@v5
17+
with:
18+
go-version-file: 'go.mod'
19+
20+
- name: Run make generate
21+
run: make generate
22+
23+
- name: Run make docs
24+
run: make docs
25+
26+
- name: Run make helm
27+
run: make helm
28+
29+
- name: Run fmt
30+
run: make fmt
31+
32+
- name: Compare the expected and actual generated/* directories
33+
run: |
34+
if [ "$(git diff | wc -l)" -gt "0" ]; then
35+
echo "Detected uncommitted changes after build. Consider running 'make generate && make docs && make helm'."
36+
echo "See status below:"
37+
git diff
38+
exit 1
39+
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: 1 addition & 9 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:
@@ -16,7 +8,7 @@ permissions:
168
packages: write
179
jobs:
1810
release:
19-
name: goreleaser
11+
name: Run on Ubuntu
2012
runs-on: ubuntu-latest
2113
steps:
2214
- name: Check out code
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
name: Run on Ubuntu
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v5
17+
18+
- name: Install Kustomize
19+
run: |
20+
make kustomize
21+
mv ./bin/kustomize /usr/local/bin
22+
23+
- run: |
24+
./hack/validate-kustomize.sh

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
run: |
24+
make golangci-lint
25+
cp ./bin/golangci-lint /usr/local/bin/
26+
go list -f '{{.Dir}}' ./... | grep -v nxos/ | xargs golangci-lint run
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
name: Run on Ubuntu
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
packages: write
30+
31+
if: |
32+
github.event_name == 'push' ||
33+
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-charts')) ||
34+
(github.event_name == 'release' && github.event.action == 'published')
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v5
38+
39+
- name: Set up Helm
40+
uses: azure/setup-helm@v4
41+
with:
42+
version: v3.17.0
43+
44+
- name: Determine chart version
45+
id: chart_version
46+
run: |
47+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
48+
# Use SHA for main branch
49+
CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)"
50+
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
51+
# Use tag version (strip 'v' prefix)
52+
CHART_VERSION="${GITHUB_REF#refs/tags/v}"
53+
else
54+
# Use PR SHA for dry run
55+
CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)"
56+
fi
57+
echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT
58+
59+
- name: Install Kustomize
60+
run: |
61+
make kustomize
62+
mv ./bin/kustomize /usr/local/bin
63+
64+
- name: Package Helm chart with crds folder in template
65+
run: |
66+
helm package dist/chart --version ${{ steps.chart_version.outputs.version }}-crds
67+
68+
- name: Prepare CRDs folder
69+
run: |
70+
mkdir -p dist/chart/crds
71+
kustomize build config/default | yq ea 'select(.kind == "CustomResourceDefinition")' > dist/chart/crds/crds.yaml
72+
rm -rf dist/chart/templates/crd
73+
74+
- name: Package Helm chart with removed crds folder from template folder
75+
run: |
76+
helm package dist/chart --version ${{ steps.chart_version.outputs.version }}
77+
78+
- name: Log in to GitHub Container Registry
79+
run: |
80+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
81+
82+
- name: Push Helm chart to GHCR
83+
run: |
84+
helm push network-operator-${{ steps.chart_version.outputs.version }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
85+
helm push network-operator-${{ steps.chart_version.outputs.version }}-crds.tgz oci://ghcr.io/${{ github.repository_owner }}/charts

0 commit comments

Comments
 (0)