bumping golang.org/x/oauth2 ebe81ad...85231f9:
> 85231f9 go.mod: update golang.org/x dependencies
> 34a7afa google/externalaccount: add Config.UniverseDomain
> 95bec95 google/externalaccount: moves externalaccount package out of internal and exports it
bumping google.golang.org/genproto/googleapis/rpc 1f4bbc5...37d4d3c:
> 37d4d3c chore(all): update all (# 1089)
> df926f6 chore(all): auto-regenerate .pb.go files (# 1092)
> 05fd2b7 chore(all): Update to google.golang.org/genproto/googleapis/rpc without backreference (# 1093)
> 1f18d85 chore(all): Drop submodule backreferences (# 1087)
> 6ceb2ff chore: make vet script less error prone (# 1091)
> c5ed0a4 chore(all): auto-regenerate .pb.go files (# 1084)
> 9b9be74 chore: updates for Go 1.22 (# 1090)
> b0ce06b chore(all): update all (# 1088)
> 012b6fc chore(all): update all (# 1086)
> 31a09d3 chore(all): update all (# 1085)
bumping k8s.io/klog/v2 6ded808...007e661:
> 007e661 textlogger: allow caller to override stack unwinding
> 2d08296 Merge pull request # 396 from pohly/slog-helper
> 2086216 Merge pull request # 393 from kaisoz/add-safeptr
> e4deee8 slog: use main logr package instead of logr/slogr
> 8dd3f2e Merge pull request # 395 from pohly/readme-update
> 881fa0b Add SafePtr wrapper
> 5d1d2d5 add SetSlogLogger
> 761b630 Merge pull request # 394 from pohly/owners-update
> d3dd725 docs: clarify relationship between different features
> e3f75b8 Merge pull request # 384 from pohly/slog
> 39afdba dependencies: logr v1.4.1
> f33bd6c OWNERS: remove serathius, add mengjiao-liu, promote pohly
> 02e7b69 Merge pull request # 391 from pohly/with-name-output
> 44eadc3 add slog support
> b588475 Merge pull request # 380 from pohly/golangci-lint-action
> 009a04a output: handle WithName like zapr does
> cc856bb update to logr 1.3.0
> edee20c Merge pull request # 392 from pohly/promote-experimental
> 1a0dfc5 github: run golangci-lint via action
> 61b308a Merge pull request # 390 from pohly/go-vet-print
> 18cdd3a promote experimental code to stable
> ef25537 fix revive issues
> 6632ba5 Merge pull request # 376 from pohly/stderr-threshold-docs
> 6af4ad1 testing: bump Go version matrix
> a4f9060 fix golangci-lint issues
> ff82b97 Merge pull request # 379 from lowang-bh/fixWarning
> 3838dbc stderrthreshold: fix flag comment
> b394f4b enable "go vet" checks for parameters
> 5ac9b76 Merge pull request # 378 from aimuz/fix-370
> 6c35c6a resolve comments warning
> 1e2789b fix: SetLogger via klog.SetLogger will output an unexpected newline
bumping knative.dev/client-pkg 2c46c44...ca457df:
> ca457df upgrade to latest dependencies (# 154)
> f170971 🎁 Terminal UI basic implementation (# 139)
> ae3b852 [main] Upgrade to latest dependencies (# 146)
> e7f1f8d Update community files (# 151)
bumping golang.org/x/term 353276a...c5eaf76:
> c5eaf76 go.mod: update golang.org/x dependencies
bumping google.golang.org/api 87aa1d0...9c2cde8:
> 9c2cde8 chore(main): release 0.169.0 (# 2451)
> a488112 feat(all): auto-regenerate discovery clients (# 2457)
> 2675c0a feat(all): auto-regenerate discovery clients (# 2454)
> d22da18 feat(all): auto-regenerate discovery clients (# 2450)
> e84ba36 chore(main): release 0.168.0 (# 2432)
> 74538f7 chore(all): update module github.com/google/go-github/v58 to v59 (# 2411)
> 6381123 chore(all): update all (# 2435)
> b438981 feat(all): auto-regenerate discovery clients (# 2449)
> af383c7 feat(all): auto-regenerate discovery clients (# 2448)
> 022c85c feat(all): auto-regenerate discovery clients (# 2447)
> 4fa90c9 feat(all): auto-regenerate discovery clients (# 2445)
> ced0c09 feat(all): auto-regenerate discovery clients (# 2443)
> 9f9c0cf feat(all): auto-regenerate discovery clients (# 2442)
> 454cba5 chore: make vet script less error prone (# 2441)
>
|
||
|---|---|---|
| .. | ||
| CODE-OF-CONDUCT.md | ||
| LICENSE | ||
| README.md | ||
| codegen-library.sh | ||
| e2e-tests.sh | ||
| embed.go | ||
| go.work | ||
| infra-library.sh | ||
| library.sh | ||
| microbenchmarks.sh | ||
| performance-tests.sh | ||
| presubmit-tests.sh | ||
| release.sh | ||
| shellcheck-presubmit.sh | ||
README.md
knative.dev/hack
hack is a collection of scripts used to bootstrap CI processes and other vital
entrypoint functionality.
Using the presubmit-tests.sh helper script
This is a helper script to run the presubmit tests. To use it:
-
Source this script:
source "$(go run knative.dev/hack/cmd/script presubmit-tests.sh)" -
[optional] Define the function
build_tests(). If you don't define this function, the default action for running the build tests is to:- run
go buildon the entire repo - run
hack/verify-codegen.sh(if it exists) - check licenses in all go packages
- run
-
[optional] Customize the default build test runner, if you're using it. Set the following environment variables if the default values don't fit your needs:
PRESUBMIT_TEST_FAIL_FAST: Fail the presubmit test immediately if a test fails, defaults to 0 (false).
-
[optional] Define the functions
pre_build_tests()and/orpost_build_tests(). These functions will be called before or after the build tests (either your custom one or the default action) and will cause the test to fail if they don't return success. -
[optional] Define the function
unit_tests(). If you don't define this function, the default action for running the unit tests is to run all go tests in the repo. -
[optional] Define the functions
pre_unit_tests()and/orpost_unit_tests(). These functions will be called before or after the unit tests (either your custom one or the default action) and will cause the test to fail if they don't return success. -
[optional] Define the function
integration_tests(). If you don't define this function, the default action for running the integration tests is to run all run all./test/e2e-*tests.shscripts, in sequence. -
[optional] Define the functions
pre_integration_tests()and/orpost_integration_tests(). These functions will be called before or after the integration tests (either your custom one or the default action) and will cause the test to fail if they don't return success. -
Call the
main()function passing"$@"(with quotes).
Running the script without parameters, or with the --all-tests flag causes all
tests to be executed, in the right order (i.e., build, then unit, then
integration tests).
Use the flags --build-tests, --unit-tests and --integration-tests to run a
specific set of tests.
To run specific programs as a test, use the --run-test flag, and provide the
program as the argument. If arguments are required for the program, pass
everything as a single quotes argument. For example,
./presubmit-tests.sh --run-test "test/my/test data". This flag can be used
repeatedly, and each one will be ran in sequential order.
The script will automatically skip all presubmit tests for PRs where all changed
files are exempt of tests (e.g., a PR changing only the OWNERS file).
Also, for PRs touching only markdown files, the unit and integration tests are skipped.
Sample presubmit test script
source "$(go run knative.dev/hack/cmd/script presubmit-tests.sh)"
function post_build_tests() {
echo "Cleaning up after build tests"
rm -fr ./build-cache
}
function unit_tests() {
make -C tests test
}
function pre_integration_tests() {
echo "Cleaning up before integration tests"
rm -fr ./staging-area
}
# We use the default integration test runner.
main "$@"
Using the e2e-tests.sh helper script
This is a helper script for Knative E2E test scripts. To use it:
-
[optional] Customize the test cluster. Pass the flags as described here to the
initializefunction call if the default values don't fit your needs. -
Source the script:
source "$(go run knative.dev/hack/cmd/script e2e-tests.sh)" -
[optional] Write the
knative_setup()function, which will set up your system under test (e.g., Knative Serving). -
[optional] Write the
knative_teardown()function, which will tear down your system under test (e.g., Knative Serving). -
[optional] Write the
test_setup()function, which will set up the test resources. -
[optional] Write the
test_teardown()function, which will tear down the test resources. -
[optional] Write the
cluster_setup()function, which will set up any resources before the test cluster is created. -
[optional] Write the
cluster_teardown()function, which will tear down any resources after the test cluster is destroyed. -
[optional] Write the
dump_extra_cluster_state()function. It will be called when a test fails, and can dump extra information about the current state of the cluster (typically usingkubectl). -
[optional] Write the
on_successfunction. It will be called when a test succeeds -
[optional] Write the
on_failurefunction. It will be called when a test fails -
[optional] Write the
parse_flags()function. It will be called whenever an unrecognized flag is passed to the script, allowing you to define your own flags. The function must return 0 if the flag is unrecognized, or the number of items to skip in the command line if the flag was parsed successfully. For example, return 1 for a simple flag, and 2 for a flag with a parameter. -
Call the
initialize()function passing"$@". -
Write logic for the end-to-end tests. Run all go tests using
go_test_e2e()(orreport_go_test()if you need a more fine-grained control) and callfail_test()orsuccess()if any of them failed. The environment variableKO_DOCKER_REPOandE2E_PROJECT_IDwill be set according to the test cluster.
Notes:
-
Calling your script without arguments will create a new cluster in your current GCP project and run the tests against it.
-
Calling your script with
--run-testsand the variableKO_DOCKER_REPOset will immediately start the tests against the cluster currently configured forkubectl. -
By default
knative_teardown()andtest_teardown()will be called after the tests finish, use--skip-teardownsif you don't want them to be called. -
By default Google Kubernetes Engine telemetry to Cloud Logging and Monitoring is disabled. This can be enabled by setting
ENABLE_GKE_TELEMETRYtotrue. -
By default Spot Worker nodes are disabled. This can be enabled by setting
ENABLE_PREEMPTIBLE_NODEStotrue.
Sample end-to-end test script
This script will test that the latest Knative Serving nightly release works. It
defines a special flag (--no-knative-wait) that causes the script not to wait
for Knative Serving to be up before running the tests. It also requires that the
test cluster is created in a specific region, us-west2.
source "$(go run knative.dev/hack/cmd/script e2e-tests.sh)"
function knative_setup() {
start_latest_knative_serving
if (( WAIT_FOR_KNATIVE )); then
wait_until_pods_running knative-serving || fail_test "Knative Serving not up"
fi
}
function parse_flags() {
if [[ "$1" == "--no-knative-wait" ]]; then
WAIT_FOR_KNATIVE=0
return 1
fi
return 0
}
WAIT_FOR_KNATIVE=1
# This test requires a cluster in LA
initialize $@ --region=us-west2
# TODO: use go_test_e2e to run the tests.
kubectl get pods || fail_test
success
Using the performance-tests.sh helper script
This is a helper script for Knative performance test scripts. In combination with specific Prow jobs, it can automatically manage the environment for running benchmarking jobs for each repo. To use it:
-
Source the script:
source "$(go run knative.dev/hack/cmd/script performance-tests.sh)" -
[optional] Customize GCP project settings for the benchmarks. Set the following environment variables if the default value doesn't fit your needs:
PROJECT_NAME: GCP project name for keeping the clusters that run the benchmarks. Defaults toknative-performance.SERVICE_ACCOUNT_NAME: Service account name for controlling GKE clusters and interacting with Mako server. It MUST haveKubernetes Engine AdminandStorage Adminrole, and be allowed by Mako admin. Defaults tomako-job.
-
[optional] Customize root path of the benchmarks. This root folder should contain and only contain all benchmarks you want to run continuously. Set the following environment variable if the default value doesn't fit your needs:
BENCHMARK_ROOT_PATH: Benchmark root path, defaults totest/performance/benchmarks. Each repo can decide which folder to put its benchmarks in, and override this environment variable to be the path of that folder.
-
[optional] Write the
update_knativefunction, which will update your system under test (e.g. Knative Serving). -
[optional] Write the
update_benchmarkfunction, which will update the underlying resources for the benchmark (usually Knative resources and Kubernetes cronjobs for benchmarking). This function accepts a parameter, which is the benchmark name in the current repo. -
Call the
main()function with all parameters (e.g.$@).
Sample performance test script
This script will update Knative serving and the given benchmark.
source "$(go run knative.dev/hack/cmd/script performance-tests.sh)"
function update_knative() {
echo ">> Updating serving"
ko apply -f config/ || abort "failed to apply serving"
}
function update_benchmark() {
echo ">> Updating benchmark $1"
ko apply -f ${BENCHMARK_ROOT_PATH}/$1 || abort "failed to apply benchmark $1"
}
main $@
Using the release.sh helper script
This is a helper script for Knative release scripts. To use it:
-
Source the script:
source "$(go run knative.dev/hack/cmd/script release.sh)" -
[optional] By default, the release script will run
./test/presubmit-tests.shas the release validation tests. If you need to run something else, set the environment variableVALIDATION_TESTSto the executable to run. -
Write logic for building the release in a function named
build_release(). Set the environment variableARTIFACTS_TO_PUBLISHto the list of files created, space separated. Use the following boolean (0 is false, 1 is true) and string environment variables for the logic:RELEASE_VERSION: contains the release version if--versionwas passed. This also overrides the value of theTAGvariable asv<version>.RELEASE_BRANCH: contains the release branch if--branchwas passed. Otherwise it's empty andmainHEAD will be considered the release branch.RELEASE_NOTES: contains the filename with the release notes if--release-noteswas passed. The release notes is a simple markdown file.RELEASE_GCS_BUCKET: contains the GCS bucket name to store the manifests if--release-gcswas passed, otherwise the default valueknative-nightly/<repo>will be used. It is empty if--publishwas not passed.RELEASE_DIR: contains the directory to store the manifests if--release-dirwas passed. Defaults to empty value, but if--nopublishwas passed then points to the repository root directory.BUILD_COMMIT_HASH: the commit short hash for the current repo. If the current git tree is dirty, it will have-dirtyappended to it.BUILD_YYYYMMDD: current UTC date inYYYYMMDDformat.BUILD_TIMESTAMP: human-readable UTC timestamp inYYYY-MM-DD HH:MM:SSformat.BUILD_TAG: a tag in the formv$BUILD_YYYYMMDD-$BUILD_COMMIT_HASH.KO_DOCKER_REPO: contains the GCR to store the images if--release-gcrwas passed, otherwise the default valuegcr.io/knative-nightlywill be used. It is set toko.localif--publishwas not passed.SKIP_TESTS: true if--skip-testswas passed. This is handled automatically.TAG_RELEASE: true if--tag-releasewas passed. In this case, the environment variableTAGwill contain the release tag in the formv$BUILD_TAG.PUBLISH_RELEASE: true if--publishwas passed. In this case, the environment variableKO_FLAGSwill be updated with the-Loption andTAGwill contain the release tag in the formv$RELEASE_VERSION.PUBLISH_TO_GITHUB: true if--version,--branchand--publish-releasewere passed.
All boolean environment variables default to false for safety.
All environment variables above, except
KO_FLAGS, are marked read-only oncemain()is called (see below). -
Call the
main()function passing"$@"(with quotes).
Sample release script
source "$(go run knative.dev/hack/cmd/script release.sh)"
function build_release() {
# config/ contains the manifests
ko resolve ${KO_FLAGS} -f config/ > release.yaml
ARTIFACTS_TO_PUBLISH="release.yaml"
}
main "$@"
Origins of hack
When Kubernetes was first getting started, someone was trying to introduce some
quick shell scripts and land them into the ./scripts folder. But there was one
that opposed this: Ville Aikas. The compromise was to put those quick scripts in
a folder called hack to remind users and developers that there is likely a
better way to perform the task you are attempting that is not using a shell
script, like a tested python script.
"I was like fine, put them in hack not scripts, cause they are hacks." - Ville Aikas