forked from kubernetes-sigs/kubebuilder
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub actions to the default scaffold. Motivation: - help developers use the tests in the CI - make clear the purpose of the e2e tests scaffolds - encourage good practices and standard approachs
- Loading branch information
1 parent
ec3bf70
commit 5a69aac
Showing
23 changed files
with
706 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml
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,23 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Run linter | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 |
35 changes: 35 additions & 0 deletions
35
docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test-e2e.yml
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,35 @@ | ||
name: E2E Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test-e2e: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Install the latest version of kind | ||
run: | | ||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 | ||
chmod +x ./kind | ||
sudo mv ./kind /usr/local/bin/kind | ||
- name: Verify kind installation | ||
run: kind version | ||
|
||
- name: Create kind cluster | ||
run: kind create cluster | ||
|
||
- name: Running Test e2e | ||
run: | | ||
go mod tidy | ||
make test-e2e |
23 changes: 23 additions & 0 deletions
23
docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/test.yml
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,23 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Running Tests | ||
run: | | ||
go mod tidy | ||
make test |
23 changes: 23 additions & 0 deletions
23
docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml
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,23 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Run linter | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 |
35 changes: 35 additions & 0 deletions
35
docs/book/src/getting-started/testdata/project/.github/workflows/test-e2e.yml
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,35 @@ | ||
name: E2E Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test-e2e: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Install the latest version of kind | ||
run: | | ||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 | ||
chmod +x ./kind | ||
sudo mv ./kind /usr/local/bin/kind | ||
- name: Verify kind installation | ||
run: kind version | ||
|
||
- name: Create kind cluster | ||
run: kind create cluster | ||
|
||
- name: Running Test e2e | ||
run: | | ||
go mod tidy | ||
make test-e2e |
23 changes: 23 additions & 0 deletions
23
docs/book/src/getting-started/testdata/project/.github/workflows/test.yml
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,23 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Running Tests | ||
run: | | ||
go mod tidy | ||
make test |
23 changes: 23 additions & 0 deletions
23
docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml
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,23 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Run linter | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 |
35 changes: 35 additions & 0 deletions
35
docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test-e2e.yml
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,35 @@ | ||
name: E2E Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test-e2e: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Install the latest version of kind | ||
run: | | ||
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 | ||
chmod +x ./kind | ||
sudo mv ./kind /usr/local/bin/kind | ||
- name: Verify kind installation | ||
run: kind version | ||
|
||
- name: Create kind cluster | ||
run: kind create cluster | ||
|
||
- name: Running Test e2e | ||
run: | | ||
go mod tidy | ||
make test-e2e |
23 changes: 23 additions & 0 deletions
23
docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/test.yml
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,23 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Running Tests | ||
run: | | ||
go mod tidy | ||
make test |
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
67 changes: 67 additions & 0 deletions
67
pkg/plugins/golang/v4/scaffolds/internal/templates/github/lint.go
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,67 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package github | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/v4/pkg/machinery" | ||
) | ||
|
||
var _ machinery.Template = &TestCi{} | ||
|
||
// LintCi scaffolds the GitHub Action to lint the project | ||
type LintCi struct { | ||
machinery.TemplateMixin | ||
machinery.BoilerplateMixin | ||
} | ||
|
||
// SetTemplateDefaults implements file.Template | ||
func (f *LintCi) SetTemplateDefaults() error { | ||
if f.Path == "" { | ||
f.Path = filepath.Join(".github", "workflows", "lint.yml") | ||
} | ||
|
||
f.TemplateBody = lintCiTemplate | ||
|
||
return nil | ||
} | ||
|
||
const lintCiTemplate = `name: Lint | ||
on: | ||
push: | ||
pull_request: | ||
jobs: | ||
lint: | ||
name: Run on Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone the code | ||
uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
- name: Run linter | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 | ||
` |
Oops, something went wrong.