-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Within the changes of this PR new projects will become to be scaffold with GitHub actions which will allow users be aware of how to test their changes on the ci. Either will make clear the purpose of the test-e2e and encorage common/best practices to ensure the quality of the properties
- Loading branch information
1 parent
a1457ac
commit ba717f3
Showing
28 changed files
with
762 additions
and
34 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,55 @@ | ||
name: Test Sample CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
check-ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install act in project bin | ||
run: | | ||
mkdir -p testdata/project-v4/bin | ||
ACT_VERSION="v0.2.65" | ||
curl -Lo act.tgz https://github.com/nektos/act/releases/download/${ACT_VERSION}/act_Linux_x86_64.tar.gz | ||
tar -C testdata/project-v4/bin -xzf act.tgz act | ||
rm -f act.tgz | ||
- name: Test act installation | ||
run: | | ||
echo "Testing act installation" | ||
testdata/project-v4/bin/act --help | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '~1.22' | ||
|
||
- name: Prepare the environment | ||
run: | | ||
KUSTOMIZATION_FILE_PATH="testdata/project-v4/config/default/kustomization.yaml" | ||
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH | ||
sed -i '51s/^#//' $KUSTOMIZATION_FILE_PATH | ||
cd testdata/project-v4/ | ||
go mod tidy | ||
make generate | ||
make manifests | ||
- name: Lint | ||
run: | | ||
echo "Running lint ci" | ||
./testdata/project-v4/bin/act -W testdata/project-v4/.github/workflows/lint.yml --container-architecture linux/amd64 -P ubuntu-latest=nektos/act-environments-ubuntu:20.04 | ||
- name: Unit Tests | ||
run: | | ||
echo "Running unit tests ci" | ||
./testdata/project-v4/bin/act -W testdata/project-v4/.github/workflows/test.yml --container-architecture linux/amd64 -P ubuntu-latest=nektos/act-environments-ubuntu:20.04 | ||
- name: E2e Tests | ||
run: | | ||
echo "Running e2e tests ci" | ||
./testdata/project-v4/bin/act -W testdata/project-v4/.github/workflows/test-e2e.yml --container-architecture linux/amd64 -P ubuntu-latest=nektos/act-environments-ubuntu:20.04 |
This file was deleted.
Oops, something went wrong.
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: Linter | ||
|
||
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: Run linter | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
name: E2e 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: Create kind cluster | ||
run: kind create cluster | ||
|
||
- name: Test e2e | ||
run: make test-e2e |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
name: Unit 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: Create kind cluster | ||
run: kind create cluster | ||
|
||
- name: Test e2e | ||
run: 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: Linter | ||
|
||
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: Run linter | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
name: E2e 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: Create kind cluster | ||
run: kind create cluster | ||
|
||
- name: Test e2e | ||
run: make test-e2e |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
name: Unit 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: Create kind cluster | ||
run: kind create cluster | ||
|
||
- name: Test e2e | ||
run: 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: Linter | ||
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: Run linter | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.59 | ||
` |
68 changes: 68 additions & 0 deletions
68
pkg/plugins/golang/v4/scaffolds/internal/templates/github/test-e2e.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,68 @@ | ||
/* | ||
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 = &E2eTestCi{} | ||
|
||
// E2eTestCi scaffolds the GitHub Action to call make test-e2e | ||
type E2eTestCi struct { | ||
machinery.TemplateMixin | ||
machinery.BoilerplateMixin | ||
} | ||
|
||
// SetTemplateDefaults implements file.Template | ||
func (f *E2eTestCi) SetTemplateDefaults() error { | ||
if f.Path == "" { | ||
f.Path = filepath.Join(".github", "workflows", "test-e2e.yml") | ||
} | ||
|
||
f.TemplateBody = e2eTestCiTemplate | ||
|
||
return nil | ||
} | ||
|
||
const e2eTestCiTemplate = `name: E2e 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: Create kind cluster | ||
run: kind create cluster | ||
- name: Test e2e | ||
run: make test-e2e | ||
` |
Oops, something went wrong.