Skip to content

Commit

Permalink
chore(build): Refactor to simplify and add dedicated test mode (#268)
Browse files Browse the repository at this point in the history
Rearranged script a bit to make easier to understand the various run
modes.
Added a `--test` mode which will only run the tests
  • Loading branch information
rhuss authored and knative-prow-robot committed Jul 22, 2019
1 parent 875e8da commit 34992aa
Showing 1 changed file with 38 additions and 22 deletions.
60 changes: 38 additions & 22 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,38 +55,52 @@ run() {
watch
fi

if ! $(has_flag --fast -f) || $(has_flag --codegen -c); then
# Update dependencies
update_deps

# Format source code and cleanup imports
source_format
# Fast mode: Only compile and maybe run test
if $(has_flag --fast -f); then
go_build

# Generate docs
# Check for license headers
check_license
if $(has_flag --test -t); then
go_test
fi
exit 0
fi

# Auto generate cli docs
generate_docs
# Run only tests
if $(has_flag --test -t); then
go_test
exit 0
fi

# Stop when only codegen is requested
# Run only codegen
if $(has_flag --codegen -c); then
codegen
exit 0
fi

# Run build
# Default flow
codegen
go_build

# Run tests
if $(has_flag --test -t) || ! $(has_flag --fast -f); then
go_test
fi
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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 34992aa

Please sign in to comment.