bumping golang.org/x/tools 456962e...64b63a6: > 64b63a6 go.mod: update golang.org/x dependencies > 7701413 internal/mcp: move jsonschema out of mcp/internal > 125cd11 jsonschema: pre-compile regexps > 2f18550 jsonschema: better errors unmarshaling ints > 635622b jsonschema: using hashing for uniqueItems > 0f6a53f mcp: remove ServerConnection > ca54d59 jsonschema: represent integer keywords as ints > c75f7e8 jsonschema: validate object keywords > efd15d8 internal/mcp: clean up handling of content > 80e0fd8 internal/mcp: support prompts > ab01700 internal/mcp: add tool and schema options > 37278be internal/mcp: add more package documentation, examples > 7906227 internal/mcp: add a command transport for connecting to a sidecar > 1587f35 gopls/internal/server/completion: get correct surrounding for second lhs > f11e7de internal/stdlib: add arg types for functions > 0d2acf1 jsonschema: validate array keywords > fd1a208 jsonschema: validate logic keywords > 984d58c go/analysis/unitchecker: update TestVetStdlib's skip for "devel" move > 953b452 go/packages: skip TestRmdirAfterGoList_Runner > 9e366f5 jsonschema: validate numbers and strings > 68cf9be gopls/internal/golang/completion: tostring, tobytes postfix snippets > 6a96d1d cmd/auth: carve out module for deprecated command `auth` > 7261efd internal/mcp: export the Transport interface; add a Server example > e4c83cc internal/mcp: dynamically determine the mcp server based on URL > 26f40ac internal/mcp: clean up SSE server shutdown. > ffe579a go/packages: remove unexported fields from packages.Config > 37f9bd1 jsonschema: validate some keywords > bf81a8d internal/mcp/internal/jsonschema: schema definition > 4ec26d6 gopls/internal/server: add modify tags code action docs > d3f8716 gopls/internal/golang/completion: offer return with whitespace > de18b0b gopls: run modernize -fix in gopls > 2f3d4ad go/packages: add variant of TestRmdirAfterGoList without gocommand > cd9151d gopls/internal/cache: fix bug in toGobDiagnostic(Related) > d3a3775 internal/mcp: implement cancellation > 2863098 internal/mcp: implement ping, and test request interleaving > caf7cdc internal/mcp: implement HTTP SSE transport > 68e94bd x/tools: use 2-arg form of //go:linkname > f11abcb internal/analysisinternal: permit Fix.End slightly beyond EOF > 46e932f internal/analysisinternal: add std import at the start of the import group > d346382 gopls/internal/server: add modify_tags command handler > 0c2f68a gopls/internal/golang/completion: show typeparam for preceding funcs in chain > f01b9f6 gopls/internal/server: support links and hovers for replace directive > cd18362 go/packages: add test that go list closes file handles > 04af9bf go/analysis/passes/hostport: publish > 357c3da internal/mcp: add batching support > cc6bc88 internal/mcp: an MCP SDK prototype > e9d2a36 gopls/internal/golang: pkgdoc: don't discard NewT for unexported t > d905d0b gopls/internal/golang: add test for (unfixed) issue 65098 > e27768f internal/refactor/inline: freeishNames initial scope > 264b0a5 gopls/internal/golang/completion: modernize > 7c6d4c6 internal/refactor/inline: handle generic functions > 6da8d2e gopls/internal/golang: Rename imports: be defensive > 015c0fc gopls/internal/test/integration/web: move misc/webserver_test.go > d97a910 gopls/internal/golang: CodeAction: don't fail because of 1 producer > d0ead43 gopls/internal/settings: enable most staticcheck analyzers > bacd4ba go/analysis/passes/gofix: add an example to doc > 48422ad gopls/internal/golang: add embedded struct info to hover > a318c19 internal/refactor/inline: test type params shadowing pkg symbols > 035d8c6 gopls/internal/golang: Rename all receivers only at declaration > 6f344f9 internal/refactor/inline: add test for type param shadowing > 2337e7c internal/refactor/inline: factor out free obj renaming > 93bb7f0 gopls: update x/telemetry > 33c6419 gopls/internal/golang: fix build > e78fd89 internal/astutil/cursor: four API refinements > cf5cb00 internal/astutil: PreorderStack: a safer ast.Inspect for stacks > f76b112 gopls/internal/golang: Rename all receiver variables > ee8f138 go/analysis/passes/gofix: go:fix directive checker > 1494dfe gopls: improve warning against using go get -tool with gopls > 20a69d6 gopls: warn against using go get -tool with gopls > 26ef4d1 gopls/internal/golang: fix broken build due to semantic merge conflict > 808c870 gopls/internal/cache: more test cases for syntax repairing > b68d703 gopls/internal/cache: handle VS Code Insiders in watchSubdirs > ce1c5d5 gopls/internal/golang: CallHierarchy: show only *types.Func callees > 7e7983f gopls/internal/golang: fix extract with free control statements > fd68572 internal/stdlib: find api directory more robustly > 7ceff13 go/analysis/passes/structtag: ignore findings for "encoding/..." > d363f10 gopls/doc: fix config for vim-lsp > 7829e07 go/analysis/passes/testinggoroutine: used UsedIdent > 9df6bbd gopls: hide todo inside readme.md > fd3eb08 gopls/internal/cache/parsego: new test case for fixed syntax > c24b06c gopls/internal/golang: implementation: report iface/iface relations > edff653 gopls/internal/server: TypeHierarchy support > a99a1c3 gopls/internal/analysis/modernize: prevent conversion of variadic functions to slices.ContainsFunc > 4e973d9 gopls/internal/golang: yet more refinement of golang/go# 70553 > f64b14a gopls/internal/golang: completion: better default keyword completion in switch stmt > af71e42 gopls/internal/golang: Rename: fix crash in ill-typed redeclaration > 9fbec96 gopls/internal/server: workspace: skip adding already added file bumping golang.org/x/text 4890c57...700cc20: > 700cc20 go.mod: update golang.org/x dependencies bumping golang.org/x/sync 396f3a0...506c70f: > 506c70f errgroup: propagate panic and Goexit through Wait bumping knative.dev/pkg d5e74d2...19a1383: > 19a1383 group golang.org/x dependencies (# 3178) > 1c0e799 Bump golang.org/x/net from 0.39.0 to 0.40.0 (# 3177) > d09148e Bump golang.org/x/tools from 0.32.0 to 0.33.0 (# 3176) > cb6cfa2 Bump golang.org/x/sync from 0.13.0 to 0.14.0 (# 3175) bumping golang.org/x/net b8d8877...7d6e62a: > 7d6e62a go.mod: update golang.org/x dependencies > ea0c1d9 internal/timeseries: use built-in max/min to simplify the code > 3e7a445 quic: skip packet numbers for optimistic ack defense > 3f563d3 quic: use an enum for sentPacket state > a3b6e77 quic: don't re-lose packets when discarding keys > 22500a6 quic: decode packet numbers >255 in tests > dd0b200 quic: remove go1.21 build constraint bumping knative.dev/hack c4037b0...f525e18: > f525e18 Bump min kube version to 1.32 (# 424) bumping golang.org/x/sys 01aaa83...3d9a6b8: > 3d9a6b8 windows: add WSADuplicateSocket > c0a9559 cpu: add crypto extensions detection for riscv64 > 8e9e046 windows: add virtual key codes and console input consts > 7138967 windows: fix slicing of NTUnicodeString values > 6a85559 windows: fix dangling pointers in (*SECURITY_DESCRIPTOR).ToAbsolute bumping golang.org/x/term 5d2308b...2ec7864: > 2ec7864 go.mod: update golang.org/x dependencies > a809085 term: support pluggable history Signed-off-by: Knative Automation <automation@knative.team> |
||
---|---|---|
.. | ||
CODE-OF-CONDUCT.md | ||
LICENSE | ||
README.md | ||
SECURITY.md | ||
boilerplate.go.txt | ||
codegen-library.sh | ||
e2e-tests.sh | ||
embed.go | ||
go.work | ||
go.work.sum | ||
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.
Contributing
If you are interested in contributing to Knative, take a look at CLOTRIBUTOR for a list of help wanted issues across the project.
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 build
on 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.sh
scripts, 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
initialize
function 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_success
function. It will be called when a test succeeds -
[optional] Write the
on_failure
function. 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_REPO
andE2E_PROJECT_ID
will 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-tests
and the variableKO_DOCKER_REPO
set 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-teardowns
if 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_TELEMETRY
totrue
. -
By default Spot Worker nodes are disabled. This can be enabled by setting
ENABLE_PREEMPTIBLE_NODES
totrue
.
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 Admin
andStorage Admin
role, 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_knative
function, which will update your system under test (e.g. Knative Serving). -
[optional] Write the
update_benchmark
function, 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.sh
as the release validation tests. If you need to run something else, set the environment variableVALIDATION_TESTS
to the executable to run. -
Write logic for building the release in a function named
build_release()
. Set the environment variableARTIFACTS_TO_PUBLISH
to 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--version
was passed. This also overrides the value of theTAG
variable asv<version>
.RELEASE_BRANCH
: contains the release branch if--branch
was passed. Otherwise it's empty andmain
HEAD will be considered the release branch.RELEASE_NOTES
: contains the filename with the release notes if--release-notes
was passed. The release notes is a simple markdown file.RELEASE_GCS_BUCKET
: contains the GCS bucket name to store the manifests if--release-gcs
was passed, otherwise the default valueknative-nightly/<repo>
will be used. It is empty if--publish
was not passed.RELEASE_DIR
: contains the directory to store the manifests if--release-dir
was passed. Defaults to empty value, but if--nopublish
was 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-dirty
appended to it.BUILD_YYYYMMDD
: current UTC date inYYYYMMDD
format.BUILD_TIMESTAMP
: human-readable UTC timestamp inYYYY-MM-DD HH:MM:SS
format.BUILD_TAG
: a tag in the formv$BUILD_YYYYMMDD-$BUILD_COMMIT_HASH
.KO_DOCKER_REPO
: contains the GCR to store the images if--release-gcr
was passed, otherwise the default valuegcr.io/knative-nightly
will be used. It is set toko.local
if--publish
was not passed.SKIP_TESTS
: true if--skip-tests
was passed. This is handled automatically.TAG_RELEASE
: true if--tag-release
was passed. In this case, the environment variableTAG
will contain the release tag in the formv$BUILD_TAG
.PUBLISH_RELEASE
: true if--publish
was passed. In this case, the environment variableKO_FLAGS
will be updated with the-L
option andTAG
will contain the release tag in the formv$RELEASE_VERSION
.PUBLISH_TO_GITHUB
: true if--version
,--branch
and--publish-release
were 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