From ef594e50166b575af9b4694a7e81fad4eb60a524 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 13 Sep 2018 10:44:49 -0700 Subject: [PATCH 1/3] hack/shellcheck: Set --workdir and ignore tests/smoke vendor Setting --workdir and passing ${@} through means: $ ./hack/shellcheck.sh will show any errors with relative paths that will still work outside the container. For example: ./tests/smoke/.build/external/go_sdk/src/syscall/mkall.sh:278:7: note: Expressions don't expand in single quotes, use double quotes for that. [SC2016] instead of: /workdir/tests/smoke/.build/external/go_sdk/src/syscall/mkall.sh:278:7: note: Expressions don't expand in single quotes, use double quotes for that. [SC2016] Adding prune rules for vendor and .build under tests/smoke avoids complaining about that file and others over which are maintained upstream or elsewhere. --- hack/shellcheck.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hack/shellcheck.sh b/hack/shellcheck.sh index cc245e6b83f..2941dc9987d 100755 --- a/hack/shellcheck.sh +++ b/hack/shellcheck.sh @@ -4,12 +4,15 @@ if [ "$IS_CONTAINER" != "" ]; then find "${TOP_DIR}" \ -path "${TOP_DIR}/vendor" -prune \ -o -path "${TOP_DIR}/.build" -prune \ + -o -path "${TOP_DIR}/tests/smoke/vendor" -prune \ + -o -path "${TOP_DIR}/tests/smoke/.build" -prune \ -o -type f -name '*.sh' -exec shellcheck --format=gcc {} \+ else podman run --rm \ --env IS_CONTAINER=TRUE \ --volume "${PWD}:/workdir:ro,z" \ --entrypoint sh \ + --workdir /workdir \ quay.io/coreos/shellcheck-alpine:v0.5.0 \ - /workdir/hack/shellcheck.sh /workdir + /workdir/hack/shellcheck.sh "${@}" fi; From 4b9cbdd9957e782a6b18fe696ac20caed1b414c2 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 13 Sep 2018 11:00:27 -0700 Subject: [PATCH 2/3] hack/tf-fmt: Allow callers to pass positional args This way they can use: $ hack/tf-fmt.sh -list -check to update their local Terraform (vs. just checking if it's correctly formatted). I've also dropped the read-only mount option to support this use case. I use set [1] to inject default args if the caller set no positional args themselves [2], so the test config in openshift/release continues to work. [1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set [2]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_02 --- hack/tf-fmt.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hack/tf-fmt.sh b/hack/tf-fmt.sh index 228a2de4bef..64dc20cca2f 100755 --- a/hack/tf-fmt.sh +++ b/hack/tf-fmt.sh @@ -2,12 +2,15 @@ # in prow, already in container, so no 'podman run' if [ "$IS_CONTAINER" != "" ]; then + if [ "${#N}" -gt 1 ]; then + set -- -list -check -write=false + fi set -x - /terraform fmt -list -check -write=false + /terraform fmt "${@}" else podman run --rm \ --env IS_CONTAINER=TRUE \ - --volume "${PWD}:${PWD}:ro,z" \ + --volume "${PWD}:${PWD}:z" \ --workdir "${PWD}" \ quay.io/coreos/terraform-alpine:v0.11.7 \ ./hack/tf-fmt.sh From 0581e4757f9c970723b43ae1f97abbcd73fedab4 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 25 Jul 2018 10:29:16 -0700 Subject: [PATCH 3/3] CONTRIBUTING: Drop stale structure-check references They haven't worked since d61abd48 (*: cleanup bazel rules, 2018-03-26, coreos/tectonic-installer#3137). Recommend out new hack/* scripts instead. --- CONTRIBUTING.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d77e36eccc8..13d873224aa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,11 +38,18 @@ For contributors who want to work up pull requests, the workflow is roughly: 3. Make sure your commit messages are in the proper format (see [below](#commit-message-format)). 4. Push your changes to a topic branch in your fork of the repository. 5. Make sure the tests pass, and add any new tests as appropriate. -6. Please run this command before submitting your pull request: +6. We run a number of linters and tests on each pull request. + You may wish to run these locally before submitting your pull request: ```sh - make structure-check + hack/go-fmt.sh . + hack/go-lint.sh $(go list -f '{{ .ImportPath }}' ./...) + hack/go-vet.sh ./... + hack/shellcheck.sh + hack/test-bazel-build-tarball.sh + hack/tf-fmt.sh -list -check + hack/tf-lint.sh + hack/yaml-lint.sh ``` - Note that a portion of the docs and examples are generated and that the generated files are to be committed by you. `make structure-check` checks that what is generated is what you must commit. 7. Submit a pull request to the original repository. 8. The [repo](OWNERS) [owners](OWNERS_ALIASES) will respond to your issue promptly, following [the ususal Prow workflow][prow-review]. @@ -52,9 +59,7 @@ Thanks for your contributions! The coding style suggested by the Golang community is used in installer. See the [style doc][golang-style] for details. Please follow them when working on your contributions. -Tectonic Installer includes syntax checks on the Terraform templates which will fail the PR checker for non-standard formatted code. - -Use `make structure-check` to identify files that don't meet the canonical format and style. Then, use `terraform fmt` to align the template syntax, if necessary. +Terraform has similar standards, and you can run `terraform fmt` to rewrite Terraform files to the canonical format. ## Commit Message Format