-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
1,252 additions
and
1,349 deletions.
There are no files selected for viewing
This file contains 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,125 @@ | ||
--- | ||
name: CI Workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: "5 0 * * *" # TODO: Run every 4 hours to soak test, should be less frequent before merge (weekly/daily/???) | ||
workflow_dispatch: | ||
|
||
env: | ||
BOOTSTRAP_IMAGE_NAME: cluster-api-provider-k3s-bootstrap | ||
CONTROLPLANE_IMAGE_NAME: cluster-api-provider-k3s-controlplane | ||
GHCR_REGISTRY: ghcr.io/${{ github.repository_owner }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
validate: | ||
name: "CI" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: "./go.mod" | ||
|
||
- name: GoLangCI Lint | ||
run: make lint | ||
|
||
- name: Tests - bootstrap | ||
run: make test-bootstrap | ||
|
||
- name: Tests - controlplane | ||
run: make test-controlplane | ||
|
||
build-image: | ||
name: Build and Push Image | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
packages: write # needed to push docker image to ghcr.io | ||
pull-requests: write # needed to create and update comments in PRs | ||
|
||
steps: | ||
- name: Checkout git repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Login to ghcr.io registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build docker - bootstrap | ||
run: make docker-bootstrap | ||
|
||
- name: Build docker - controlplane | ||
run: make docker-controlplane | ||
|
||
# If PR, put image tags in the PR comments | ||
# from https://github.com/marketplace/actions/create-or-update-comment | ||
- name: Find comment for image tags | ||
uses: peter-evans/find-comment@v2 | ||
if: github.event_name == 'pull_request' | ||
id: fc | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: "github-actions[bot]" | ||
body-includes: Docker image tag(s) pushed | ||
|
||
# If PR, put image tags in the PR comments | ||
- name: Create or update comment for image tags | ||
uses: peter-evans/create-or-update-comment@v3 | ||
if: github.event_name == 'pull_request' | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
Docker image tag(s) pushed: | ||
```text | ||
${{ steps.docker_meta.outputs.tags }} | ||
``` | ||
Labels added to images: | ||
```text | ||
${{ steps.docker_meta.outputs.labels }} | ||
``` | ||
edit-mode: replace | ||
|
||
outputs: | ||
image-tag: "${{ steps.docker_meta.outputs.version }}" | ||
|
||
release-manifests: | ||
name: Make Release Manifests | ||
runs-on: ubuntu-latest | ||
needs: [build-image] | ||
env: | ||
TAG: ${{ needs.build-image.outputs.image-tag }} | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: "./go.mod" | ||
|
||
- name: Make Release | ||
run: make release | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: release-manifests | ||
path: out/release |
This file contains 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,30 @@ | ||
name: Pull Request Validation | ||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
workflow_dispatch: | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
validate: | ||
name: "Validate ${{ matrix.target }}" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: ["lint", "test-bootstrap", "test-controlplane"] | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: "./go.mod" | ||
|
||
- name: ${{ matrix.target }} | ||
run: make ${{ matrix.target }} |
This file contains 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,156 @@ | ||
run: | ||
skip-files: | ||
- ".*zz_generated.*\\.go" | ||
- "contrib/.*" | ||
timeout: 5m | ||
issue: | ||
max-same-issues: 0 | ||
max-per-linter: 0 | ||
issues: | ||
exclude-rules: | ||
- path: "test/e2e/*" | ||
linters: | ||
- gosec | ||
text: "G106:" | ||
- linters: | ||
- revive | ||
text: "dot-imports" | ||
path: ".*test.*" | ||
- linters: | ||
- stylecheck | ||
text: "ST1001" | ||
path: ".*test.*" | ||
|
||
linters: | ||
fast: true | ||
disable-all: true | ||
enable: | ||
- asciicheck | ||
- bodyclose | ||
- depguard | ||
- dogsled | ||
- errcheck | ||
- exportloopref | ||
- gci | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- godot | ||
- gofmt | ||
- goimports | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- importas | ||
- ineffassign | ||
- misspell | ||
- nakedret | ||
- nilerr | ||
- noctx | ||
- nolintlint | ||
- prealloc | ||
- predeclared | ||
- revive | ||
- rowserrcheck | ||
- staticcheck | ||
- stylecheck | ||
- thelper | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
|
||
linters-settings: | ||
depguard: | ||
rules: | ||
main: | ||
allow: | ||
- $gostd | ||
- github.com/go-logr/logr | ||
- github.com/coredns/corefile-migration/migration | ||
|
||
- k8s.io/api | ||
- k8s.io/apimachinery/pkg | ||
- k8s.io/apiserver | ||
- k8s.io/client-go | ||
- k8s.io/klog/v2/klogr | ||
- k8s.io/utils/pointer | ||
|
||
- github.com/onsi/ginkgo | ||
- github.com/onsi/gomega | ||
|
||
- sigs.k8s.io/yaml | ||
- sigs.k8s.io/controller-runtime | ||
- sigs.k8s.io/cluster-api | ||
|
||
- github.com/cluster-api-provider-k3s/cluster-api-k3s | ||
gci: | ||
sections: | ||
- standard | ||
- default | ||
- prefix(github.com/cluster-api-provider-k3s/cluster-api-k3s) | ||
gomoddirectives: | ||
# List of allowed `replace` directives. | ||
# Default: [] | ||
replace-allow-list: | ||
- sigs.k8s.io/cluster-api | ||
goimports: | ||
# put imports beginning with prefix after 3rd-party packages; | ||
# it's a comma-separated list of prefixes | ||
local-prefixes: github.com/cluster-api-provider-k3s/cluster-api-k3s | ||
godot: | ||
# declarations - for top level declaration comments (default); | ||
# toplevel - for top level comments; | ||
# all - for all comments. | ||
scope: toplevel | ||
exclude: | ||
- '^ \+.*' | ||
- '^ ANCHOR.*' | ||
gosec: | ||
excludes: | ||
- G307 # Deferring unsafe method "Close" on type "\*os.File" | ||
- G108 # Profiling endpoint is automatically exposed on /debug/pprof | ||
importas: | ||
# Do not allow unaliased imports of aliased packages. | ||
# Default: false | ||
no-unaliased: true | ||
alias: | ||
# Kubernetes | ||
- pkg: k8s.io/api/core/v1 | ||
alias: corev1 | ||
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 | ||
alias: apiextensionsv1 | ||
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1 | ||
alias: metav1 | ||
- pkg: k8s.io/apimachinery/pkg/api/errors | ||
alias: apierrors | ||
- pkg: k8s.io/apimachinery/pkg/util/errors | ||
alias: kerrors | ||
# Controller Runtime | ||
- pkg: sigs.k8s.io/controller-runtime | ||
alias: ctrl | ||
nolintlint: | ||
# Enable to require nolint directives to mention the specific linter being suppressed. | ||
# Default: false | ||
require-specific: true | ||
revive: | ||
rules: | ||
- name: exported | ||
arguments: | ||
- disableStutteringCheck | ||
- name: unused-parameter | ||
disabled: true | ||
staticcheck: | ||
go: "1.20" | ||
stylecheck: | ||
go: "1.20" | ||
tagliatelle: | ||
case: | ||
rules: | ||
# Any struct tag type can be used. | ||
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header` | ||
json: goCamel | ||
unused: | ||
go: "1.20" |
Oops, something went wrong.