-
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
33 changed files
with
707 additions
and
356 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,114 @@ | ||
linters: | ||
enable-all: true | ||
disable: | ||
- cyclop | ||
- deadcode | ||
- errname | ||
- exhaustive | ||
- exhaustruct | ||
- exhaustivestruct | ||
- forbidigo | ||
- funlen | ||
- gci | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- gocognit | ||
- godot | ||
- godox | ||
- golint | ||
- gofumpt | ||
- gomnd | ||
- ifshort | ||
- interfacer | ||
- lll | ||
- maligned | ||
- nestif | ||
- nilnil | ||
- nlreturn | ||
- nosnakecase | ||
- paralleltest | ||
- scopelint | ||
- structcheck | ||
- tagliatelle | ||
- testpackage | ||
- thelper | ||
- tparallel | ||
- varcheck | ||
- varnamelen | ||
- wrapcheck | ||
- wsl | ||
|
||
linters-settings: | ||
depguard: | ||
rules: | ||
main: | ||
allow: | ||
- $gostd | ||
- github.com/go-logr/logr | ||
- github.com/coredns/corefile-migration/migration | ||
|
||
- k8s.io/apimachinery/pkg | ||
- k8s.io/api | ||
- 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 | ||
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 | ||
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 | ||
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: sigs.k8s.io/cluster-api-provider-packet | ||
nolintlint: | ||
# Enable to require nolint directives to mention the specific linter being suppressed. | ||
# Default: false | ||
require-specific: true | ||
revive: | ||
rules: | ||
- name: unused-parameter | ||
disabled: true | ||
|
||
run: | ||
go: "1.20" | ||
timeout: 10m | ||
skip-files: | ||
- "zz_generated.*\\.go$" | ||
- ".*conversion.*\\.go$" | ||
allow-parallel-runners: true |
Oops, something went wrong.