-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor Makefile, GH workflows and other project housekeeping tasks #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
afritzler
wants to merge
5
commits into
main
Choose a base branch
from
enh/makefile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Check Codegen | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - 'docs/**' | ||
| - '**/*.md' | ||
|
|
||
| jobs: | ||
| check-codegen: | ||
| name: Run on Ubuntu | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
|
|
||
| - name: Run make generate | ||
| run: make generate | ||
|
|
||
| - name: Run make docs | ||
| run: make docs | ||
|
|
||
| - name: Run make helm | ||
| run: make helm | ||
|
|
||
| - name: Run fmt | ||
| run: make fmt | ||
|
|
||
| - name: Compare the expected and actual generated/* directories | ||
| run: | | ||
| if [ "$(git diff | wc -l)" -gt "0" ]; then | ||
| echo "Detected uncommitted changes after build. Consider running 'make generate && make docs && make helm'." | ||
| echo "See status below:" | ||
| git diff | ||
| exit 1 | ||
| fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Kustomize Validation | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [ assigned, opened, synchronize, reopened ] | ||
| paths-ignore: | ||
| - 'docs/**' | ||
| - '**/*.md' | ||
|
|
||
| jobs: | ||
| kustomize-validation: | ||
| name: Run on Ubuntu | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Install Kustomize | ||
| run: | | ||
| make kustomize | ||
| mv ./bin/kustomize /usr/local/bin | ||
|
|
||
| - run: | | ||
| ./hack/validate-kustomize.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: Lint | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths-ignore: | ||
| - 'docs/**' | ||
| - '**/*.md' | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Run on Ubuntu | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Clone the code | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Run linter | ||
| run: | | ||
| make golangci-lint | ||
| cp ./bin/golangci-lint /usr/local/bin/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we otherwise use |
||
| go list -f '{{.Dir}}' ./... | grep -v nxos/ | xargs golangci-lint run | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| name: Release Helm Chart | ||
|
|
||
| on: | ||
| release: | ||
| types: | ||
| - published | ||
| push: | ||
| branches: | ||
| - main | ||
| tags: | ||
| - 'v*.*.*' | ||
| paths-ignore: | ||
| - 'docs/**' | ||
| - '**/*.md' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - 'docs/**' | ||
| - '**/*.md' | ||
| types: [labeled, opened, synchronize, reopened] | ||
|
|
||
| jobs: | ||
| helm-chart: | ||
| name: Run on Ubuntu | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| if: | | ||
| github.event_name == 'push' || | ||
| (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-charts')) || | ||
| (github.event_name == 'release' && github.event.action == 'published') | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Set up Helm | ||
| uses: azure/setup-helm@v4 | ||
| with: | ||
| version: v3.17.0 | ||
|
|
||
| - name: Determine chart version | ||
| id: chart_version | ||
| run: | | ||
| if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then | ||
| # Use SHA for main branch | ||
| CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)" | ||
| elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| # Use tag version (strip 'v' prefix) | ||
| CHART_VERSION="${GITHUB_REF#refs/tags/v}" | ||
| else | ||
| # Use PR SHA for dry run | ||
| CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)" | ||
| fi | ||
| echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Install Kustomize | ||
felix-kaestner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| run: | | ||
| make kustomize | ||
| mv ./bin/kustomize /usr/local/bin | ||
|
|
||
| - name: Package Helm chart with crds folder in template | ||
| run: | | ||
| helm package charts/network-operator --version ${{ steps.chart_version.outputs.version }}-crds | ||
|
|
||
| - name: Prepare CRDs folder | ||
| run: | | ||
| mkdir -p charts/network-operator/crds | ||
| kustomize build config/default | yq ea 'select(.kind == "CustomResourceDefinition")' > charts/network-operator/crds/crds.yaml | ||
| rm -rf charts/network-operator/templates/crd | ||
|
|
||
| - name: Package Helm chart with removed crds folder from template folder | ||
| run: | | ||
| helm package charts/network-operator --version ${{ steps.chart_version.outputs.version }} | ||
|
|
||
| - name: Log in to GitHub Container Registry | ||
| run: | | ||
| echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
|
||
| - name: Push Helm chart to GHCR | ||
| run: | | ||
| helm push network-operator-${{ steps.chart_version.outputs.version }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts | ||
| helm push network-operator-${{ steps.chart_version.outputs.version }}-crds.tgz oci://ghcr.io/${{ github.repository_owner }}/charts | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.