From 574bef0b3cf0a707a4b44008242d7d939b709aad Mon Sep 17 00:00:00 2001 From: goedelsoup Date: Fri, 19 Jun 2020 14:30:28 -0400 Subject: [PATCH 01/21] Add support for Clojure with clj-kondo --- .automation/test/clojure/README.md | 13 +++++ .automation/test/clojure/clojure_bad_1.clj | 64 +++++++++++++++++++++ .automation/test/clojure/clojure_good_1.clj | 35 +++++++++++ Dockerfile | 9 +++ README.md | 2 + lib/linter.sh | 58 ++++++++++++++++++- 6 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 .automation/test/clojure/README.md create mode 100644 .automation/test/clojure/clojure_bad_1.clj create mode 100644 .automation/test/clojure/clojure_good_1.clj diff --git a/.automation/test/clojure/README.md b/.automation/test/clojure/README.md new file mode 100644 index 00000000..6606ef5b --- /dev/null +++ b/.automation/test/clojure/README.md @@ -0,0 +1,13 @@ +# Clojure Test Cases +This folder holds the test cases for **Clojure**. + +## Additional Docs +No Additional information is needed for this test case. + +## Good Test Cases +The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted. +- **Note:** They are linted utilizing the default linter rules. + +## Bad Test Cases +The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted. +- **Note:** They are linted utilizing the default linter rules. diff --git a/.automation/test/clojure/clojure_bad_1.clj b/.automation/test/clojure/clojure_bad_1.clj new file mode 100644 index 00000000..c8366066 --- /dev/null +++ b/.automation/test/clojure/clojure_bad_1.clj @@ -0,0 +1,64 @@ +(ns foo + (:require + [clojure.string :as str] + ;; We're never using this namespace. Also, the namespaces aren't sorted. + [clojure.set :as set])) + +;; Here we made a typo, so the symbol is unresolved: +(but-last [1 2 3]) + +;; Clj-kondo knows about arities of clojure namespaces, but you can also teach +;; it about your libraries or own namespaces +(str/join) + +;; foo has an arity of 2, but we're not actually using y +(defn foo-fn [x y] + ;; this do is redundant: + (do + ;; this is handy for debugging, but please remove it before pushing your code: + (def tmp_x x) + (let [y (fn [] (inc x))] + ;; the next let can be squashed together with the previous: + (let [z y] + ;; whoopsy, calling a local function with an incorrect number of args: + (y x) + ;; also wrong: + (recur))))) + +(letfn + [(f [] (h 1)) + (h [] (f 1))]) + +(defn- private-fn []) +;; redefining it... +(defn- private-fn []) + +(defn foo [] :foo) +;; Type error, because foo doesn't return a number! +(inc (foo)) + +;; I'm tired now, let's sleep... +;; Oops, not happening because of wrong amount of args: +(Thread/sleep 1000 1 2) + +;; Here we switch to another namespace and require the previous: +(ns bar (:require [foo :as f])) + +;; Wrong arity when calling a function from the previous namespace: +(f/foo-fn) + +;; private: +(f/private-fn) + +;; this won't pass the reader: +{:a 1 :a 2} +;; and neither will this: +#{1 1} +;; nor this: +{:a 1 :b} + +(ns bar-test (:require [clojure.test :as t])) + +(t/deftest my-tests + ;; you're not actually testing something here: + (odd? (inc 1))) \ No newline at end of file diff --git a/.automation/test/clojure/clojure_good_1.clj b/.automation/test/clojure/clojure_good_1.clj new file mode 100644 index 00000000..7ea739e1 --- /dev/null +++ b/.automation/test/clojure/clojure_good_1.clj @@ -0,0 +1,35 @@ +(ns foo + (:require + [clojure.string :as str])) + +(butlast [1 2 3]) + +(str/join "" "") + +(defn foo-fn [x] + (let [y (fn [] (inc x)) + z y] + (y))) + +(letfn + [(f [g] (h g)) + (h [i] (f i))]) + +(defn foo [] 1) +(inc (foo)) + +(Thread/sleep 1000 1) + +;; Here we switch to another namespace and require the previous: +(ns bar (:require [foo :as f])) + +(f/foo-fn 1) + +{:a 1 :b 2} +#{1 2} +{:a 1 :b 2} + +(ns bar-test (:require [clojure.test :as t])) + +(t/deftest my-tests + (t/is (odd? (inc 1)))) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7f655c31..f66fb596 100644 --- a/Dockerfile +++ b/Dockerfile @@ -102,6 +102,14 @@ RUN wget -O- -nvq https://raw.githubusercontent.com/golangci/golangci-lint/maste RUN curl -Ls "$(curl -Ls https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" -o tflint.zip && unzip tflint.zip && rm tflint.zip \ && mv "tflint" /usr/bin/ +##################### +# Install clj-kondo # +##################### +RUN curl -sLO https://github.com/borkdude/clj-kondo/releases/download/v2020.06.12/clj-kondo-2020.06.12-linux-static-amd64.zip \ + && unzip clj-kondo-2020.06.12-linux-static-amd64.zip \ + && rm clj-kondo-2020.06.12-linux-static-amd64.zip \ + && mv clj-kondo /usr/bin/ + ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### @@ -128,6 +136,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ VALIDATE_GO=${VALIDATE_GO} \ VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \ VALIDATE_CSS=${VALIDATE_CSS} \ + VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \ ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ RUN_LOCAL=${RUN_LOCAL} \ TEST_CASE_RUN=${TEST_CASE_RUN} \ diff --git a/README.md b/README.md index b7f5455d..4a001385 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | --- | --- | | **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | | **CSS** | [stylelint](https://stylelint.io/) | +| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | | **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | | **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | | **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | @@ -135,6 +136,7 @@ and won't run anything unexpected. | **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the language. | +| **VALIDATE_CLOJURE** | `true` | Flag to enable or disable the linting process of the language. | | **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | | **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | | **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. | diff --git a/lib/linter.sh b/lib/linter.sh index b96f44ec..c1c46b7a 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -51,6 +51,9 @@ TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path # CSS Vars CSS_FILE_NAME='.stylelintrc.json' # Name of the file CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to the CSS lint rules +# Clojure Vars +CLOJURE_FILE_NAME='.clj-kondo/config.edn' +CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME" ####################################### @@ -59,14 +62,15 @@ CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to th LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" "pylint" "perl" "rubocop" "coffeelint" "eslint" "standard" "ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint" - "stylelint") + "stylelint" "clj-kondo") ############################# # Language array for prints # ############################# LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RUBY' 'PYTHON' 'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' - 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS') + 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS' + 'CLOJURE') ################### # GitHub ENV Vars # @@ -95,6 +99,7 @@ VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate lang VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language +VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases ############## @@ -136,6 +141,7 @@ FILE_ARRAY_DOCKER=() # Array of files to check FILE_ARRAY_GO=() # Array of files to check FILE_ARRAY_TERRAFORM=() # Array of files to check FILE_ARRAY_CSS=() # Array of files to check +FILE_ARRAAY_CLOJURE=() # Array of files to check ############ # Counters # @@ -158,6 +164,7 @@ ERRORS_FOUND_DOCKER=0 # Count of errors found ERRORS_FOUND_GO=0 # Count of errors found ERRORS_FOUND_TERRAFORM=0 # Count of errors found ERRORS_FOUND_CSS=0 # Count of errors found +ERRORS_FOUND_CLOJURE=0 # Count of errors found ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -735,6 +742,7 @@ GetValidationInfo() VALIDATE_GO=$(echo "$VALIDATE_GO" | awk '{print tolower($0)}') VALIDATE_TERRAFORM=$(echo "$VALIDATE_TERRAFORM" | awk '{print tolower($0)}') VALIDATE_CSS=$(echo "$VALIDATE_CSS" | awk '{print tolower($0)') + VALIDATE_CLOJURE=$(echo "$VALIDATE_CLOJURE" | awk '{print tolower($0)') ################################################ # Determine if any linters were explicitly set # @@ -757,7 +765,8 @@ GetValidationInfo() -n "$VALIDATE_DOCKER" || \ -n "$VALIDATE_GO" || \ -n "$VALIDATE_TERRAFORM" || \ - -n "$VALIDATE_CSS" ]]; then + -n "$VALIDATE_CSS" || \ + -n "$VALIDATE_CLOJURE" ]]; then ANY_SET="true" fi @@ -1013,6 +1022,20 @@ GetValidationInfo() VALIDATE_CSS="true" fi + ####################################### + # Validate if we should check Clojure # + ####################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_CLOJURE" ]]; then + # Clojure flag was not set - default to false + VALIDATE_CLOJURE="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_CLOJURE="true" + fi + ####################################### # Print which linters we are enabling # ####################################### @@ -1106,6 +1129,11 @@ GetValidationInfo() else PRINT_ARRAY+=("- Excluding [CSS] files in code base...") fi + if [[ "$VALIDATE_CLOJURE" == "true" ]]; then + PRINT_ARRAY+=("- Validating [CLOJURE] files in code base...") + else + PRINT_ARRAY+=("- Excluding [CLOJURE] files in code base...") + fi ############################## # Validate Ansible Directory # @@ -1431,6 +1459,15 @@ BuildFileList() # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 + elif [ "$FILE" == "clj" ] || [ "$FILE" == "cljs" ] || [ "$FILE" == "cljc" ] || [ "$FILE" == "edn" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CLOJURE+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 else ############################################## # Use file to see if we can parse what it is # @@ -1986,6 +2023,7 @@ RunTestCases() TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c $ANSIBLE_LINTER_RULES" "ansible-lint" TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" + TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES" ".*\.\(clj\)\$" ################# # Footer prints # @@ -2282,6 +2320,20 @@ if [ "$VALIDATE_DOCKER" == "true" ]; then LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}" fi +################### +# CLOJURE LINTING # +################### +if [ "$VALIDATE_CLOJURE" == "true" ]; then + ################################# + # Get Clojure standard rules # + ################################# + GetStandardRules "clj-kondo" + ######################### + # Lint the Clojure files # + ######################### + LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES" ".*\.\(clj\)\$" "${FILE_ARRAY_CLOJURE[@]}" +fi + ########## # Footer # ########## From 69b98486a3645a62d769dd34389072e0338e660d Mon Sep 17 00:00:00 2001 From: goedelsoup Date: Fri, 19 Jun 2020 14:31:50 -0400 Subject: [PATCH 02/21] fix typo in variable name --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index c1c46b7a..53828113 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -141,7 +141,7 @@ FILE_ARRAY_DOCKER=() # Array of files to check FILE_ARRAY_GO=() # Array of files to check FILE_ARRAY_TERRAFORM=() # Array of files to check FILE_ARRAY_CSS=() # Array of files to check -FILE_ARRAAY_CLOJURE=() # Array of files to check +FILE_ARRAY_CLOJURE=() # Array of files to check ############ # Counters # From 8a5be8d448427c01a2eb38aec156fab7333fa7cf Mon Sep 17 00:00:00 2001 From: goedelsoup Date: Fri, 19 Jun 2020 14:34:53 -0400 Subject: [PATCH 03/21] make clj-kondo version a build arg --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f66fb596..2529279a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -105,9 +105,10 @@ RUN curl -Ls "$(curl -Ls https://api.github.com/repos/terraform-linters/tflint/r ##################### # Install clj-kondo # ##################### -RUN curl -sLO https://github.com/borkdude/clj-kondo/releases/download/v2020.06.12/clj-kondo-2020.06.12-linux-static-amd64.zip \ - && unzip clj-kondo-2020.06.12-linux-static-amd64.zip \ - && rm clj-kondo-2020.06.12-linux-static-amd64.zip \ +ARG CLJ_KONDO_VERSION='2020.06.12' +RUN curl -sLO https://github.com/borkdude/clj-kondo/releases/download/v${CLJ_KONDO_VERSION}/clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip \ + && unzip clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip \ + && rm clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip \ && mv clj-kondo /usr/bin/ ########################################### From 5063d7cb6c03e3aa8c7031b5b7e3bdb46e63e4f7 Mon Sep 17 00:00:00 2001 From: goedelsoup Date: Mon, 22 Jun 2020 08:39:32 -0400 Subject: [PATCH 04/21] fix clojure file regex --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 82a3ebaf..e4c7d218 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2088,7 +2088,7 @@ RunTestCases() TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" - TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES" ".*\.\(clj\)\$" + TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES" ".*\.\(clj\|cljs\|cljc\|edn\)\$" ################# # Footer prints # @@ -2407,7 +2407,7 @@ if [ "$VALIDATE_CLOJURE" == "true" ]; then ######################### # Lint the Clojure files # ######################### - LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES" ".*\.\(clj\)\$" "${FILE_ARRAY_CLOJURE[@]}" + LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILE_ARRAY_CLOJURE[@]}" fi ########## From 7a298710713bbbe52efc450161aa7770ccc59fb8 Mon Sep 17 00:00:00 2001 From: goedelsoup Date: Tue, 23 Jun 2020 09:43:29 -0400 Subject: [PATCH 05/21] add documentation to configuration --- .github/linters/.clj-kondo/config.edn | 2 ++ .gitignore | 3 +++ docs/disabling-linters.md | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 .github/linters/.clj-kondo/config.edn diff --git a/.github/linters/.clj-kondo/config.edn b/.github/linters/.clj-kondo/config.edn new file mode 100644 index 00000000..30cae4c6 --- /dev/null +++ b/.github/linters/.clj-kondo/config.edn @@ -0,0 +1,2 @@ +{:linters {:unresolved-symbol {:exclude [(compojure.api.sweet/defroutes)]} + :refer-all {:exclude [clj-time.jdbc]}}} diff --git a/.gitignore b/.gitignore index ad46b308..ae755b39 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,6 @@ typings/ # next.js build output .next + +# clj-kondo cache +.cache \ No newline at end of file diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 0efb4d27..45fa6957 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -607,3 +607,22 @@ import package.b.* ### ktlint disable entire file - There is currently **No** way to disable rules inline of the file(s) + +-------------------------------------------------------------------------------- + +## Clojure +- [clj-kondo](https://github.com/borkdude/clj-kondo) + +### clj-kondo standard Config file +- `.github/linters/.clj-kondo/config.edn` + +### clj-kondo disable single line +- There is currently **No** way to disable rules in a single line + +### clj-kondo disable code block +- There is currently **No** way to disable rules in a code block + +### clj-kondo disable entire file +```clojure +{:output {:exclude-files ["path/to/file"]}} +``` From a52fd6a5fe44eb9dc13b729519847081665fcb4e Mon Sep 17 00:00:00 2001 From: goedelsoup Date: Tue, 23 Jun 2020 09:46:15 -0400 Subject: [PATCH 06/21] link to clj-kondo docs --- docs/disabling-linters.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 45fa6957..5b11ee51 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -612,6 +612,7 @@ import package.b.* ## Clojure - [clj-kondo](https://github.com/borkdude/clj-kondo) +- Since clj-kondo approaches static analysis in a very Clojure way, it is advised to read the [configuration docs](https://github.com/borkdude/clj-kondo/blob/master/doc/config.md) ### clj-kondo standard Config file - `.github/linters/.clj-kondo/config.edn` From b922ece707b9a57c7ad42c9159fdd6bdbab7c217 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 12:45:57 -0500 Subject: [PATCH 07/21] found missing var --- lib/linter.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 5c8042bd..5f7af0c9 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -150,7 +150,7 @@ FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check FILE_ARRAY_DOCKER=() # Array of files to check FILE_ARRAY_GO=() # Array of files to check FILE_ARRAY_TERRAFORM=() # Array of files to check -FILE_ARRAY_POWERSHELL=() # Array of files to check +FILE_ARRAY_POWERSHELL=() # Array of files to check FILE_ARRAY_CSS=() # Array of files to check FILE_ARRAY_ENV=() # Array of files to check FILE_ARRAY_CLOJURE=() # Array of files to check @@ -2159,6 +2159,7 @@ Footer() [ "$ERRORS_FOUND_RUBY" -ne 0 ] || \ [ "$ERRORS_FOUND_CSS" -ne 0 ] || \ [ "$ERRORS_FOUND_ENV" -ne 0 ] || \ + [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || \ [ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then # Failed exit echo "Exiting with errors found!" From e2eaf633277bc11514231f62dc9541fe47861740 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 24 Jun 2020 08:35:56 -0500 Subject: [PATCH 08/21] Adding config to templates --- TEMPLATES/.clj-kondo/config.edn | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 TEMPLATES/.clj-kondo/config.edn diff --git a/TEMPLATES/.clj-kondo/config.edn b/TEMPLATES/.clj-kondo/config.edn new file mode 100644 index 00000000..30cae4c6 --- /dev/null +++ b/TEMPLATES/.clj-kondo/config.edn @@ -0,0 +1,2 @@ +{:linters {:unresolved-symbol {:exclude [(compojure.api.sweet/defroutes)]} + :refer-all {:exclude [clj-time.jdbc]}}} From b26f7eda6d9c5f88cce367f34bad8bad8a78a8c4 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 24 Jun 2020 09:51:16 -0500 Subject: [PATCH 09/21] fixed command --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 74ea060a..39921b04 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2221,7 +2221,7 @@ RunTestCases() TestCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" - TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES" ".*\.\(clj\|cljs\|cljc\|edn\)\$" + TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" ################# @@ -2565,7 +2565,7 @@ if [ "$VALIDATE_CLOJURE" == "true" ]; then ######################### # Lint the Clojure files # ######################### - LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILE_ARRAY_CLOJURE[@]}" + LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILE_ARRAY_CLOJURE[@]}" fi ###################### From eac560b35b45c3850f4aa1b6d9ed0e52a37ee9d4 Mon Sep 17 00:00:00 2001 From: Justin Kalland Date: Thu, 25 Jun 2020 08:13:19 +0200 Subject: [PATCH 10/21] Add support for OpenAPI --- .automation/test/openapi/README.md | 13 +++ .automation/test/openapi/openapi_bad_1.yml | 1 + .automation/test/openapi/openapi_bad_2.json | 3 + .automation/test/openapi/openapi_good_1.yml | 13 +++ .automation/test/openapi/openapi_good_2.json | 23 ++++++ Dockerfile | 4 +- README.md | 2 + TEMPLATES/.openapirc.yml | 9 +++ lib/linter.sh | 83 +++++++++++++++++++- 9 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 .automation/test/openapi/README.md create mode 100644 .automation/test/openapi/openapi_bad_1.yml create mode 100644 .automation/test/openapi/openapi_bad_2.json create mode 100644 .automation/test/openapi/openapi_good_1.yml create mode 100644 .automation/test/openapi/openapi_good_2.json create mode 100644 TEMPLATES/.openapirc.yml diff --git a/.automation/test/openapi/README.md b/.automation/test/openapi/README.md new file mode 100644 index 00000000..8e77fdbf --- /dev/null +++ b/.automation/test/openapi/README.md @@ -0,0 +1,13 @@ +# OpenAPI Test Cases +This folder holds the test cases for **OpenAPI**. + +## Additional Docs +No Additional information is needed for this test case. + +## Good Test Cases +The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted. +- **Note:** They are linted utilizing the default linter rules. + +## Bad Test Cases +The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted. +- **Note:** They are linted utilizing the default linter rules. diff --git a/.automation/test/openapi/openapi_bad_1.yml b/.automation/test/openapi/openapi_bad_1.yml new file mode 100644 index 00000000..6c86b1b4 --- /dev/null +++ b/.automation/test/openapi/openapi_bad_1.yml @@ -0,0 +1 @@ +openapi: '3.0.0' diff --git a/.automation/test/openapi/openapi_bad_2.json b/.automation/test/openapi/openapi_bad_2.json new file mode 100644 index 00000000..b0b97ddb --- /dev/null +++ b/.automation/test/openapi/openapi_bad_2.json @@ -0,0 +1,3 @@ +{ + "openapi": "3.0.0" +} diff --git a/.automation/test/openapi/openapi_good_1.yml b/.automation/test/openapi/openapi_good_1.yml new file mode 100644 index 00000000..eb4924a1 --- /dev/null +++ b/.automation/test/openapi/openapi_good_1.yml @@ -0,0 +1,13 @@ +openapi: 3.0.0 +info: + title: Example + version: '1.0' + contact: + name: Justin Kalland + email: justin@kalland.com + description: Test for super-linter +servers: + - url: 'http://localhost:3000' +paths: {} +tags: + - name: example diff --git a/.automation/test/openapi/openapi_good_2.json b/.automation/test/openapi/openapi_good_2.json new file mode 100644 index 00000000..93f59635 --- /dev/null +++ b/.automation/test/openapi/openapi_good_2.json @@ -0,0 +1,23 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Example", + "version": "1.0", + "contact": { + "name": "Justin Kalland", + "email": "justin@kalland.com" + }, + "description": "Test for super-linter" + }, + "servers": [ + { + "url": "http://localhost:3000" + } + ], + "paths": {}, + "tags": [ + { + "name": "example" + } + ] +} diff --git a/Dockerfile b/Dockerfile index 49a5dbb1..b25a7b1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ RUN apk add --no-cache \ libxml2-utils perl \ ruby ruby-dev ruby-bundler ruby-rdoc make \ py3-setuptools ansible-lint \ - go \ + go \ openjdk8-jre \ php7 \ ca-certificates less ncurses-terminfo-base \ @@ -72,6 +72,7 @@ RUN npm config set package-lock false \ eslint-plugin-jest \ stylelint \ stylelint-config-standard \ + @stoplight/spectral \ && npm --no-cache install \ markdownlint-cli \ jsonlint prettyjson \ @@ -168,6 +169,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ VALIDATE_ENV=${VALIDATE_ENV} \ VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \ VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \ + VALIDATE_OPENAPI=${VALIDATE_OPENAPI} \ ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ RUN_LOCAL=${RUN_LOCAL} \ TEST_CASE_RUN=${TEST_CASE_RUN} \ diff --git a/README.md b/README.md index 218a30d5..638ed28b 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | | **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | | **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | +| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | ## How to use To use this **GitHub** Action you will need to complete the following: @@ -144,6 +145,7 @@ and won't run anything unexpected. | **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_ENV** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the language. | +| **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the language. | | **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | | **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | | **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | diff --git a/TEMPLATES/.openapirc.yml b/TEMPLATES/.openapirc.yml new file mode 100644 index 00000000..fdf641e1 --- /dev/null +++ b/TEMPLATES/.openapirc.yml @@ -0,0 +1,9 @@ +--- + +########################## +########################## +## OpenAPI Linter rules ## +########################## +########################## + +extends: spectral:oas diff --git a/lib/linter.sh b/lib/linter.sh index 9bad8c8b..7b90ae32 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -54,6 +54,9 @@ POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Pat # CSS Vars CSS_FILE_NAME='.stylelintrc.json' # Name of the file CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to the CSS lint rules +# OpenAPI Vars +OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file +OPENAPI_LINTER_RULES="$DEFAULT_RULES_LOCATION/$OPENAPI_FILE_NAME" # Path to the OpenAPI lint rules ####################################### # Linter array for information prints # @@ -61,7 +64,7 @@ CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to th LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" "pylint" "perl" "rubocop" "coffeelint" "eslint" "standard" "ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint" - "stylelint" "dotenv-linter" "powershell" "ktlint") + "stylelint" "dotenv-linter" "powershell" "ktlint" "spectral") ############################# # Language array for prints # @@ -69,7 +72,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'PHP' 'RUBY' 'PYTHON' 'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' - 'ENV' 'POWERSHELL' 'KOTLIN') + 'ENV' 'POWERSHELL' 'KOTLIN' 'OPENAPI') ################### # GitHub ENV Vars # @@ -102,6 +105,7 @@ VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate lang VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language +VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors @@ -149,6 +153,7 @@ FILE_ARRAY_POWERSHELL=() # Array of files to check FILE_ARRAY_CSS=() # Array of files to check FILE_ARRAY_ENV=() # Array of files to check FILE_ARRAY_KOTLIN=() # Array of files to check +FILE_ARRAY_OPENAPI=() # Array of files to check ############ # Counters # @@ -175,6 +180,7 @@ ERRORS_FOUND_POWERSHELL=0 # Count of errors found ERRORS_FOUND_CSS=0 # Count of errors found ERRORS_FOUND_ENV=0 # Count of errors found ERRORS_FOUND_KOTLIN=0 # Count of errors found +ERRORS_FOUND_OPENAPI=0 # Count of errors found ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -556,6 +562,19 @@ LintAnsibleFiles() fi fi } + +################################################################################ +#### Function DetectOpenAPIFile ################################################ +DetectOpenAPIFile() +{ + egrep '"openapi":|"swagger":|^openapi:|^swagger:' $GITHUB_WORKSPACE/$1 > /dev/null + if [ $? -eq 0 ]; then + return 0 + else + return 1 + fi +} + ################################################################################ #### Function GetGitHubVars #################################################### GetGitHubVars() @@ -756,6 +775,7 @@ GetValidationInfo() VALIDATE_CSS=$(echo "$VALIDATE_CSS" | awk '{print tolower($0)}') VALIDATE_ENV=$(echo "$VALIDATE_ENV" | awk '{print tolower($0)}') VALIDATE_KOTLIN=$(echo "$VALIDATE_KOTLIN" | awk '{print tolower($0)}') + VALIDATE_OPENAPI=$(echo "$VALIDATE_OPENAPI" | awk '{print tolower($0)}') ################################################ # Determine if any linters were explicitly set # @@ -782,7 +802,8 @@ GetValidationInfo() -n "$VALIDATE_POWERSHELL" || \ -n "$VALIDATE_CSS" || \ -n "$VALIDATE_ENV" || \ - -n "$VALIDATE_KOTLIN" ]]; then + -n "$VALIDATE_KOTLIN" || \ + -n "$VALIDATE_OPENAPI" ]]; then ANY_SET="true" fi @@ -1094,6 +1115,19 @@ GetValidationInfo() VALIDATE_KOTLIN="true" fi + ####################################### + # Validate if we should check OPENAPI # + ####################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_OPENAPI" ]]; then + # OPENAPI flag was not set - default to false + VALIDATE_OPENAPI="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_OPENAPI="true" + fi ####################################### # Print which linters we are enabling # @@ -1208,6 +1242,11 @@ GetValidationInfo() else PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...") fi + if [[ "$VALIDATE_OPENAPI" == "true" ]]; then + PRINT_ARRAY+=("- Validating [OPENAPI] files in code base...") + else + PRINT_ARRAY+=("- Excluding [OPENAPI] files in code base...") + fi ############################## # Validate Ansible Directory # @@ -1391,6 +1430,12 @@ BuildFileList() # Append the file to the array # ################################ FILE_ARRAY_YML+=("$FILE") + ############################ + # Check if file is OpenAPI # + ############################ + if DetectOpenAPIFile $FILE; then + FILE_ARRAY_OPENAPI+=("$FILE") + fi ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -1403,6 +1448,12 @@ BuildFileList() # Append the file to the array # ################################ FILE_ARRAY_JSON+=("$FILE") + ############################ + # Check if file is OpenAPI # + ############################ + if DetectOpenAPIFile $FILE; then + FILE_ARRAY_OPENAPI+=("$FILE") + fi ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -2122,7 +2173,8 @@ Footer() [ "$ERRORS_FOUND_RUBY" -ne 0 ] || \ [ "$ERRORS_FOUND_CSS" -ne 0 ] || \ [ "$ERRORS_FOUND_ENV" -ne 0 ] || \ - [ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then + [ "$ERRORS_FOUND_KOTLIN" -ne 0 ] || \ + [ "$ERRORS_FOUND_OPENAPI" -ne 0 ]; then # Failed exit echo "Exiting with errors found!" exit 1 @@ -2184,6 +2236,7 @@ RunTestCases() TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" + TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(yml\|yaml\|json\)\$" ################# # Footer prints # @@ -2526,6 +2579,28 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then LintCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi +################### +# OPENAPI LINTING # +################### +if [ "$VALIDATE_OPENAPI" == "true" ]; then + # If we are validating all codebase we need to build file list because not every yml/json file is an OpenAPI file + if [ "$VALIDATE_ALL_CODEBASE" == "true" ]; then + LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)) + for FILE in "${LIST_FILES[@]}" + do + if DetectOpenAPIFile $FILE; then + FILE_ARRAY_OPENAPI+=("$FILE") + fi + done + fi + + ########################## + # Lint the OpenAPI files # + ########################## + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" "disabledfileext" "${FILE_ARRAY_OPENAPI[@]}" +fi + ########## # Footer # ########## From b80ea7e335ae4c3a18007c3372e6d9b91a87e09d Mon Sep 17 00:00:00 2001 From: danielcompton Date: Thu, 25 Jun 2020 20:06:44 +1200 Subject: [PATCH 11/21] Remove unused binding from good Clojure test file Prevents clj-kondo from warning about an unused binding. --- .automation/test/clojure/clojure_good_1.clj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.automation/test/clojure/clojure_good_1.clj b/.automation/test/clojure/clojure_good_1.clj index 7ea739e1..391f4688 100644 --- a/.automation/test/clojure/clojure_good_1.clj +++ b/.automation/test/clojure/clojure_good_1.clj @@ -7,8 +7,7 @@ (str/join "" "") (defn foo-fn [x] - (let [y (fn [] (inc x)) - z y] + (let [y (fn [] (inc x))] (y))) (letfn From 37f6828d1ecbb30ef3090caf46cfeb4f1fd3ab61 Mon Sep 17 00:00:00 2001 From: Justin Kalland Date: Thu, 25 Jun 2020 11:49:09 +0200 Subject: [PATCH 12/21] Fix OpenAPI tests being run by JSON & YAML Tests are run by file extension. The [JSON] and [YAML] tests were running the _bad_ [OPENAPI] tests and expecting them to fail. For [OPENAPI] the _bad_ tests are syntactically good JSON/YAML but bad OAS. --- .automation/test/openapi/README.md | 3 ++- .../openapi/{openapi_bad_1.yml => openapi_bad_1.ymlopenapi} | 0 .../openapi/{openapi_bad_2.json => openapi_bad_2.jsonopenapi} | 0 .../openapi/{openapi_good_1.yml => openapi_good_1.ymlopenapi} | 0 .../{openapi_good_2.json => openapi_good_2.jsonopenapi} | 0 lib/linter.sh | 2 +- 6 files changed, 3 insertions(+), 2 deletions(-) rename .automation/test/openapi/{openapi_bad_1.yml => openapi_bad_1.ymlopenapi} (100%) rename .automation/test/openapi/{openapi_bad_2.json => openapi_bad_2.jsonopenapi} (100%) rename .automation/test/openapi/{openapi_good_1.yml => openapi_good_1.ymlopenapi} (100%) rename .automation/test/openapi/{openapi_good_2.json => openapi_good_2.jsonopenapi} (100%) diff --git a/.automation/test/openapi/README.md b/.automation/test/openapi/README.md index 8e77fdbf..6f5d2c24 100644 --- a/.automation/test/openapi/README.md +++ b/.automation/test/openapi/README.md @@ -2,7 +2,8 @@ This folder holds the test cases for **OpenAPI**. ## Additional Docs -No Additional information is needed for this test case. +The `_bad_` tests are valid `.yml`/`.json` but invalid OpenAPI specs. +The test extensions used are `.ymlopenapi`/`.jsonopenapi` instead of `.yml`/`.json`. This is to prevent the [YAML] and [JSON] tests from picking them up. ## Good Test Cases The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted. diff --git a/.automation/test/openapi/openapi_bad_1.yml b/.automation/test/openapi/openapi_bad_1.ymlopenapi similarity index 100% rename from .automation/test/openapi/openapi_bad_1.yml rename to .automation/test/openapi/openapi_bad_1.ymlopenapi diff --git a/.automation/test/openapi/openapi_bad_2.json b/.automation/test/openapi/openapi_bad_2.jsonopenapi similarity index 100% rename from .automation/test/openapi/openapi_bad_2.json rename to .automation/test/openapi/openapi_bad_2.jsonopenapi diff --git a/.automation/test/openapi/openapi_good_1.yml b/.automation/test/openapi/openapi_good_1.ymlopenapi similarity index 100% rename from .automation/test/openapi/openapi_good_1.yml rename to .automation/test/openapi/openapi_good_1.ymlopenapi diff --git a/.automation/test/openapi/openapi_good_2.json b/.automation/test/openapi/openapi_good_2.jsonopenapi similarity index 100% rename from .automation/test/openapi/openapi_good_2.json rename to .automation/test/openapi/openapi_good_2.jsonopenapi diff --git a/lib/linter.sh b/lib/linter.sh index 7b90ae32..b23b96e6 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2236,7 +2236,7 @@ RunTestCases() TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" - TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(yml\|yaml\|json\)\$" + TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(ymlopenapi\|jsonopenapi\)\$" ################# # Footer prints # From 79671724a0b0142b773e1387c5ddf75fef2f7638 Mon Sep 17 00:00:00 2001 From: Justin Kalland Date: Thu, 25 Jun 2020 12:21:11 +0200 Subject: [PATCH 13/21] Add OpenAPI to disabling-linters doc --- .github/linters/.openapirc.yml | 9 +++++++++ docs/disabling-linters.md | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .github/linters/.openapirc.yml diff --git a/.github/linters/.openapirc.yml b/.github/linters/.openapirc.yml new file mode 100644 index 00000000..fdf641e1 --- /dev/null +++ b/.github/linters/.openapirc.yml @@ -0,0 +1,9 @@ +--- + +########################## +########################## +## OpenAPI Linter rules ## +########################## +########################## + +extends: spectral:oas diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index c738bdbd..2f36d22d 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -24,6 +24,7 @@ Below are examples and documentation for each language and the various methods t - [CSS](#stylelint) - [ENV](#dotenv-linter) - [Kotlin](#kotlin) +- [OpenAPI](#openapi) @@ -607,3 +608,24 @@ import package.b.* ### ktlint disable entire file - There is currently **No** way to disable rules inline of the file(s) + +-------------------------------------------------------------------------------- + +## OpenAPI +- [spectral](https://github.com/stoplightio/spectral) + +### OpenAPI Config file +- `.github/linters/.openapirc.yml` +- You can add, extend, and disable rules +- Documentation at [Spectral Custom Rulesets](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/guides/4-custom-rulesets.md) +- File should be located at: `.github/linters/.openapirc.yml` + +### OpenAPI disable single line +- There is currently **No** way to disable rules inline of the file(s) + +### OpenAPI disable code block +- There is currently **No** way to disable rules inline of the file(s) + +### OpenAPI disable entire file +- There is currently **No** way to disable rules inline of the file(s) +- However, you can make [rule exceptions](https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/guides/6-exceptions.md?srn=gh/stoplightio/spectral/docs/guides/6-exceptions.md) in the config for individual file(s). From ce9b8526f85bd248fa4fe0167ccbdce89557f94e Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Thu, 25 Jun 2020 16:56:06 -0400 Subject: [PATCH 14/21] Proactively add GitHub markdown emojis --- .github/actions/spelling/allow/emoji.txt | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/actions/spelling/allow/emoji.txt diff --git a/.github/actions/spelling/allow/emoji.txt b/.github/actions/spelling/allow/emoji.txt new file mode 100644 index 00000000..5b4b2b08 --- /dev/null +++ b/.github/actions/spelling/allow/emoji.txt @@ -0,0 +1,48 @@ +abcd +bangbang +bento +bullettrain +busstop +cn +couplekiss +dango +dvd +facepunch +feelsgood +finnadie +fuelpump +gb +goberserk +godmode +gua +hankey +heartpulse +hocho +hurtrealbad +icecream +inbox +iphone +izakaya +jp +keycap +mega +minidisc +moyai +neckbeard +octocat +oden +ramen +ru +scorpius +shipit +snowboarder +tada +tanabata +thumbsdown +thumbsup +tophat +trollface +tshirt +uk +vhs +zzz From 116698b03237fed27fa86ab9e4ebc1e4ac1266e0 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 26 Jun 2020 08:26:36 -0500 Subject: [PATCH 15/21] fixed linting errors --- lib/linter.sh | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index a89bb3fe..06bc0022 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -573,10 +573,33 @@ LintAnsibleFiles() #### Function DetectOpenAPIFile ################################################ DetectOpenAPIFile() { - egrep '"openapi":|"swagger":|^openapi:|^swagger:' $GITHUB_WORKSPACE/$1 > /dev/null - if [ $? -eq 0 ]; then + ################ + # Pull in vars # + ################ + FILE="$1" + + ############################### + # Check the file for keywords # + ############################### + egrep '"openapi":|"swagger":|^openapi:|^swagger:' "$GITHUB_WORKSPACE/$FILE" > /dev/null + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ $ERROR_CODE -eq 0 ]; then + ######################## + # Found string in file # + ######################## return 0 else + ################### + # No string match # + ################### return 1 fi } @@ -1460,7 +1483,7 @@ BuildFileList() ############################ # Check if file is OpenAPI # ############################ - if DetectOpenAPIFile $FILE; then + if DetectOpenAPIFile "$FILE"; then FILE_ARRAY_OPENAPI+=("$FILE") fi ########################################################## @@ -1478,7 +1501,7 @@ BuildFileList() ############################ # Check if file is OpenAPI # ############################ - if DetectOpenAPIFile $FILE; then + if DetectOpenAPIFile "$FILE"; then FILE_ARRAY_OPENAPI+=("$FILE") fi ########################################################## @@ -2640,7 +2663,7 @@ if [ "$VALIDATE_OPENAPI" == "true" ]; then LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)) for FILE in "${LIST_FILES[@]}" do - if DetectOpenAPIFile $FILE; then + if DetectOpenAPIFile "$FILE"; then FILE_ARRAY_OPENAPI+=("$FILE") fi done From 063e48d9c4926a8353973adc9703bd2a143bfc7e Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Fri, 26 Jun 2020 08:35:36 -0500 Subject: [PATCH 16/21] Remove spell-checker --- .github/actions/spelling/allow/Dockerfile.txt | 7 - .../spelling/allow/cleanup-docker.sh.txt | 1 - .../spelling/allow/disabling-linters.md.txt | 3 - .github/actions/spelling/allow/emoji.txt | 48 ------ .../allow/ghe-api-config-apply.yml.txt | 2 - .../spelling/allow/ghe-config-apply.sh.txt | 2 - .../allow/ghe-initial-configuration.yml.txt | 1 - .../allow/ghe-ldap-configuration.yml.txt | 2 - .github/actions/spelling/allow/gitignore.txt | 8 - .github/actions/spelling/allow/linter.sh.txt | 7 - .github/actions/spelling/allow/main.yml.txt | 8 - .../spelling/allow/settings.json.j2.txt | 4 - .github/actions/spelling/allow/words.txt | 158 ------------------ .github/actions/spelling/excludes.txt | 2 - .github/actions/spelling/expect.txt | 39 ----- .github/actions/spelling/patterns.txt | 7 - .github/workflows/check-spelling.yml | 48 ------ 17 files changed, 347 deletions(-) delete mode 100644 .github/actions/spelling/allow/Dockerfile.txt delete mode 100644 .github/actions/spelling/allow/cleanup-docker.sh.txt delete mode 100644 .github/actions/spelling/allow/disabling-linters.md.txt delete mode 100644 .github/actions/spelling/allow/emoji.txt delete mode 100644 .github/actions/spelling/allow/ghe-api-config-apply.yml.txt delete mode 100644 .github/actions/spelling/allow/ghe-config-apply.sh.txt delete mode 100644 .github/actions/spelling/allow/ghe-initial-configuration.yml.txt delete mode 100644 .github/actions/spelling/allow/ghe-ldap-configuration.yml.txt delete mode 100644 .github/actions/spelling/allow/gitignore.txt delete mode 100644 .github/actions/spelling/allow/linter.sh.txt delete mode 100644 .github/actions/spelling/allow/main.yml.txt delete mode 100644 .github/actions/spelling/allow/settings.json.j2.txt delete mode 100644 .github/actions/spelling/allow/words.txt delete mode 100644 .github/actions/spelling/excludes.txt delete mode 100644 .github/actions/spelling/expect.txt delete mode 100644 .github/actions/spelling/patterns.txt delete mode 100644 .github/workflows/check-spelling.yml diff --git a/.github/actions/spelling/allow/Dockerfile.txt b/.github/actions/spelling/allow/Dockerfile.txt deleted file mode 100644 index bb490a92..00000000 --- a/.github/actions/spelling/allow/Dockerfile.txt +++ /dev/null @@ -1,7 +0,0 @@ -musl -nvq -rdoc -setuptools -uninstall -wget -WORKDIR diff --git a/.github/actions/spelling/allow/cleanup-docker.sh.txt b/.github/actions/spelling/allow/cleanup-docker.sh.txt deleted file mode 100644 index 1efe4ad7..00000000 --- a/.github/actions/spelling/allow/cleanup-docker.sh.txt +++ /dev/null @@ -1 +0,0 @@ -alnum diff --git a/.github/actions/spelling/allow/disabling-linters.md.txt b/.github/actions/spelling/allow/disabling-linters.md.txt deleted file mode 100644 index fe1303c8..00000000 --- a/.github/actions/spelling/allow/disabling-linters.md.txt +++ /dev/null @@ -1,3 +0,0 @@ -noqa -toc -todo diff --git a/.github/actions/spelling/allow/emoji.txt b/.github/actions/spelling/allow/emoji.txt deleted file mode 100644 index 5b4b2b08..00000000 --- a/.github/actions/spelling/allow/emoji.txt +++ /dev/null @@ -1,48 +0,0 @@ -abcd -bangbang -bento -bullettrain -busstop -cn -couplekiss -dango -dvd -facepunch -feelsgood -finnadie -fuelpump -gb -goberserk -godmode -gua -hankey -heartpulse -hocho -hurtrealbad -icecream -inbox -iphone -izakaya -jp -keycap -mega -minidisc -moyai -neckbeard -octocat -oden -ramen -ru -scorpius -shipit -snowboarder -tada -tanabata -thumbsdown -thumbsup -tophat -trollface -tshirt -uk -vhs -zzz diff --git a/.github/actions/spelling/allow/ghe-api-config-apply.yml.txt b/.github/actions/spelling/allow/ghe-api-config-apply.yml.txt deleted file mode 100644 index 8d39ee0b..00000000 --- a/.github/actions/spelling/allow/ghe-api-config-apply.yml.txt +++ /dev/null @@ -1,2 +0,0 @@ -configcheck -nohup diff --git a/.github/actions/spelling/allow/ghe-config-apply.sh.txt b/.github/actions/spelling/allow/ghe-config-apply.sh.txt deleted file mode 100644 index 0570567b..00000000 --- a/.github/actions/spelling/allow/ghe-config-apply.sh.txt +++ /dev/null @@ -1,2 +0,0 @@ -args -pid diff --git a/.github/actions/spelling/allow/ghe-initial-configuration.yml.txt b/.github/actions/spelling/allow/ghe-initial-configuration.yml.txt deleted file mode 100644 index a09f0564..00000000 --- a/.github/actions/spelling/allow/ghe-initial-configuration.yml.txt +++ /dev/null @@ -1 +0,0 @@ -initialconfig diff --git a/.github/actions/spelling/allow/ghe-ldap-configuration.yml.txt b/.github/actions/spelling/allow/ghe-ldap-configuration.yml.txt deleted file mode 100644 index 04b1c12f..00000000 --- a/.github/actions/spelling/allow/ghe-ldap-configuration.yml.txt +++ /dev/null @@ -1,2 +0,0 @@ -ldapconfig -openldap diff --git a/.github/actions/spelling/allow/gitignore.txt b/.github/actions/spelling/allow/gitignore.txt deleted file mode 100644 index 6fcb9a9c..00000000 --- a/.github/actions/spelling/allow/gitignore.txt +++ /dev/null @@ -1,8 +0,0 @@ -cov -eslintcache -jscoverage -jspm -nyc -tgz -typings -wscript diff --git a/.github/actions/spelling/allow/linter.sh.txt b/.github/actions/spelling/allow/linter.sh.txt deleted file mode 100644 index 9bd25b2f..00000000 --- a/.github/actions/spelling/allow/linter.sh.txt +++ /dev/null @@ -1,7 +0,0 @@ -cw -Mstrict -printenv -rcfile -tf -tolower -whoami diff --git a/.github/actions/spelling/allow/main.yml.txt b/.github/actions/spelling/allow/main.yml.txt deleted file mode 100644 index 877e71bb..00000000 --- a/.github/actions/spelling/allow/main.yml.txt +++ /dev/null @@ -1,8 +0,0 @@ -Autobots -basemap -cas -cn -crt -rsa -tlsv -tmp diff --git a/.github/actions/spelling/allow/settings.json.j2.txt b/.github/actions/spelling/allow/settings.json.j2.txt deleted file mode 100644 index 7f01269b..00000000 --- a/.github/actions/spelling/allow/settings.json.j2.txt +++ /dev/null @@ -1,4 +0,0 @@ -dotcom -identicons -oauth -timezone diff --git a/.github/actions/spelling/allow/words.txt b/.github/actions/spelling/allow/words.txt deleted file mode 100644 index 0e91754b..00000000 --- a/.github/actions/spelling/allow/words.txt +++ /dev/null @@ -1,158 +0,0 @@ -admiralawkbar -ansible -api -apk -aws -baz -beardofedu -certs -changeset -codebase -CODEOWNERS -coffeelint -coffeescript -collectd -concat -config -configs -css -dest -devops -dirname -dockerfile -dockerfilelint -dockerfilelintrc -dotenv -elif -emails -entrypoint -Errorf -eslint -eslintrc -filetype -func -gcc -getenv -ghe -GHES -ghl -github -globals -golang -golangci -Google -gpg -gql -Grafana -graphql -grep -homepage -hookshot -hostname -hostvars -http -https -hubot -idp -ip -Jani -javascript -jq -json -jsonlint -jwiebalk -JWT -ldap -len -lfs -libxml -linted -linting -loadbalancer -localhost -loglevel -markdownlint -millis -mkdir -nodejs -NONINFRINGEMENT -noproxy -noreply -npm -ntp -opensource -opensourcefriday -perl -plugin -posix -pprint -Prego -prettyjson -Println -probot -px -py -pylint -rb -readlines -README -regex -regexp -resqued -rgba -rien -Rubo -rubocop -saml -screenshots -shellcheck -signup -smtp -snmp -socio -splunk -src -ssh -ssl -sso -stackoverflow -stacktraces -standardjs -stringify -stylelint -stylelintrc -subdomain -subfolders -sudo -sys -syslog -taz -terraform -tflint -tileserver -tls -typeof -ubuntu -udp -uid -undef -uniq -uri -url -urlencode -username -usr -utils -Vape -vnd -webhook -wiki -wildcards -workflow -xml -xmllint -yaml -yamllint -yml -yq -zkoppert diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt deleted file mode 100644 index 549b89c5..00000000 --- a/.github/actions/spelling/excludes.txt +++ /dev/null @@ -1,2 +0,0 @@ -^\.github/linters/ -^TEMPLATES/\.\S* diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt deleted file mode 100644 index 64d9960d..00000000 --- a/.github/actions/spelling/expect.txt +++ /dev/null @@ -1,39 +0,0 @@ -cdxml -changelog -chmod -Dockerhub -EOL -GPR -IAm -icu -jre -kotlin -krb -ktlint -libgcc -libintl -libssl -libstdc -linux -lttng -microsoft -ncurses -nq -openjdk -php -powershell -println -psd -psm -psrc -pssc -psscriptanalyzer -pwsh -rcu -rhc -ry -terminfo -tzdata -userspace -xargs -zlib diff --git a/.github/actions/spelling/patterns.txt b/.github/actions/spelling/patterns.txt deleted file mode 100644 index 5c595e9b..00000000 --- a/.github/actions/spelling/patterns.txt +++ /dev/null @@ -1,7 +0,0 @@ -https?:\S* -# ignore long runs of a single character: -([A-Za-z])\1{3,} -# Any CLI args (-xzf -aef) -\ -\w+\b -# Hex colors (dummy group to not be treated as comment) -(?:#)([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}) diff --git a/.github/workflows/check-spelling.yml b/.github/workflows/check-spelling.yml deleted file mode 100644 index b99524b0..00000000 --- a/.github/workflows/check-spelling.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -#################### -## Check spelling ## -#################### - -# -# Documentation: -# https://help.github.com/en/articles/workflow-syntax-for-github-actions -# - -name: Spell checking -############################# -# Start the job on all push # -############################# -on: - push: - branches-ignore: - - 'master' - -############### -# Set the Job # -############### -jobs: - build: - # Name the Job - name: Spell checking - # Set the agent to run on - runs-on: ubuntu-latest - ################## - # Load all steps # - ################## - steps: - ########################## - # Checkout the code base # - ########################## - - name: Checkout Code - uses: actions/checkout@v2 - - ############################# - # Run check spelling action # - ############################# - - name: Check spelling - uses: check-spelling/check-spelling@0.0.16-alpha - with: - bucket: .github/actions - project: spelling - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 8fdce000bf0a0f18721d169b8dc79503c1c633bd Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 26 Jun 2020 08:44:27 -0500 Subject: [PATCH 17/21] got to catch them all --- lib/linter.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 06bc0022..ca352e6e 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -581,7 +581,7 @@ DetectOpenAPIFile() ############################### # Check the file for keywords # ############################### - egrep '"openapi":|"swagger":|^openapi:|^swagger:' "$GITHUB_WORKSPACE/$FILE" > /dev/null + grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "$GITHUB_WORKSPACE/$FILE" > /dev/null ####################### # Load the error code # @@ -2232,7 +2232,7 @@ Footer() [ "$ERRORS_FOUND_RUBY" -ne 0 ] || \ [ "$ERRORS_FOUND_CSS" -ne 0 ] || \ [ "$ERRORS_FOUND_ENV" -ne 0 ] || \ - [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] \ + [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || \ [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || \ [ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then # Failed exit @@ -2660,6 +2660,7 @@ fi if [ "$VALIDATE_OPENAPI" == "true" ]; then # If we are validating all codebase we need to build file list because not every yml/json file is an OpenAPI file if [ "$VALIDATE_ALL_CODEBASE" == "true" ]; then + # shellcheck disable=SC2207 LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)) for FILE in "${LIST_FILES[@]}" do From f087775d99b15bf6632bbde557d17e18cab00d8b Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 26 Jun 2020 09:00:28 -0500 Subject: [PATCH 18/21] typo --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index ca352e6e..65b973a1 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -833,7 +833,7 @@ GetValidationInfo() -n "$VALIDATE_CSS" || \ -n "$VALIDATE_ENV" || \ -n "$VALIDATE_CLOJURE" || \ - -n "$VALIDATE_OPENAPI" ]] \ + -n "$VALIDATE_OPENAPI" || \ -n "$VALIDATE_KOTLIN" ]]; then ANY_SET="true" fi From 24234cc73b0f2e4b1362d9faca72a19860ea1a90 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 26 Jun 2020 09:38:41 -0500 Subject: [PATCH 19/21] fixed the open issue --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 65b973a1..a9ebf15e 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2289,7 +2289,7 @@ RunTestCases() TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$" TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$" TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$" - TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" + TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$" TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c $ANSIBLE_LINTER_RULES" "ansible-lint" TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" TestCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" @@ -2626,7 +2626,7 @@ if [ "$VALIDATE_DOCKER" == "true" ]; then # Lint the docker files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}" + LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}" fi ################### From d5724472870a0536250f8821bf8d0c921448b9f8 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 26 Jun 2020 10:38:02 -0500 Subject: [PATCH 20/21] Adding space support --- lib/linter.sh | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 65b973a1..df3241fa 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -132,6 +132,7 @@ RAW_FILE_ARRAY=() # Array of all files that were changed READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors +DEFAULT_IFS="$IFS" # Get the Default IFS for updating ########################## # Array of changed files # @@ -1856,12 +1857,22 @@ LintCodebase() # We have files added to array of files to check LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list else + ############################################################################### + # Set the file seperator to newline to allow for grabbing objects with spaces # + ############################################################################### + IFS=$'\n' + ################################# # Get list of all files to lint # ################################# # shellcheck disable=SC2207,SC2086 LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex "$FILE_EXTENSIONS" 2>&1)) + ########################### + # Set IFS back to default # + ########################### + IFS="$DEFAULT_IFS" + ############################################################ # Set it back to empty if loaded with blanks from scanning # ############################################################ @@ -2028,11 +2039,21 @@ TestCodebase() # shellcheck disable=SC2207,SC2086,SC2010 LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; ls ansible/ | grep ".yml" 2>&1)) else + ############################################################################### + # Set the file seperator to newline to allow for grabbing objects with spaces # + ############################################################################### + IFS=$'\n' + ################################# # Get list of all files to lint # ################################# # shellcheck disable=SC2207,SC2086 LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; find . -type f -regex "$FILE_EXTENSIONS" ! -path "*./ansible*" 2>&1)) + + ########################### + # Set IFS back to default # + ########################### + IFS="$DEFAULT_IFS" fi ################## @@ -2289,7 +2310,7 @@ RunTestCases() TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$" TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$" TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$" - TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" + TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$" TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c $ANSIBLE_LINTER_RULES" "ansible-lint" TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" TestCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" @@ -2626,7 +2647,7 @@ if [ "$VALIDATE_DOCKER" == "true" ]; then # Lint the docker files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}" + LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}" fi ################### @@ -2660,6 +2681,11 @@ fi if [ "$VALIDATE_OPENAPI" == "true" ]; then # If we are validating all codebase we need to build file list because not every yml/json file is an OpenAPI file if [ "$VALIDATE_ALL_CODEBASE" == "true" ]; then + ############################################################################### + # Set the file seperator to newline to allow for grabbing objects with spaces # + ############################################################################### + IFS=$'\n' + # shellcheck disable=SC2207 LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)) for FILE in "${LIST_FILES[@]}" @@ -2668,6 +2694,11 @@ if [ "$VALIDATE_OPENAPI" == "true" ]; then FILE_ARRAY_OPENAPI+=("$FILE") fi done + + ########################### + # Set IFS back to default # + ########################### + IFS="$DEFAULT_IFS" fi ########################## From 1495c3b22cda396ee6e18bf34c75eb1d0c8b6e1e Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Fri, 26 Jun 2020 10:45:43 -0500 Subject: [PATCH 21/21] Add step to ensure release is on marketplace --- .github/CONTRIBUTING.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 253b1933..86d05b97 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -33,9 +33,10 @@ Draft pull requests are also welcome to get feedback early on, or if there is so If you are the current maintainer of this action: 1. Update `README.md` and the wiki to reflect new version number in the example workflow file sections 2. Draft [Release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) with a summarized changelog -3. A GitHub Action will Publish the Docker image to GitHub Package Registry once a Release is created -4. A GitHub Action will Publish the Docker image to Docker Hub once a Release is created -5. Look for approval from [CODEOWNERS](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners) +3. Ensure you check the box for [publishing to the marketplace](https://help.github.com/en/actions/creating-actions/publishing-actions-in-github-marketplace#publishing-an-action) +4. A GitHub Action will Publish the Docker image to GitHub Package Registry once a Release is created +5. A GitHub Action will Publish the Docker image to Docker Hub once a Release is created +6. Look for approval from [CODEOWNERS](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners) ## Resources - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)