mirror of https://github.com/knative/client.git
chore(build): Refactor to simplify and add dedicated test mode (#268)
Rearranged script a bit to make easier to understand the various run modes. Added a `--test` mode which will only run the tests
This commit is contained in:
parent
875e8da2a5
commit
34992aa5a9
|
@ -55,38 +55,52 @@ run() {
|
|||
watch
|
||||
fi
|
||||
|
||||
if ! $(has_flag --fast -f) || $(has_flag --codegen -c); then
|
||||
# Update dependencies
|
||||
update_deps
|
||||
# Fast mode: Only compile and maybe run test
|
||||
if $(has_flag --fast -f); then
|
||||
go_build
|
||||
|
||||
# Format source code and cleanup imports
|
||||
source_format
|
||||
|
||||
# Generate docs
|
||||
# Check for license headers
|
||||
check_license
|
||||
|
||||
# Auto generate cli docs
|
||||
generate_docs
|
||||
fi
|
||||
|
||||
# Stop when only codegen is requested
|
||||
if $(has_flag --codegen -c); then
|
||||
if $(has_flag --test -t); then
|
||||
go_test
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run build
|
||||
go_build
|
||||
|
||||
# Run tests
|
||||
if $(has_flag --test -t) || ! $(has_flag --fast -f); then
|
||||
# Run only tests
|
||||
if $(has_flag --test -t); then
|
||||
go_test
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run only codegen
|
||||
if $(has_flag --codegen -c); then
|
||||
codegen
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Default flow
|
||||
codegen
|
||||
go_build
|
||||
go_test
|
||||
|
||||
echo "────────────────────────────────────────────"
|
||||
./kn version
|
||||
}
|
||||
|
||||
|
||||
codegen() {
|
||||
# Update dependencies
|
||||
update_deps
|
||||
|
||||
# Format source code and cleanup imports
|
||||
source_format
|
||||
|
||||
# Check for license headers
|
||||
check_license
|
||||
|
||||
# Auto generate cli docs
|
||||
generate_docs
|
||||
}
|
||||
|
||||
go_fmt() {
|
||||
echo "🧹 ${S}Format"
|
||||
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w
|
||||
|
@ -267,10 +281,12 @@ ln -s $(basedir)/hack/build.sh /usr/local/bin/kn_build.sh
|
|||
|
||||
Examples:
|
||||
|
||||
* Compile, format, tests, docs: build.sh
|
||||
* Compile only: build.sh --fast
|
||||
* Compile with tests: build.sh -f -t
|
||||
* Automatice recompilation: build.sh --watch
|
||||
* Update deps, format, license check,
|
||||
gen docs, compile, test: ........... build.sh
|
||||
* Compile only: ...................... build.sh --fast
|
||||
* Run only tests: .................... build.sh --test
|
||||
* Compile with tests: ................ build.sh -f -t
|
||||
* Automatic recompilation: ........... build.sh --watch
|
||||
EOT
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue