From 31efa2eb68bd634ee181b3b09aba99e35fe2305a Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 18 Jun 2020 13:53:45 -0500 Subject: [PATCH 01/92] Changing from Admiralawkbar to github --- .github/workflows/deploy-DEV.yml | 6 +++--- .github/workflows/deploy-PROD.yml | 2 +- .github/workflows/stack-linter.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-DEV.yml b/.github/workflows/deploy-DEV.yml index 35760ab0..4b6975d7 100644 --- a/.github/workflows/deploy-DEV.yml +++ b/.github/workflows/deploy-DEV.yml @@ -48,7 +48,7 @@ jobs: # Set the Env Vars DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - IMAGE_REPO: admiralawkbar/super-linter + IMAGE_REPO: github/super-linter DOCKERFILE_PATH: Dockerfile shell: bash run: .automation/upload-docker.sh @@ -66,5 +66,5 @@ jobs: - name: Run Test Cases shell: bash run: | - docker pull admiralawkbar/super-linter:${BRANCH_NAME} - docker run -e RUN_LOCAL=true -e TEST_CASE_RUN=true -v ${GITHUB_WORKSPACE}:/tmp/lint admiralawkbar/super-linter:${BRANCH_NAME} + docker pull github/super-linter:${BRANCH_NAME} + docker run -e RUN_LOCAL=true -e TEST_CASE_RUN=true -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${BRANCH_NAME} diff --git a/.github/workflows/deploy-PROD.yml b/.github/workflows/deploy-PROD.yml index ab853943..fd39563b 100644 --- a/.github/workflows/deploy-PROD.yml +++ b/.github/workflows/deploy-PROD.yml @@ -45,7 +45,7 @@ jobs: # Set the Env Vars DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - IMAGE_REPO: admiralawkbar/super-linter + IMAGE_REPO: github/super-linter IMAGE_VERSION: latest DOCKERFILE_PATH: Dockerfile shell: bash diff --git a/.github/workflows/stack-linter.yml b/.github/workflows/stack-linter.yml index c6d8c58a..cac0000a 100644 --- a/.github/workflows/stack-linter.yml +++ b/.github/workflows/stack-linter.yml @@ -41,6 +41,6 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: docker://admiralawkbar/super-linter:latest + uses: github/super-linter env: VALIDATE_ALL_CODEBASE: false From d5d29c2ac9dfa33a720397f66d44918c72decc7e Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 18 Jun 2020 14:02:54 -0500 Subject: [PATCH 02/92] more updates --- .automation/upload-docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index 36c8dd02..e6f42be1 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -5,6 +5,7 @@ ################################################################################ # NOTES: This script is used to upload a Dockerfile to DockerHub +# under the GitHub organization # Its based on being built from a GitHub Action, but could be easily updated # To be ran in a different medium. # From 3764738cee4f6a16e53e064f5a541ae6ad65e39a Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 18 Jun 2020 14:06:05 -0500 Subject: [PATCH 03/92] fixed version --- .github/workflows/stack-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stack-linter.yml b/.github/workflows/stack-linter.yml index cac0000a..dea3d9a3 100644 --- a/.github/workflows/stack-linter.yml +++ b/.github/workflows/stack-linter.yml @@ -41,6 +41,6 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: github/super-linter + uses: github/super-linter@v2.0.0 env: VALIDATE_ALL_CODEBASE: false From eb9f7498f852c6659e78fd92f8e2d14f8a62efc6 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 18 Jun 2020 14:09:33 -0500 Subject: [PATCH 04/92] using the built container and not the repo --- .github/workflows/stack-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stack-linter.yml b/.github/workflows/stack-linter.yml index dea3d9a3..5db00510 100644 --- a/.github/workflows/stack-linter.yml +++ b/.github/workflows/stack-linter.yml @@ -41,6 +41,6 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: github/super-linter@v2.0.0 + uses: docker://github/super-linter:latest env: VALIDATE_ALL_CODEBASE: false From be35583eab5aa85c8ee715275ac7c2e6825330a3 Mon Sep 17 00:00:00 2001 From: SangND Date: Fri, 19 Jun 2020 02:10:08 +0700 Subject: [PATCH 05/92] README: fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2fd43bf2..35fe49c8 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ jobs: ## Environment variables The super-linter allows you to pass the following `ENV` variables to be able to trigger different functionality. -*Note:* All the `VALIDATE_[LANGAUGE]` variables behave in a specific way. +*Note:* All the `VALIDATE_[LANGUAGE]` variables behave in a specific way. If none of them are passed, then they all default to true. However if any one of the variables are set, we default to leaving any unset variable to false. This means that if you run the linter "out of the box", all langauges will be checked. From 976bc9c852a50d4d24074950f68a810ed6774433 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:12:41 -0400 Subject: [PATCH 06/92] Add environment variable for disabling errors --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 89eab906..bd8bce43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -125,7 +125,8 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ RUN_LOCAL=${RUN_LOCAL} \ TEST_CASE_RUN=${TEST_CASE_RUN} \ - ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} + ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ + DISABLE_ERRORS=${DISABLE_ERRORS} ############################# # Copy scripts to container # From e957ebf359ff32cc75575aa54ace13d26b666bfa Mon Sep 17 00:00:00 2001 From: Antoine Leblanc Date: Thu, 18 Jun 2020 21:14:22 +0200 Subject: [PATCH 07/92] Apply valid syntax to CODEOWNERS file see: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax Signed-off-by: Antoine Leblanc --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6606d7fd..c70dda77 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ ###################################################################### # These owners will be the default owners for everything in the repo # ###################################################################### -* @admiralawkbar, @jwiebalk, @zkoppert \ No newline at end of file +* @admiralawkbar @jwiebalk @zkoppert \ No newline at end of file From 4d2b216eaf25247d5fd6500feb8d3af1e42e434c Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:17:59 -0400 Subject: [PATCH 08/92] Add variable and default --- lib/linter.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/linter.sh b/lib/linter.sh index 4ea4461b..92897eec 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -89,6 +89,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 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 ############## # Debug Vars # @@ -108,6 +109,7 @@ DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugg 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 +DEFULAT_DISABLE_ERRORS='false' # Default to enabling errors ########################## # Array of changed files # From 2338c2c98ed3e43c9affd508bd1314600993f262 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:22:13 -0400 Subject: [PATCH 09/92] Parse DEFAULT_ERRORS variable --- lib/linter.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/linter.sh b/lib/linter.sh index 92897eec..4188f6af 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1096,6 +1096,30 @@ GetValidationInfo() # Set the value ANSIBLE_DIRECTORY="$TEMP_ANSIBLE_DIRECTORY" fi + + ############################### + # Get the disable errors flag # + ############################### + if [ -z "$DISABLE_ERRORS" ]; then + ################################## + # No flag passed, set to default # + ################################## + DISABLE_ERRORS="$DEFAULT_DISABLE_ERRORS" + fi + + ############################### + # Convert string to lowercase # + ############################### + DSIABLE_ERRORS=$(echo "$DISABLE_ERRORS" | awk '{print tolower($0)}') + + ############################ + # Set to false if not true # + ############################ + if [ "$DISABLE_ERRORS" != "true" ]; then + ACTIONS_RUNNER_DEBUG="false" + fi + + ############################ # Get the run verbose flag # From ff19ebe77d28621cc482b3a028da6d739d384dcc Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:24:47 -0400 Subject: [PATCH 10/92] exit early if errors are disabled --- lib/linter.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/linter.sh b/lib/linter.sh index 4188f6af..f72f3e03 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1895,6 +1895,14 @@ Footer() fi done + ################################## + # Exit with 0 if errors disabled # + ################################## + + if ${ERRORS_DISABLED} then + exit 0 + fi + ############################### # Exit with 1 if errors found # ############################### From cf8b1eddfe41db50e98843e07c71796b3af5940b Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:25:54 -0400 Subject: [PATCH 11/92] Update lib/linter.sh --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index f72f3e03..021fa960 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1116,7 +1116,7 @@ GetValidationInfo() # Set to false if not true # ############################ if [ "$DISABLE_ERRORS" != "true" ]; then - ACTIONS_RUNNER_DEBUG="false" + DISABLE_ERRORS="false" fi From 49c6b4fa7d7be72438a9a6c6cc437a2b542a1e28 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 15:26:21 -0400 Subject: [PATCH 12/92] Update lib/linter.sh --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 021fa960..5c81665f 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1899,7 +1899,7 @@ Footer() # Exit with 0 if errors disabled # ################################## - if ${ERRORS_DISABLED} then + if ${DISABLE_ERRORS} then exit 0 fi From b9055439d3f148d68d714eae8996445336c11246 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Thu, 18 Jun 2020 14:42:33 -0500 Subject: [PATCH 13/92] more language --- .automation/cleanup-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index ab333098..77b86ab3 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -1,7 +1,7 @@ #!/bin/bash ################################################################################ -############# Cleanup Container on DockerHub @admiralawkbar #################### +############# Cleanup Image on DockerHub @admiralawkbar ######################## ################################################################################ # NOTES: This script is used to remove a tagged image on DockerHub From 64189078119d28bd7a98c87ea1a9d4770407c03e Mon Sep 17 00:00:00 2001 From: Roy Date: Thu, 18 Jun 2020 22:13:20 +0200 Subject: [PATCH 14/92] docs(readme): fix typo languages --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35fe49c8..f60cdaad 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ The super-linter allows you to pass the following `ENV` variables to be able to *Note:* All the `VALIDATE_[LANGUAGE]` variables behave in a specific way. If none of them are passed, then they all default to true. However if any one of the variables are set, we default to leaving any unset variable to false. -This means that if you run the linter "out of the box", all langauges will be checked. +This means that if you run the linter "out of the box", all languages will be checked. But if you wish to select specific linters, we give you full control to choose which linters are run, and won't run anything unexpected. From 2ab14d961b3dfa0b7528d30529d7bfbe106d0384 Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Thu, 18 Jun 2020 13:23:45 -0700 Subject: [PATCH 15/92] Update README to indicate support for non-master defaults --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35fe49c8..681796d9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository is for the **GitHub Action** to run a **Super-Linter**. It is a simple combination of various linters, written in `bash`, to help validate your source code. The end goal of this tool: -- Prevent broken code from being uploaded to *master* branches +- Prevent broken code from being uploaded to the default branch (Usually `master`) branches - Help establish coding best practices across multiple languages - Build guidelines for code layout and format - Automate the process to help streamline code reviews From 95af99a134d4cf50be67f4f856e14f7a32506e61 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 16:47:05 -0400 Subject: [PATCH 16/92] Update lib/linter.sh --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 5c81665f..719aa9e0 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -109,7 +109,7 @@ DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugg 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 -DEFULAT_DISABLE_ERRORS='false' # Default to enabling errors +DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors ########################## # Array of changed files # From dc881c2d1ab3196175244032eceb3a92d24d535c Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 18 Jun 2020 16:47:52 -0400 Subject: [PATCH 17/92] Update lib/linter.sh --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 719aa9e0..6fa50fae 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1110,7 +1110,7 @@ GetValidationInfo() ############################### # Convert string to lowercase # ############################### - DSIABLE_ERRORS=$(echo "$DISABLE_ERRORS" | awk '{print tolower($0)}') + DISABLE_ERRORS=$(echo "$DISABLE_ERRORS" | awk '{print tolower($0)}') ############################ # Set to false if not true # From 33c2dd57f7de2300b5418a6966262bad9238d430 Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Thu, 18 Jun 2020 14:04:41 -0700 Subject: [PATCH 18/92] Update explicit references to master Wherever the script previously used the master branch, we now substitute our DEFAULT_BRANCH variable. We also create this variable at the beginning of the script, and default it to master if no value was passed in. --- Dockerfile | 1 + lib/linter.sh | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 89eab906..84e50039 100644 --- a/Dockerfile +++ b/Dockerfile @@ -104,6 +104,7 @@ RUN curl -Ls "$(curl -Ls https://api.github.com/repos/terraform-linters/tflint/r ENV GITHUB_SHA=${GITHUB_SHA} \ GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \ GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ + DEFAULT_BRANCH=${DEFAULT_BRANCH} \ VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \ VALIDATE_YAML=${VALIDATE_YAML} \ VALIDATE_JSON=${VALIDATE_JSON} \ diff --git a/lib/linter.sh b/lib/linter.sh index 4ea4461b..624bb9b7 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -69,6 +69,7 @@ LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RUBY' 'PYTHON' GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default) ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language @@ -1154,10 +1155,10 @@ BuildFileList() echo "Pulling in code history and branches..." fi - ##################################################################### - # Switch codebase back to master to get a list of all files changed # - ##################################################################### - SWITCH_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git pull --quiet; git checkout master 2>&1) + ################################################################################# + # Switch codebase back to the default branch to get a list of all files changed # + ################################################################################# + SWITCH_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git pull --quiet; git checkout "$DEFAULT_BRANCH" 2>&1) ####################### # Load the error code # @@ -1169,7 +1170,7 @@ BuildFileList() ############################## if [ $ERROR_CODE -ne 0 ]; then # Error - echo "Failed to switch to master branch to get files changed!" + echo "Failed to switch to $DEFAULT_BRANCH branch to get files changed!" echo "ERROR:[$SWITCH_CMD]" exit 1 fi @@ -1180,14 +1181,14 @@ BuildFileList() if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then echo "" echo "----------------------------------------------" - echo "Generating Diff with:[git diff --name-only 'master..$GITHUB_SHA' --diff-filter=d]" + echo "Generating Diff with:[git diff --name-only '$DEFAULT_BRANCH..$GITHUB_SHA' --diff-filter=d]" fi ################################################ # Get the Array of files changed in the comits # ################################################ # shellcheck disable=SC2207 - RAW_FILE_ARRAY=($(cd "$GITHUB_WORKSPACE" || exit; git diff --name-only "master..$GITHUB_SHA" --diff-filter=d 2>&1)) + RAW_FILE_ARRAY=($(cd "$GITHUB_WORKSPACE" || exit; git diff --name-only "$DEFAULT_BRANCH..$GITHUB_SHA" --diff-filter=d 2>&1)) ####################### # Load the error code # @@ -1910,7 +1911,7 @@ RunTestCases() { # This loop will run the test cases and exclude user code # This is called from the automation process to validate new code - # When a PR is opened, the new code is validated with the master branch + # When a PR is opened, the new code is validated with the default branch # version of linter.sh, and a new container is built with the latest codebase # for testing. That container is spun up, and ran, # with the flag: TEST_CASE_RUN=true From f4153396ae3f5d607eefb8dcb1140d64195250a0 Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Thu, 18 Jun 2020 14:06:52 -0700 Subject: [PATCH 19/92] Add documentation for the flag --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 681796d9..b7c8809f 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ and won't run anything unexpected. | **ENV VAR** | **Default Value** | **Notes** | | --- | --- | --- | | **VALIDATE_ALL_CODEBASE** | `true` | Will parse the entire repository and find all files to validate across all types. **NOTE:** When set to `false`, only **new** or **edited** files will be parsed for validation. | +| **DEFAULT_BRANCH** | `master` | The name of the repository default branch. | | **VALIDATE_YAML** | `true` |Flag to enable or disable the linting process of the language. | | **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_XML** | `true` | Flag to enable or disable the linting process of the language. | From 41deecee1576e86169e2a7a6d892e1093459150d Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Thu, 18 Jun 2020 16:29:06 -0500 Subject: [PATCH 20/92] update coffeelint --- Dockerfile | 4 ++-- README.md | 2 +- docs/disabling-linters.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 89eab906..ff8496b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ RUN npm config set package-lock false \ && npm -g --no-cache install \ markdownlint-cli \ jsonlint prettyjson \ - coffeelint \ + @coffeelint/cli \ typescript eslint \ standard \ babel-eslint \ @@ -53,7 +53,7 @@ RUN npm config set package-lock false \ && npm --no-cache install \ markdownlint-cli \ jsonlint prettyjson \ - coffeelint \ + @coffeelint/cli \ typescript eslint \ standard \ babel-eslint \ diff --git a/README.md b/README.md index 35fe49c8..cd0a06e9 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | *Language* | *Linter* | | --- | --- | | **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | -| **CoffeeScript** | [coffeelint](http://www.coffeelint.org/) | +| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | | **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | | **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | | **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index a885c9f4..14e5139f 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -319,7 +319,7 @@ Here is more data -------------------------------------------------------------------------------- ## Coffeescript -- [coffeelint](http://www.coffeelint.org/) +- [coffeelint](https://coffeelint.github.io/) ### coffeelint Config file - `.github/linters/.coffee-lint.yml` From c4249ee93aecb3eeed99970c0f615ef751fee3a7 Mon Sep 17 00:00:00 2001 From: Nick Van Wiggeren Date: Thu, 18 Jun 2020 15:27:50 -0700 Subject: [PATCH 21/92] update docs to point to github docker image --- README.md | 2 +- docs/run-linter-locally.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f60cdaad..ef3de4fe 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ You can use the **GitHub** **Super-Linter** *with* or *without* your own persona If you need to disable certain *rules* and *functionality*, you can view [Disable Rules](https://github.com/github/super-linter/blob/master/docs/disabling-linters.md) ## Docker Hub -The **Docker** container that is built from this repository is located at `https://hub.docker.com/r/admiralawkbar/super-linter` +The **Docker** container that is built from this repository is located at `https://hub.docker.com/r/github/super-linter` ## Running Super-Linter locally (troubleshooting/debugging/enhancements) If you find that you need to run super-linter locally, you can follow the documentation at [Running super-linter locally](https://github.com/github/super-linter/blob/master/docs/run-linter-locally.md) diff --git a/docs/run-linter-locally.md b/docs/run-linter-locally.md index 06117349..d552f3f1 100644 --- a/docs/run-linter-locally.md +++ b/docs/run-linter-locally.md @@ -12,13 +12,13 @@ You can follow the link below on how to install and configure **Docker** on your ## Download the latest Super-Linter Docker container - Pull the latest **Docker** container down from **DockerHub** - - `docker pull admiralawkbar/super-linter:latest` + - `docker pull github/super-linter:latest` Once the container has been downloaded to your local environment, you can then begin the process, or running the container against your codebase. ## Run the container Locally - You can run the container locally with the following **Base** flags to run your code: - - `docker run -e RUN_LOCAL=true -v /path/to/local/codebase:/tmp/lint admiralawkbar/super-linter` - - To run against a single file you can use: `docker run -e RUN_LOCAL=true -v /path/to/local/codebase/file:/tmp/lint/file admiralawkbar/super-linter` + - `docker run -e RUN_LOCAL=true -v /path/to/local/codebase:/tmp/lint github/super-linter` + - To run against a single file you can use: `docker run -e RUN_LOCAL=true -v /path/to/local/codebase/file:/tmp/lint/file github/super-linter` - **NOTE:** You need to pass the `RUN_LOCAL` flag to bypass some of the GitHub Actions checks, as well as the mapping of your local codebase to `/tmp/lint` so that the linter can pick up the code - **NOTE:** The flag:`RUN_LOCAL` will set: `VALIDATE_ALL_CODEBASE` to true. This means it will scan **all** the files in the directory you have mapped. If you want to only validate a subset of your codebase, map a folder with only the files you wish to have linted @@ -29,7 +29,7 @@ You can add as many **Additional** flags as needed, documented in [README.md](.. ### Run container and gain access to the command line If you need to run the container locally and gain access to its command line, you can run the following command: -- `docker run -it --entrypoint /bin/bash admiralawkbar/super-linter` +- `docker run -it --entrypoint /bin/bash github/super-linter` - This will drop you in the command line of the docker container for any testing or troubleshooting that may be needed. ### Found issues From e22eb00151aae0a8beda1292790ef918dcc453f8 Mon Sep 17 00:00:00 2001 From: iggy Date: Thu, 18 Jun 2020 16:15:52 -0700 Subject: [PATCH 22/92] Update to latest golangci-lint In setting super-linter up on one of my repo's, I ran into golangci/golangci-lint#827 which is apparently fixed in v1.23.8 (and has improved error messages in v1.24.0). I'm not sure if there's a reason for using the version that is there now, but if the latest doesn't work, please at least update to 1.24.0. Signed-off-by: iggy --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 89eab906..50c5778c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -89,7 +89,7 @@ RUN wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/s ##################### # Install Go Linter # ##################### -ARG GO_VERSION='v1.23.7' +ARG GO_VERSION='v1.27.0' RUN wget -O- -nvq https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s "$GO_VERSION" ################## From 2cf1ae7cd850882e2871c8b3a2667f1faff25032 Mon Sep 17 00:00:00 2001 From: altanstalker Date: Thu, 18 Jun 2020 19:40:41 -0400 Subject: [PATCH 23/92] Add stylelint support to super-linter Added tests Updated readme with usage notes (disabling lines etc) to match existing content --- .automation/test/css/README.md | 13 ++++++ .automation/test/css/css_bad_01.css | 9 ++++ .automation/test/css/css_good_01.css | 22 ++++++++++ .github/linters/.stylelintrc.json | 3 ++ Dockerfile | 7 ++- README.md | 2 + TEMPLATES/.stylelintrc.json | 3 ++ docs/disabling-linters.md | 33 ++++++++++++++ lib/linter.sh | 64 ++++++++++++++++++++++++++-- 9 files changed, 151 insertions(+), 5 deletions(-) create mode 100644 .automation/test/css/README.md create mode 100644 .automation/test/css/css_bad_01.css create mode 100644 .automation/test/css/css_good_01.css create mode 100644 .github/linters/.stylelintrc.json create mode 100644 TEMPLATES/.stylelintrc.json diff --git a/.automation/test/css/README.md b/.automation/test/css/README.md new file mode 100644 index 00000000..04c7121a --- /dev/null +++ b/.automation/test/css/README.md @@ -0,0 +1,13 @@ +# CSS Test Cases +This folder holds the test cases for **CSS**. + +## 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/css/css_bad_01.css b/.automation/test/css/css_bad_01.css new file mode 100644 index 00000000..3c600b36 --- /dev/null +++ b/.automation/test/css/css_bad_01.css @@ -0,0 +1,9 @@ +/* Bad */ +/* Multiline */ +/* Comment */ +.selector-3[type="text"] { + background: linear-gradient(#FFFFFF, rgba(0, 0, 0, 0.8)); + box-sizing: border-box; + display: block; + color: #AAAAAA; +} diff --git a/.automation/test/css/css_good_01.css b/.automation/test/css/css_good_01.css new file mode 100644 index 00000000..a126e5b2 --- /dev/null +++ b/.automation/test/css/css_good_01.css @@ -0,0 +1,22 @@ +/** + * Multi-line comment + */ + +.selector-1, +.selector-2, +.selector-3[type="text"] { + background: linear-gradient(#fff, rgba(0, 0, 0, 0.8)); + box-sizing: border-box; + display: block; + color: #333; +} + +.selector-a, +.selector-b:not(:first-child) { + padding: 10px !important; + top: calc(calc(1em * 2) / 3); +} + +.selector-x { width: 10%; } +.selector-y { width: 20%; } +.selector-z { width: 30%; } diff --git a/.github/linters/.stylelintrc.json b/.github/linters/.stylelintrc.json new file mode 100644 index 00000000..40db42c6 --- /dev/null +++ b/.github/linters/.stylelintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "stylelint-config-standard" +} diff --git a/Dockerfile b/Dockerfile index 89eab906..36e25542 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,8 @@ RUN npm config set package-lock false \ @typescript-eslint/eslint-plugin \ @typescript-eslint/parser \ eslint-plugin-jest \ + stylelint \ + stylelint-config-standard \ && npm --no-cache install \ markdownlint-cli \ jsonlint prettyjson \ @@ -61,7 +63,9 @@ RUN npm config set package-lock false \ eslint-config-prettier \ @typescript-eslint/eslint-plugin \ @typescript-eslint/parser \ - eslint-plugin-jest + eslint-plugin-jest \ + stylelint \ + stylelint-config-standard #################################### # Install dockerfilelint from repo # @@ -122,6 +126,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ VALIDATE_TYPESCRIPT_STANDARD=${VALIDATE_TYPESCRIPT_STANDARD} \ VALIDATE_GO=${VALIDATE_GO} \ VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \ + VALIDATE_CSS=${VALIDATE_CSS} \ ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ RUN_LOCAL=${RUN_LOCAL} \ TEST_CASE_RUN=${TEST_CASE_RUN} \ diff --git a/README.md b/README.md index f60cdaad..85a10a5f 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) | | **CoffeeScript** | [coffeelint](http://www.coffeelint.org/) | +| **CSS** | [stylelint](https://stylelint.io/) | | **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | | **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | | **JavaScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | @@ -130,6 +131,7 @@ and won't run anything unexpected. | **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the language. | | **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. | | **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. | diff --git a/TEMPLATES/.stylelintrc.json b/TEMPLATES/.stylelintrc.json new file mode 100644 index 00000000..40db42c6 --- /dev/null +++ b/TEMPLATES/.stylelintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "stylelint-config-standard" +} diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index a885c9f4..d425f078 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -20,6 +20,7 @@ Below is examples and documentation for each language and the various methods to - [Golang](#golang) - [Dockerfile](#dockerfile) - [Terraform](#terraform) +- [CSS](#stylelint) @@ -511,3 +512,35 @@ alert('foo') - There is currently **No** way to disable rules inline of the file(s) -------------------------------------------------------------------------------- + +## CSS +- [stylelint](https://stylelint.io/) + +### stylelint standard Config file +- `.github/linters/.stylelintrc.json` + +### stylelint disable single line +```css +#id { + /* stylelint-disable-next-line declaration-no-important */ + color: pink !important; +} +``` + +### stylelint disable code block +```css +/* stylelint-disable */ +a {} +/* stylelint-enable */ +``` + +### stylelint disable entire file +- You can disable entire files with the `ignoreFiles` property in `.stylelintrc.json` +```json +{ + "ignoreFiles": [ + "styles/ignored/wildcards/*.css", + "styles/ignored/specific-file.css" + ] +} +``` diff --git a/lib/linter.sh b/lib/linter.sh index 4ea4461b..84ec72b5 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -48,20 +48,25 @@ GO_LINTER_RULES="$DEFAULT_RULES_LOCATION/$GO_FILE_NAME" # Path to th # Terraform Vars TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules +# 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 + ####################################### # Linter array for information prints # ####################################### LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" "pylint" "perl" "rubocop" "coffeelint" "eslint" "standard" - "ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint") + "ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint" + "stylelint") ############################# # 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') + 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS') ################### # GitHub ENV Vars # @@ -88,6 +93,7 @@ VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to val VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language +VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases ############## @@ -128,6 +134,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_CSS=() # Array of files to check ############ # Counters # @@ -149,6 +156,7 @@ ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found 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 ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -725,6 +733,7 @@ GetValidationInfo() VALIDATE_DOCKER=$(echo "$VALIDATE_DOCKER" | awk '{print tolower($0)}') 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)') ################################################ # Determine if any linters were explicitly set # @@ -746,7 +755,8 @@ GetValidationInfo() -n "$VALIDATE_TYPESCRIPT_STANDARD" || \ -n "$VALIDATE_DOCKER" || \ -n "$VALIDATE_GO" || \ - -n "$VALIDATE_TERRAFORM" ]]; then + -n "$VALIDATE_TERRAFORM" || \ + -n "$VALIDATE_CSS" ]]; then ANY_SET="true" fi @@ -988,6 +998,20 @@ GetValidationInfo() VALIDATE_TERRAFORM="true" fi + ################################### + # Validate if we should check CSS # + ################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_CSS" ]]; then + # CSS flag was not set - default to false + VALIDATE_CSS="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_CSS="true" + fi + ####################################### # Print which linters we are enabling # ####################################### @@ -1076,6 +1100,11 @@ GetValidationInfo() else PRINT_ARRAY+=("- Excluding [TERRAFORM] files in code base...") fi + if [[ "$VALIDATE_CSS" == "true" ]]; then + PRINT_ARRAY+=("- Validating [CSS] files in code base...") + else + PRINT_ARRAY+=("- Excluding [CSS] files in code base...") + fi ############################## # Validate Ansible Directory # @@ -1383,6 +1412,15 @@ BuildFileList() # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 + elif [ "$FILE_TYPE" == "css" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CSS+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 elif [ "$FILE" == "Dockerfile" ]; then ################################ # Append the file to the array # @@ -1888,7 +1926,8 @@ Footer() [ "$ERRORS_FOUND_DOCKER" -ne 0 ] || \ [ "$ERRORS_FOUND_GO" -ne 0 ] || \ [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || \ - [ "$ERRORS_FOUND_RUBY" -ne 0 ]; then + [ "$ERRORS_FOUND_RUBY" -ne 0 ] || \ + [ "$ERRORS_FOUND_CSS" -ne 0 ]; then # Failed exit echo "Exiting with errors found!" exit 1 @@ -1945,6 +1984,7 @@ RunTestCases() TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" 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\)\$" ################# # Footer prints # @@ -1999,6 +2039,8 @@ GetLinterRules "$GO_FILE_NAME" "$GO_LINTER_RULES" GetLinterRules "$DOCKER_FILE_NAME" "$DOCKER_LINTER_RULES" # Get Terraform rules GetLinterRules "$TERRAFORM_FILE_NAME" "$TERRAFORM_LINTER_RULES" +# Get CSS rules +GetLinterRules "$CSS_FILE_NAME" "$CSS_LINTER_RULES" ################################# # Check if were in verbose mode # @@ -2214,6 +2256,20 @@ if [ "$VALIDATE_TYPESCRIPT_STANDARD" == "true" ]; then LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}" fi +############### +# CSS LINTING # +############### +if [ "$VALIDATE_CSS" == "true" ]; then + ################################# + # Get CSS standard rules # + ################################# + GetStandardRules "stylelint" + ############################# + # Lint the CSS files # + ############################# + LintCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" "${FILE_ARRAY_CSS[@]}" +fi + ################## # DOCKER LINTING # ################## From fd416152eb24eacbc11afd824fd7a24ed8aa4b04 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Thu, 18 Jun 2020 22:27:23 -0700 Subject: [PATCH 24/92] Update README.md Co-authored-by: Philip Mallegol-Hansen --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1981b2fa..6391bb73 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository is for the **GitHub Action** to run a **Super-Linter**. It is a simple combination of various linters, written in `bash`, to help validate your source code. The end goal of this tool: -- Prevent broken code from being uploaded to the default branch (Usually `master`) branches +- Prevent broken code from being uploaded to the default branch (Usually `master`) - Help establish coding best practices across multiple languages - Build guidelines for code layout and format - Automate the process to help streamline code reviews From 2751fb19a97a61b3c61921cd2545bd1e2f46daa3 Mon Sep 17 00:00:00 2001 From: Antoine Leblanc Date: Fri, 19 Jun 2020 07:44:26 +0200 Subject: [PATCH 25/92] Minor brand wording change Rename Github to GitHub. Signed-off-by: Antoine Leblanc --- .automation/cleanup-docker.sh | 4 ++-- .../test/ansible/ghe-initialize/defaults/main.yml | 2 +- .../ghe-initialize/tasks/ghe-initial-configuration.yml | 2 +- .automation/test/python/python_bad_1.py | 2 +- .automation/test/python/python_good_1.py | 2 +- .automation/upload-docker.sh | 4 ++-- Dockerfile | 4 ++-- lib/linter.sh | 10 +++++----- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index 77b86ab3..ba2cb758 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -16,7 +16,7 @@ ########### # Globals # ########### -GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image @@ -32,7 +32,7 @@ Header() { echo "" echo "-------------------------------------------------------" - echo "----- Github Actions remove image from DockerHub ------" + echo "----- GitHub Actions remove image from DockerHub ------" echo "-------------------------------------------------------" echo "" } diff --git a/.automation/test/ansible/ghe-initialize/defaults/main.yml b/.automation/test/ansible/ghe-initialize/defaults/main.yml index 6e8741f0..62e30a3a 100644 --- a/.automation/test/ansible/ghe-initialize/defaults/main.yml +++ b/.automation/test/ansible/ghe-initialize/defaults/main.yml @@ -62,7 +62,7 @@ core_expire_sessions: "false" core_package_version: "null" ####################### -# Default Github Vars # +# Default GitHub Vars # ####################### github_ssl_enabled: "true" github_ssl_tls_mode: "tlsv12" diff --git a/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml b/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml index d078873e..91865d3c 100644 --- a/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml +++ b/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml @@ -74,7 +74,7 @@ ################################### # Set the GHE Admin Password fact # ################################### - - name: Set the Github Admin password fact + - name: Set the GitHub Admin password fact set_fact: github_admin_password: "{{ github_admin_password }}" diff --git a/.automation/test/python/python_bad_1.py b/.automation/test/python/python_bad_1.py index 843aad50..369a7224 100644 --- a/.automation/test/python/python_bad_1.py +++ b/.automation/test/python/python_bad_1.py @@ -89,7 +89,7 @@ def delete_label(label_id): Delete the specified label :param label_id: Label's node id. :type label_id: str - :return: Github API request response. + :return: GitHub API request response. """ query_variables = { diff --git a/.automation/test/python/python_good_1.py b/.automation/test/python/python_good_1.py index f808c297..e894c36f 100644 --- a/.automation/test/python/python_good_1.py +++ b/.automation/test/python/python_good_1.py @@ -88,7 +88,7 @@ def delete_label(label_id): Delete the specified label :param label_id: Label's node id. :type label_id: str - :return: Github API request response. + :return: GitHub API request response. """ query_variables = { diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index e6f42be1..644bee8d 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -17,7 +17,7 @@ ########### # Globals # ########### -GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image @@ -33,7 +33,7 @@ Header() { echo "" echo "-------------------------------------------------------" - echo "------ Github Actions Upload image to DockerHub -------" + echo "------ GitHub Actions Upload image to DockerHub -------" echo "-------------------------------------------------------" echo "" } diff --git a/Dockerfile b/Dockerfile index 89eab906..da74a9f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ FROM python:alpine # Label the instance and set maintainer # ######################################### LABEL com.github.actions.name="GitHub Super-Linter" \ - com.github.actions.description="Lint your code base with Github Actions" \ + com.github.actions.description="Lint your code base with GitHub Actions" \ com.github.actions.icon="code" \ com.github.actions.color="red" \ maintainer="GitHub DevOps " @@ -99,7 +99,7 @@ RUN curl -Ls "$(curl -Ls https://api.github.com/repos/terraform-linters/tflint/r && mv "tflint" /usr/bin/ ########################################### -# Load GitHub Env Vars for Github Actions # +# Load GitHub Env Vars for GitHub Actions # ########################################### ENV GITHUB_SHA=${GITHUB_SHA} \ GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \ diff --git a/lib/linter.sh b/lib/linter.sh index 4ea4461b..473f53cd 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -67,8 +67,8 @@ LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RUBY' 'PYTHON' # GitHub ENV Vars # ################### GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit -GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path -GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace +GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # GitHub Event Path +GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language @@ -167,7 +167,7 @@ Header() ########## echo "" echo "---------------------------------------------" - echo "--- Github Actions Multi Language Linter ----" + echo "--- GitHub Actions Multi Language Linter ----" echo "---------------------------------------------" echo "" echo "---------------------------------------------" @@ -1963,9 +1963,9 @@ RunTestCases() Header ####################### -# Get Github Env Vars # +# Get GitHub Env Vars # ####################### -# Need to pull in all the Github variables +# Need to pull in all the GitHub variables # needed to connect back and update checks GetGitHubVars From d20d93fec3068fca5c8d03b31e3f56745a4eeb47 Mon Sep 17 00:00:00 2001 From: Jason Lenny Date: Fri, 19 Jun 2020 11:47:45 +0200 Subject: [PATCH 26/92] Allow for workspace location to be provided by the end user This will give more flexibility to anyone who doesn't happen to keep their files in /tmp/lint. --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 4ea4461b..3ca9dd3d 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -100,7 +100,7 @@ ACTIONS_RUNNER_DEBUG="${ACTIONS_RUNNER_DEBUG}" # Boolean to see even more info # Default Vars # ################ DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files -DEFAULT_WORKSPACE='/tmp/lint' # Default workspace if running locally +DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally DEFAULT_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/ansible" # Default Ansible Directory DEFAULT_RUN_LOCAL='false' # Default value for debugging locally DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases From 14828eb478fbbe843ab1af973d2e2df0578ebb39 Mon Sep 17 00:00:00 2001 From: Jason Lenny Date: Fri, 19 Jun 2020 11:50:35 +0200 Subject: [PATCH 27/92] Add environment variable for running locally --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ef3de4fe..8e584d75 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ and won't run anything unexpected. | **VALIDATE_TERRAFORM** | `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. | ### Template rules files You can use the **GitHub** **Super-Linter** *with* or *without* your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level. From 248c421eda0031527e1461095269b4115f79ad8d Mon Sep 17 00:00:00 2001 From: Jason Lenny Date: Fri, 19 Jun 2020 11:52:14 +0200 Subject: [PATCH 28/92] Add instruction to running local page --- docs/run-linter-locally.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/run-linter-locally.md b/docs/run-linter-locally.md index d552f3f1..c28418b4 100644 --- a/docs/run-linter-locally.md +++ b/docs/run-linter-locally.md @@ -20,6 +20,7 @@ Once the container has been downloaded to your local environment, you can then b - `docker run -e RUN_LOCAL=true -v /path/to/local/codebase:/tmp/lint github/super-linter` - To run against a single file you can use: `docker run -e RUN_LOCAL=true -v /path/to/local/codebase/file:/tmp/lint/file github/super-linter` - **NOTE:** You need to pass the `RUN_LOCAL` flag to bypass some of the GitHub Actions checks, as well as the mapping of your local codebase to `/tmp/lint` so that the linter can pick up the code + - **NOTE:** If you want to override the `/tmp/lint` folder, you can set the `DEFAULT_WORKSPACE` environment variable to point to the folder you'd prefer to scan. - **NOTE:** The flag:`RUN_LOCAL` will set: `VALIDATE_ALL_CODEBASE` to true. This means it will scan **all** the files in the directory you have mapped. If you want to only validate a subset of your codebase, map a folder with only the files you wish to have linted ### Flags for running Locally From f81547ff33b59d09ddf19dbd85e98493af4e7674 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Fri, 19 Jun 2020 20:46:13 +0900 Subject: [PATCH 29/92] Update the notation of RuboCop RuboCop is the proper notation as below. > **RuboCop** is a Ruby static code analyzer (a.k.a. `linter`) and > code formatter. https://github.com/rubocop-hq/rubocop/blob/v0.85.1/README.md --- README.md | 2 +- docs/disabling-linters.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ef3de4fe..f1dfb044 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) | | **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) | | **Python3** | [pylint](https://www.pylint.org/) | -| **Ruby** | [Rubocop](https://github.com/rubocop-hq/rubocop) | +| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | | **Terraform** | [tflint](https://github.com/terraform-linters/tflint) | | **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index a885c9f4..3adf8bfd 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -26,20 +26,20 @@ Below is examples and documentation for each language and the various methods to -------------------------------------------------------------------------------- ## Ruby -- [Rubocop](https://github.com/rubocop-hq/rubocop) +- [RuboCop](https://github.com/rubocop-hq/rubocop) -### Rubocop Config file +### RuboCop Config file - `.github/linters/.ruby-lint.yml` - You can pass multiple rules and overwrite default rules - File should be located at: `.github/linters/.ruby-lint.yml` -- **Note:** We use the Default **GitHub** Rule set from [Rubocop-GitHub](https://github.com/github/rubocop-github) +- **Note:** We use the Default **GitHub** Rule set from [RuboCop-GitHub](https://github.com/github/rubocop-github) -### Rubocop disable single line +### RuboCop disable single line ```ruby method(argument) # rubocop:disable SomeRule, SomeOtherRule ``` -### Rubocop disable code block +### RuboCop disable code block ```ruby # rubocop:disable This is a long line @@ -47,7 +47,7 @@ var="this is some other stuff" # rubocop:enable ``` -### Rubocop disable entire file +### RuboCop disable entire file If you need to ignore an entire file, you can update the `.github/linters/.ruby-lint.yml` to ignore certain files and locations ```yml From 7ee5d3d66a7e2c9db0bd4710f20833e49c010464 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 06:51:04 -0700 Subject: [PATCH 30/92] Fix Links Links pointed to github-demo which is 404, updated to point to super-linter --- .github/CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 960b4afe..f553dcfc 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -40,6 +40,6 @@ If you are the current maintainer of this action: - [Using Pull Requests](https://help.github.com/articles/about-pull-requests/) - [GitHub Help](https://help.github.com) -[pulls]: https://github.com/github/github-demo-stack/pulls -[pr]: https://github.com/github/github-demo-stack/compare -[fork]: https://github.com/github/github-demo-stack/fork +[pulls]: https://github.com/github/super-linter/pulls +[pr]: https://github.com/github/super-linter/compare +[fork]: https://github.com/github/super-linter/fork From 1cb6bc76d285118aa46e6310df50c64a809e7607 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 19 Jun 2020 10:18:45 -0500 Subject: [PATCH 31/92] fixing docs --- README.md | 4 +++- TEMPLATES/README.md | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 541937e2..9e9ee22e 100644 --- a/README.md +++ b/README.md @@ -93,13 +93,15 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: github/super-linter@v2.0.0 + uses: docker://github/super-linter:v2.0.0 env: VALIDATE_ALL_CODEBASE: false VALIDATE_ANSIBLE: false ... ``` +**NOTE:** Using the line:`uses: docker://github/super-linter:v2.0.0` will pull the image down from **DockerHub** and run the **GitHub Super-Linter**. Using the line: `uses: github/super-linter@v2.0.0` will build and compile the **GitHub Super-Linter** at build time. This can be far more costly in time... + ## Environment variables The super-linter allows you to pass the following `ENV` variables to be able to trigger different functionality. diff --git a/TEMPLATES/README.md b/TEMPLATES/README.md index bcd84269..c1ed7152 100644 --- a/TEMPLATES/README.md +++ b/TEMPLATES/README.md @@ -2,7 +2,5 @@ The files in this folder are template rules for the linters that will run against your code base. If you chose to copy these to your local repository in the directory: `.github/` they will be used at runtime. If they are not present, they will be used by default in the linter run. - - The file(s) will be parsed at run time on the local branch to load all rules needed to run the **Super-Linter** **GitHub** Action. The **GitHub** Action will inform the user via the **Checks API** on the status and success of the process. From df54ef21376c80b507ec13381f600bf989710478 Mon Sep 17 00:00:00 2001 From: Artem Medvedev Date: Fri, 19 Jun 2020 20:32:07 +0300 Subject: [PATCH 32/92] Add dotenv-linter support to super-linter (#173) --- .automation/test/env/README.md | 13 +++++++ .automation/test/env/env_bad_1.env | 5 +++ .automation/test/env/env_good_1.env | 4 +++ Dockerfile | 7 ++++ README.md | 2 ++ docs/disabling-linters.md | 20 +++++++++++ lib/linter.sh | 54 ++++++++++++++++++++++++++--- 7 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 .automation/test/env/README.md create mode 100644 .automation/test/env/env_bad_1.env create mode 100644 .automation/test/env/env_good_1.env diff --git a/.automation/test/env/README.md b/.automation/test/env/README.md new file mode 100644 index 00000000..d2ef659d --- /dev/null +++ b/.automation/test/env/README.md @@ -0,0 +1,13 @@ +# ENV Test Cases +This folder holds the test cases for **ENV**. + +## 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/env/env_bad_1.env b/.automation/test/env/env_bad_1.env new file mode 100644 index 00000000..7361eb11 --- /dev/null +++ b/.automation/test/env/env_bad_1.env @@ -0,0 +1,5 @@ + LOGGER_LEVEL=info +MY_ENV +DB-NAME=testing +DEbUG_hTTP=true +DB_NAME=development diff --git a/.automation/test/env/env_good_1.env b/.automation/test/env/env_good_1.env new file mode 100644 index 00000000..112599ec --- /dev/null +++ b/.automation/test/env/env_good_1.env @@ -0,0 +1,4 @@ +DB_NAME=development +DEBUG_HTTP=true +LOGGER_LEVEL=info +MY_ENV= diff --git a/Dockerfile b/Dockerfile index 7f655c31..04eaa5b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -102,6 +102,12 @@ 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 dotenv-linter # +################## +RUN wget "https://github.com/dotenv-linter/dotenv-linter/releases/latest/download/dotenv-linter-alpine-x86_64.tar.gz" -O - -q | tar -xzf - \ + && mv "dotenv-linter" /usr/bin + ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### @@ -128,6 +134,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ VALIDATE_GO=${VALIDATE_GO} \ VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \ VALIDATE_CSS=${VALIDATE_CSS} \ + VALIDATE_ENV=${VALIDATE_ENV} \ ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ RUN_LOCAL=${RUN_LOCAL} \ TEST_CASE_RUN=${TEST_CASE_RUN} \ diff --git a/README.md b/README.md index b7f5455d..f2d11029 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | | **XML** | [LibXML](http://xmlsoft.org/) | | **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | +| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | ## How to use To use this **GitHub** Action you will need to complete the following: @@ -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_ENV** | `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/docs/disabling-linters.md b/docs/disabling-linters.md index 92187192..00a6a2dd 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -21,6 +21,7 @@ Below is examples and documentation for each language and the various methods to - [Dockerfile](#dockerfile) - [Terraform](#terraform) - [CSS](#stylelint) +- [ENV](#dotenv-linter) @@ -544,3 +545,22 @@ a {} ] } ``` + +-------------------------------------------------------------------------------- + +## ENV +- [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) + +### dotenv-linter Config file +- There is no top level *configuration file* available at this time + +### dotenv-linter disable single line +``` +# Comment line will be ignored +``` + +### dotenv-linter disable code block +- There is currently **No** way to disable rules inline of the file(s) + +### dotenv-linter disable entire file +- There is currently **No** way to disable rules inline of the file(s) diff --git a/lib/linter.sh b/lib/linter.sh index b96f44ec..945caf21 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -59,14 +59,14 @@ 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" "dotenv-linter") ############################# # 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' "ENV") ################### # GitHub ENV Vars # @@ -95,6 +95,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_ENV="${VALIDATE_ENV}" # Boolean to validate language TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases ############## @@ -136,6 +137,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_ARRAY_ENV=() # Array of files to check ############ # Counters # @@ -158,6 +160,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_ENV=0 # Count of errors found ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -735,6 +738,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_ENV=$(echo "$VALIDATE_ENV" | awk '{print tolower($0)') ################################################ # Determine if any linters were explicitly set # @@ -757,7 +761,8 @@ GetValidationInfo() -n "$VALIDATE_DOCKER" || \ -n "$VALIDATE_GO" || \ -n "$VALIDATE_TERRAFORM" || \ - -n "$VALIDATE_CSS" ]]; then + -n "$VALIDATE_CSS" || \ + -n "$VALIDATE_ENV" ]]; then ANY_SET="true" fi @@ -1013,6 +1018,20 @@ GetValidationInfo() VALIDATE_CSS="true" fi + #################################### + # Validate if we should check ENV # + #################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_ENV" ]]; then + # ENV flag was not set - default to false + VALIDATE_ENV="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_ENV="true" + fi + ####################################### # Print which linters we are enabling # ####################################### @@ -1106,6 +1125,11 @@ GetValidationInfo() else PRINT_ARRAY+=("- Excluding [CSS] files in code base...") fi + if [[ "$VALIDATE_ENV" == "true" ]]; then + PRINT_ARRAY+=("- Validating [ENV] files in code base...") + else + PRINT_ARRAY+=("- Excluding [ENV] files in code base...") + fi ############################## # Validate Ansible Directory # @@ -1422,6 +1446,15 @@ BuildFileList() # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 + elif [ "$FILE_TYPE" == "env" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_ENV+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 elif [ "$FILE" == "Dockerfile" ]; then ################################ # Append the file to the array # @@ -1928,7 +1961,8 @@ Footer() [ "$ERRORS_FOUND_GO" -ne 0 ] || \ [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || \ [ "$ERRORS_FOUND_RUBY" -ne 0 ] || \ - [ "$ERRORS_FOUND_CSS" -ne 0 ]; then + [ "$ERRORS_FOUND_CSS" -ne 0 ] || \ + [ "$ERRORS_FOUND_ENV" -ne 0 ]; then # Failed exit echo "Exiting with errors found!" exit 1 @@ -1986,6 +2020,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 "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" ################# # Footer prints # @@ -2271,6 +2306,17 @@ if [ "$VALIDATE_CSS" == "true" ]; then LintCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" "${FILE_ARRAY_CSS[@]}" fi +################ +# ENV LINTING # +################ +if [ "$VALIDATE_ENV" == "true" ]; then + ####################### + # Lint the env files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "${FILE_ARRAY_ENV[@]}" +fi + ################## # DOCKER LINTING # ################## From 2f7f03efe36ee55c6cb58b2a33554f70b2affbf4 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 19 Jun 2020 12:39:08 -0500 Subject: [PATCH 33/92] fixing logic --- lib/linter.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 6fa50fae..01e85333 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1096,7 +1096,7 @@ GetValidationInfo() # Set the value ANSIBLE_DIRECTORY="$TEMP_ANSIBLE_DIRECTORY" fi - + ############################### # Get the disable errors flag # ############################### @@ -1119,8 +1119,6 @@ GetValidationInfo() DISABLE_ERRORS="false" fi - - ############################ # Get the run verbose flag # ############################ @@ -1898,15 +1896,13 @@ Footer() ################################## # Exit with 0 if errors disabled # ################################## - - if ${DISABLE_ERRORS} then + if [ "$DISABLE_ERRORS" == "true" ]; then + echo "WARN! Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]" exit 0 - fi - ############################### # Exit with 1 if errors found # ############################### - if [ "$ERRORS_FOUND_YML" -ne 0 ] || \ + elif [ "$ERRORS_FOUND_YML" -ne 0 ] || \ [ "$ERRORS_FOUND_JSON" -ne 0 ] || \ [ "$ERRORS_FOUND_XML" -ne 0 ] || \ [ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || \ From d5fa264b0def91474e83749540f38b97e3a0f3a2 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 19 Jun 2020 12:40:53 -0500 Subject: [PATCH 34/92] Adding flag to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2fd43bf2..5dff4639 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ and won't run anything unexpected. | **VALIDATE_TERRAFORM** | `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. | ### Template rules files You can use the **GitHub** **Super-Linter** *with* or *without* your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level. From 8409d58d6900954eae648afa6669e49e0895dc94 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 19 Jun 2020 12:59:06 -0500 Subject: [PATCH 35/92] adding fence language --- docs/disabling-linters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 00a6a2dd..0a2af8b6 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -555,7 +555,7 @@ a {} - There is no top level *configuration file* available at this time ### dotenv-linter disable single line -``` +```env # Comment line will be ignored ``` From ca81f52818e84f8fae685da5a09b0fd7ac044a72 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Fri, 19 Jun 2020 20:20:20 +0200 Subject: [PATCH 36/92] Fix typo this repositories -> this repository's --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf28abd1..2e390774 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ and won't run anything unexpected. ### Template rules files You can use the **GitHub** **Super-Linter** *with* or *without* your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level. - Copy **any** or **all** template rules files from `TEMPLATES/` into your repository in the location: `.github/linters/` of your repository - - If your repository does not have rules files, they will fall back to defaults in this repositories `TEMPLATE` folder + - If your repository does not have rules files, they will fall back to defaults in [this repository's `TEMPLATE` folder](https://github.com/github/super-linter/tree/master/TEMPLATES) ## Disabling rules If you need to disable certain *rules* and *functionality*, you can view [Disable Rules](https://github.com/github/super-linter/blob/master/docs/disabling-linters.md) From 37a1605ba023bae727bbb57e29f996fbffe7ddc6 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 19 Jun 2020 13:31:05 -0500 Subject: [PATCH 37/92] Adding it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf28abd1..900996de 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: docker://github/super-linter:v2.0.0 + uses: docker://github/super-linter:v2.1.0 env: VALIDATE_ALL_CODEBASE: false VALIDATE_ANSIBLE: false From 005c8b3fcd9e65c7f0a759a5113cca928bd9344e Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Fri, 19 Jun 2020 13:32:46 -0500 Subject: [PATCH 38/92] another one... --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 900996de..de23b12c 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ jobs: ... ``` -**NOTE:** Using the line:`uses: docker://github/super-linter:v2.0.0` will pull the image down from **DockerHub** and run the **GitHub Super-Linter**. Using the line: `uses: github/super-linter@v2.0.0` will build and compile the **GitHub Super-Linter** at build time. This can be far more costly in time... +**NOTE:** Using the line:`uses: docker://github/super-linter:v2.1.0` will pull the image down from **DockerHub** and run the **GitHub Super-Linter**. Using the line: `uses: github/super-linter@v2.1.0` will build and compile the **GitHub Super-Linter** at build time. This can be far more costly in time... ## Environment variables The super-linter allows you to pass the following `ENV` variables to be able to trigger different functionality. From 5212a5b016b32a96bef00c9e5d9a05effb339d17 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Fri, 19 Jun 2020 11:53:22 -0700 Subject: [PATCH 39/92] More complete release instructions --- .github/CONTRIBUTING.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f553dcfc..e2302dd8 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -31,9 +31,11 @@ Draft pull requests are also welcome to get feedback early on, or if there is so ## Releasing If you are the current maintainer of this action: -1. Update `README.md` to reflect new version number in the suggested workflow file section -2. Draft [Release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) document explaining details of Release -3. Look for approval from [CODEOWNERS](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners) +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. Publish the docker image to GitHub package registry +4. Publish the docker image to Docker Hub +5. 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/) From 871291057e153b96a6869c8645086532c279bfd5 Mon Sep 17 00:00:00 2001 From: Ricardo Fearing Date: Fri, 19 Jun 2020 16:12:20 -0400 Subject: [PATCH 40/92] The word "disable" was misspelled --- TEMPLATES/.yaml-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TEMPLATES/.yaml-lint.yml b/TEMPLATES/.yaml-lint.yml index faccea80..2aa49bd1 100644 --- a/TEMPLATES/.yaml-lint.yml +++ b/TEMPLATES/.yaml-lint.yml @@ -3,7 +3,7 @@ # These are the rules used for # # linting all the yaml files in the stack # # NOTE: # -# You can disble line with: # +# You can disable line with: # # # yamllint disable-line # ########################################### rules: From 2e94f3c355d0b8b343387048ab63c4db77db7de0 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 15:10:34 +0000 Subject: [PATCH 41/92] Feat: Add Powershell to DockerFile --- Dockerfile | 321 +++++++++++++++++++++++++++++------------------------ 1 file changed, 178 insertions(+), 143 deletions(-) diff --git a/Dockerfile b/Dockerfile index da74a9f9..67c5d15f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,143 +1,178 @@ -########################################### -########################################### -## Dockerfile to run GitHub Super-Linter ## -########################################### -########################################### - -################## -# Get base image # -################## -FROM python:alpine - -######################################### -# Label the instance and set maintainer # -######################################### -LABEL com.github.actions.name="GitHub Super-Linter" \ - com.github.actions.description="Lint your code base with GitHub Actions" \ - com.github.actions.icon="code" \ - com.github.actions.color="red" \ - maintainer="GitHub DevOps " - -#################### -# Run APK installs # -#################### -RUN apk add --no-cache \ - bash git git-lfs musl-dev curl gcc jq file\ - npm nodejs \ - libxml2-utils perl \ - ruby ruby-dev ruby-bundler ruby-rdoc make \ - py3-setuptools ansible-lint \ - go - -##################### -# Run Pip3 Installs # -##################### -RUN pip3 --no-cache-dir install --upgrade --no-cache-dir \ - yamllint pylint yq - -#################### -# Run NPM Installs # -#################### -RUN npm config set package-lock false \ - && npm config set loglevel error \ - && npm -g --no-cache install \ - markdownlint-cli \ - jsonlint prettyjson \ - coffeelint \ - typescript eslint \ - standard \ - babel-eslint \ - @typescript-eslint/eslint-plugin \ - @typescript-eslint/parser \ - eslint-plugin-jest \ - && npm --no-cache install \ - markdownlint-cli \ - jsonlint prettyjson \ - coffeelint \ - typescript eslint \ - standard \ - babel-eslint \ - prettier \ - eslint-config-prettier \ - @typescript-eslint/eslint-plugin \ - @typescript-eslint/parser \ - eslint-plugin-jest - -#################################### -# Install dockerfilelint from repo # -#################################### -RUN git clone https://github.com/replicatedhq/dockerfilelint.git && cd /dockerfilelint && npm install - - # I think we could fix this with path but not sure the language... - # https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md - -#################### -# Run GEM installs # -#################### -RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0 - -# Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default -# We then need to promot the correct verion, uninstall, and fix deps -RUN sh -c 'gem install --default rubocop:0.74.0; yes | gem uninstall rubocop:0.85.1 -a -x -I; gem install rubocop:0.74.0' - -###################### -# Install shellcheck # -###################### -RUN wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv \ - && mv "shellcheck-stable/shellcheck" /usr/bin/ - -##################### -# Install Go Linter # -##################### -ARG GO_VERSION='v1.23.7' -RUN wget -O- -nvq https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s "$GO_VERSION" - -################## -# Install TFLint # -################## -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/ - -########################################### -# Load GitHub Env Vars for GitHub Actions # -########################################### -ENV GITHUB_SHA=${GITHUB_SHA} \ - GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \ - GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ - VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \ - VALIDATE_YAML=${VALIDATE_YAML} \ - VALIDATE_JSON=${VALIDATE_JSON} \ - VALIDATE_XML=${VALIDATE_XML} \ - VALIDATE_MD=${VALIDATE_MD} \ - VALIDATE_BASH=${VALIDATE_BASH} \ - VALIDATE_PERL=${VALIDATE_PERL} \ - VALIDATE_PYTHON=${VALIDATE_PYTHON} \ - VALIDATE_RUBY=${VALIDATE_RUBY} \ - VALIDATE_COFFEE=${VALIDATE_COFFEE} \ - VALIDATE_ANSIBLE=${VALIDATE_ANSIBLE} \ - VALIDATE_DOCKER=${VALIDATE_DOCKER} \ - VALIDATE_JAVASCRIPT_ES=${VALIDATE_JAVASCRIPT_ES} \ - VALIDATE_JAVASCRIPT_STANDARD=${VALIDATE_JAVASCRIPT_STANDARD} \ - VALIDATE_TYPESCRIPT_ES=${VALIDATE_TYPESCRIPT_ES} \ - VALIDATE_TYPESCRIPT_STANDARD=${VALIDATE_TYPESCRIPT_STANDARD} \ - VALIDATE_GO=${VALIDATE_GO} \ - VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \ - ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ - RUN_LOCAL=${RUN_LOCAL} \ - TEST_CASE_RUN=${TEST_CASE_RUN} \ - ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} - -############################# -# Copy scripts to container # -############################# -COPY lib /action/lib - -################################## -# Copy linter rules to container # -################################## -COPY TEMPLATES /action/lib/.automation - -###################### -# Set the entrypoint # -###################### -ENTRYPOINT ["/action/lib/linter.sh"] +########################################### +########################################### +## Dockerfile to run GitHub Super-Linter ## +########################################### +########################################### + +################## +# Get base image # +################## +FROM python:alpine + +######################################### +# Label the instance and set maintainer # +######################################### +LABEL com.github.actions.name="GitHub Super-Linter" \ + com.github.actions.description="Lint your code base with GitHub Actions" \ + com.github.actions.icon="code" \ + com.github.actions.color="red" \ + maintainer="GitHub DevOps " + +#################### +# Run APK installs # +#################### +RUN apk add --no-cache \ + bash git git-lfs musl-dev curl gcc jq file\ + npm nodejs \ + libxml2-utils perl \ + ruby ruby-dev ruby-bundler ruby-rdoc make \ + py3-setuptools ansible-lint \ + go + +##################### +# Run Pip3 Installs # +##################### +RUN pip3 --no-cache-dir install --upgrade --no-cache-dir \ + yamllint pylint yq + +#################### +# Run NPM Installs # +#################### +RUN npm config set package-lock false \ + && npm config set loglevel error \ + && npm -g --no-cache install \ + markdownlint-cli \ + jsonlint prettyjson \ + coffeelint \ + typescript eslint \ + standard \ + babel-eslint \ + @typescript-eslint/eslint-plugin \ + @typescript-eslint/parser \ + eslint-plugin-jest \ + && npm --no-cache install \ + markdownlint-cli \ + jsonlint prettyjson \ + coffeelint \ + typescript eslint \ + standard \ + babel-eslint \ + prettier \ + eslint-config-prettier \ + @typescript-eslint/eslint-plugin \ + @typescript-eslint/parser \ + eslint-plugin-jest + +#################################### +# Install dockerfilelint from repo # +#################################### +RUN git clone https://github.com/replicatedhq/dockerfilelint.git && cd /dockerfilelint && npm install + + # I think we could fix this with path but not sure the language... + # https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md + +#################### +# Run GEM installs # +#################### +RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0 + +# Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default +# We then need to promot the correct verion, uninstall, and fix deps +RUN sh -c 'gem install --default rubocop:0.74.0; yes | gem uninstall rubocop:0.85.1 -a -x -I; gem install rubocop:0.74.0' + +###################### +# Install shellcheck # +###################### +RUN wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv \ + && mv "shellcheck-stable/shellcheck" /usr/bin/ + +##################### +# Install Go Linter # +##################### +ARG GO_VERSION='v1.23.7' +RUN wget -O- -nvq https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s "$GO_VERSION" + +################## +# Install TFLint # +################## +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 Powershell + PSScriptAnalyzer # +######################################### +# Reference: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7 +# Slightly modified to always retrieve latest stable Powershell version +RUN apk add --no-cache \ + ca-certificates \ + less \ + ncurses-terminfo-base \ + krb5-libs \ + libgcc \ + libintl \ + libssl1.1 \ + libstdc++ \ + tzdata \ + userspace-rcu \ + zlib \ + icu-libs \ + curl \ + lttng-ust \ + && \ + mkdir -p /opt/microsoft/powershell/7 \ + && \ + curl -s https://api.github.com/repos/powershell/powershell/releases/latest \ + | grep browser_download_url \ + | grep linux-alpine-x64 \ + | cut -d '"' -f 4 \ + | xargs -n 1 wget -O - \ + | tar -xzC /opt/microsoft/powershell/7 \ + && \ + ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh \ + && \ + pwsh -c 'install-module psscriptanalyzer -force' + + +########################################### +# Load GitHub Env Vars for GitHub Actions # +########################################### +ENV GITHUB_SHA=${GITHUB_SHA} \ + GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \ + GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ + VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \ + VALIDATE_YAML=${VALIDATE_YAML} \ + VALIDATE_JSON=${VALIDATE_JSON} \ + VALIDATE_XML=${VALIDATE_XML} \ + VALIDATE_MD=${VALIDATE_MD} \ + VALIDATE_BASH=${VALIDATE_BASH} \ + VALIDATE_PERL=${VALIDATE_PERL} \ + VALIDATE_PYTHON=${VALIDATE_PYTHON} \ + VALIDATE_RUBY=${VALIDATE_RUBY} \ + VALIDATE_COFFEE=${VALIDATE_COFFEE} \ + VALIDATE_ANSIBLE=${VALIDATE_ANSIBLE} \ + VALIDATE_DOCKER=${VALIDATE_DOCKER} \ + VALIDATE_JAVASCRIPT_ES=${VALIDATE_JAVASCRIPT_ES} \ + VALIDATE_JAVASCRIPT_STANDARD=${VALIDATE_JAVASCRIPT_STANDARD} \ + VALIDATE_TYPESCRIPT_ES=${VALIDATE_TYPESCRIPT_ES} \ + VALIDATE_TYPESCRIPT_STANDARD=${VALIDATE_TYPESCRIPT_STANDARD} \ + VALIDATE_GO=${VALIDATE_GO} \ + VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \ + ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ + RUN_LOCAL=${RUN_LOCAL} \ + TEST_CASE_RUN=${TEST_CASE_RUN} \ + ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} + +############################# +# Copy scripts to container # +############################# +COPY lib /action/lib + +################################## +# Copy linter rules to container # +################################## +COPY TEMPLATES /action/lib/.automation + +###################### +# Set the entrypoint # +###################### +ENTRYPOINT ["/action/lib/linter.sh"] From d39d5c62ff908cf644e6bc287469c063b35ffc35 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 16:13:13 +0000 Subject: [PATCH 42/92] Powershell Initial Commit --- .../test/powershell/powershell_bad_1.ps1 | 14 ++++++++++++ .../test/powershell/powershell_good_1.ps1 | 1 + TEMPLATES/.powershell-psscriptanalyzer.psd1 | 18 +++++++++++++++ lib/linter.sh | 22 ++++++++++++++++--- 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 .automation/test/powershell/powershell_bad_1.ps1 create mode 100644 .automation/test/powershell/powershell_good_1.ps1 create mode 100644 TEMPLATES/.powershell-psscriptanalyzer.psd1 diff --git a/.automation/test/powershell/powershell_bad_1.ps1 b/.automation/test/powershell/powershell_bad_1.ps1 new file mode 100644 index 00000000..f1709a0a --- /dev/null +++ b/.automation/test/powershell/powershell_bad_1.ps1 @@ -0,0 +1,14 @@ +#Plaintext Parameters +function BadFunction { + param( + [String]$Username = 'me', + [String]$Password = 'password' + ) + $Username + $Password + $VariableThatIsNotUsedLater = '5' + try { + 'Empty Catch Block' + } catch {} +} + diff --git a/.automation/test/powershell/powershell_good_1.ps1 b/.automation/test/powershell/powershell_good_1.ps1 new file mode 100644 index 00000000..d762886f --- /dev/null +++ b/.automation/test/powershell/powershell_good_1.ps1 @@ -0,0 +1 @@ +Write-Output "hello world!" \ No newline at end of file diff --git a/TEMPLATES/.powershell-psscriptanalyzer.psd1 b/TEMPLATES/.powershell-psscriptanalyzer.psd1 new file mode 100644 index 00000000..ab462662 --- /dev/null +++ b/TEMPLATES/.powershell-psscriptanalyzer.psd1 @@ -0,0 +1,18 @@ +#Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/markdown/Invoke-ScriptAnalyzer.md#-settings +@{ + #CustomRulePath='path\to\CustomRuleModule.psm1' + #RecurseCustomRulePath='path\of\customrules' + #Severity = @( + # 'Error' + # 'Warning' + #) + #IncludeDefaultRules=$true + #ExcludeRules = @( + # 'PSAvoidUsingWriteHost', + # 'MyCustomRuleName' + #) + #IncludeRules = @( + # 'PSAvoidUsingWriteHost', + # 'MyCustomRuleName' + #) +} \ No newline at end of file diff --git a/lib/linter.sh b/lib/linter.sh index 473f53cd..32687755 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -48,20 +48,24 @@ GO_LINTER_RULES="$DEFAULT_RULES_LOCATION/$GO_FILE_NAME" # Path to th # Terraform Vars TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules +# Powershell Vars +POWERSHELL_FILE_NAME='.powershell-psccriptanalyzer.psd1' # Name of the file +POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Path to the Powershell lint rules + ####################################### # Linter array for information prints # ####################################### LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" "pylint" "perl" "rubocop" "coffeelint" "eslint" "standard" - "ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint") + "ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint" "powershell") ############################# # 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') + 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'POWERSHELL') ################### # GitHub ENV Vars # @@ -88,6 +92,7 @@ VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to val VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language +VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases ############## @@ -2225,7 +2230,18 @@ if [ "$VALIDATE_DOCKER" == "true" ]; then LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}" fi +###################### +# POWERSHELL LINTING # +###################### +if [ "$VALIDATE_POWERSHELL" == "true" ]; then + ############################# + # Lint the powershell files # + ############################# + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -Settings $POWERSHELL_LINTER_RULES -Path' " 'ps[md]?1$' "${FILE_ARRAY_POWERSHELL[@]}" +fi + ########## # Footer # ########## -Footer +Footer \ No newline at end of file From 1e80fc15b5a346a2018d44ef133d42c33eb6e801 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 12:28:27 -0700 Subject: [PATCH 43/92] Additional File Type test cases --- .automation/test/powershell/powershell.psd1 | 3 +++ .automation/test/powershell/powershell.psm1 | 1 + 2 files changed, 4 insertions(+) create mode 100644 .automation/test/powershell/powershell.psd1 create mode 100644 .automation/test/powershell/powershell.psm1 diff --git a/.automation/test/powershell/powershell.psd1 b/.automation/test/powershell/powershell.psd1 new file mode 100644 index 00000000..68432ff9 --- /dev/null +++ b/.automation/test/powershell/powershell.psd1 @@ -0,0 +1,3 @@ +@{ + 'Hello'='World' +} \ No newline at end of file diff --git a/.automation/test/powershell/powershell.psm1 b/.automation/test/powershell/powershell.psm1 new file mode 100644 index 00000000..d762886f --- /dev/null +++ b/.automation/test/powershell/powershell.psm1 @@ -0,0 +1 @@ +Write-Output "hello world!" \ No newline at end of file From 62fe1b7b41bcba53069c95ad8fc11a3d6a4bfbd6 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 12:28:58 -0700 Subject: [PATCH 44/92] Add Powershell to Linter --- lib/linter.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 32687755..81e19a20 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -49,7 +49,7 @@ GO_LINTER_RULES="$DEFAULT_RULES_LOCATION/$GO_FILE_NAME" # Path to th TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules # Powershell Vars -POWERSHELL_FILE_NAME='.powershell-psccriptanalyzer.psd1' # Name of the file +POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Path to the Powershell lint rules @@ -133,6 +133,8 @@ 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 + ############ # Counters # @@ -154,6 +156,7 @@ ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found 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_POWERSHELL=0 # Count of errors found ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -730,6 +733,7 @@ GetValidationInfo() VALIDATE_DOCKER=$(echo "$VALIDATE_DOCKER" | awk '{print tolower($0)}') VALIDATE_GO=$(echo "$VALIDATE_GO" | awk '{print tolower($0)}') VALIDATE_TERRAFORM=$(echo "$VALIDATE_TERRAFORM" | awk '{print tolower($0)}') + VALIDATE_POWERSHELL=$(echo "$VALIDATE_POWERSHELL" | awk '{print tolower($0)}') ################################################ # Determine if any linters were explicitly set # @@ -751,7 +755,9 @@ GetValidationInfo() -n "$VALIDATE_TYPESCRIPT_STANDARD" || \ -n "$VALIDATE_DOCKER" || \ -n "$VALIDATE_GO" || \ - -n "$VALIDATE_TERRAFORM" ]]; then + -n "$VALIDATE_TERRAFORM" || \ + -n "$VALIDATE_POWERSHELL" \ + ]]; then ANY_SET="true" fi @@ -993,6 +999,20 @@ GetValidationInfo() VALIDATE_TERRAFORM="true" fi + ######################################### + # Validate if we should check POWERSHELL # + ######################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_POWERSHELL" ]]; then + # POWERSHELL flag was not set - default to false + VALIDATE_POWERSHELL="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_POWERSHELL="true" + fi + ####################################### # Print which linters we are enabling # ####################################### @@ -1081,6 +1101,11 @@ GetValidationInfo() else PRINT_ARRAY+=("- Excluding [TERRAFORM] files in code base...") fi + if [[ "$VALIDATE_POWERSHELL" == "true" ]]; then + PRINT_ARRAY+=("- Validating [POWERSHELL] files in code base...") + else + PRINT_ARRAY+=("- Excluding [POWERSHELL] files in code base...") + fi ############################## # Validate Ansible Directory # @@ -1388,6 +1413,18 @@ BuildFileList() # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 + ########################### + # Get the Powershell files # + ########################### + elif [ "$FILE_TYPE" == "ps1" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_POWERSHELL+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 elif [ "$FILE" == "Dockerfile" ]; then ################################ # Append the file to the array # @@ -1616,7 +1653,12 @@ LintCodebase() ################################ # Lint the file with the rules # ################################ - LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1) + #Special Handling for Powershell Required + if [ $FILE_TYPE -eq 'POWERSHELL' ];then + + else + LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1) + fi ####################### # Load the error code # @@ -1893,6 +1935,7 @@ Footer() [ "$ERRORS_FOUND_DOCKER" -ne 0 ] || \ [ "$ERRORS_FOUND_GO" -ne 0 ] || \ [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || \ + [ "$ERRORS_FOUND_POWERSHELL" -ne 0 ] || \ [ "$ERRORS_FOUND_RUBY" -ne 0 ]; then # Failed exit echo "Exiting with errors found!" @@ -1950,6 +1993,7 @@ RunTestCases() TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(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 -Settings $POWERSHELL_LINTER_RULES'" ".*\.\(ps\.\*\)\$" ################# # Footer prints # @@ -2004,6 +2048,9 @@ GetLinterRules "$GO_FILE_NAME" "$GO_LINTER_RULES" GetLinterRules "$DOCKER_FILE_NAME" "$DOCKER_LINTER_RULES" # Get Terraform rules GetLinterRules "$TERRAFORM_FILE_NAME" "$TERRAFORM_LINTER_RULES" +# Get Terraform rules +GetLinterRules "$POWERSHELL_FILE_NAME" "$POWERSHELL_LINTER_RULES" + ################################# # Check if were in verbose mode # @@ -2238,7 +2285,7 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # Lint the powershell files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -Settings $POWERSHELL_LINTER_RULES -Path' " 'ps[md]?1$' "${FILE_ARRAY_POWERSHELL[@]}" + LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -Settings $POWERSHELL_LINTER_RULES -Path '" ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi ########## From 507afd74a788f0d289c08c5aa0729e08a49fb681 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 20:51:12 +0000 Subject: [PATCH 45/92] Move to separate pwshlint script for better handling --- lib/linter.sh | 9 ++------- lib/pwshlint.ps1 | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 lib/pwshlint.ps1 diff --git a/lib/linter.sh b/lib/linter.sh index 81e19a20..ca8c5837 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1653,12 +1653,7 @@ LintCodebase() ################################ # Lint the file with the rules # ################################ - #Special Handling for Powershell Required - if [ $FILE_TYPE -eq 'POWERSHELL' ];then - - else - LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1) - fi + LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1) ####################### # Load the error code # @@ -2285,7 +2280,7 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # Lint the powershell files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -Settings $POWERSHELL_LINTER_RULES -Path '" ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" + LintCodebase "POWERSHELL" "/action/lib/pwshlint.ps1" "/action/lib/pwshlint.ps1 $POWERSHELL_LINTER_RULES " ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi ########## diff --git a/lib/pwshlint.ps1 b/lib/pwshlint.ps1 new file mode 100644 index 00000000..8045282e --- /dev/null +++ b/lib/pwshlint.ps1 @@ -0,0 +1,6 @@ +#!/usr/bin/pwsh +param( + [String]$SettingsPath, + [String]$FileToAnalyze +) +Invoke-ScriptAnalyzer -Settings $SettingsPath -Path $FileToAnalyze \ No newline at end of file From 3e4ad2fcdbfd7be9f18cf7b9bd7d9127859bb9d7 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 21:11:40 +0000 Subject: [PATCH 46/92] Enable Exit catch --- lib/pwshlint.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pwshlint.ps1 b/lib/pwshlint.ps1 index 8045282e..a3a7cfd7 100644 --- a/lib/pwshlint.ps1 +++ b/lib/pwshlint.ps1 @@ -3,4 +3,4 @@ param( [String]$SettingsPath, [String]$FileToAnalyze ) -Invoke-ScriptAnalyzer -Settings $SettingsPath -Path $FileToAnalyze \ No newline at end of file +$ScriptAnalyzerResults = Invoke-ScriptAnalyzer -EnableExit -Settings $SettingsPath -Path $FileToAnalyze \ No newline at end of file From f13251355513f7dff2119bfdd5d730f21f591e3d Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Fri, 19 Jun 2020 14:21:23 -0700 Subject: [PATCH 47/92] Add link to wiki for new language support --- .github/ISSUE_TEMPLATE/feature_request.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 11fc491e..670c0420 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -18,3 +18,6 @@ A clear and concise description of any alternative solutions or features you've **Additional context** Add any other context or screenshots about the feature request here. + +**Note** +If this is a request to add a new language, after submitting this issue check out [the wiki](https://github.com/github/super-linter/wiki/Adding-new-language-support) for more info on how to accomplish that. From 79ebca41ac61010ed3ee89e0fbe1c4ea4a5023a2 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Fri, 19 Jun 2020 14:23:15 -0700 Subject: [PATCH 48/92] Remove EOL space --- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 670c0420..caee45bc 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -20,4 +20,4 @@ A clear and concise description of any alternative solutions or features you've Add any other context or screenshots about the feature request here. **Note** -If this is a request to add a new language, after submitting this issue check out [the wiki](https://github.com/github/super-linter/wiki/Adding-new-language-support) for more info on how to accomplish that. +If this is a request to add a new language, after submitting this issue check out [the wiki](https://github.com/github/super-linter/wiki/Adding-new-language-support) for more info on how to accomplish that. From 793ac9b8615387a24ef2c14a3ae8bf51808031e0 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 14:26:06 -0700 Subject: [PATCH 49/92] DOCS: Add Powershell --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f1dfb044..e28f409a 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) | | **XML** | [LibXML](http://xmlsoft.org/) | | **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | +| **Powershell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | ## How to use To use this **GitHub** Action you will need to complete the following: @@ -129,6 +130,7 @@ and won't run anything unexpected. | **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) | | **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the language. | +| **VALIDATE_POWERSHELL** | `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. | | **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. | From ea7a07f1d35af844113ac35a30c39e650462bbdb Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Fri, 19 Jun 2020 16:13:19 -0700 Subject: [PATCH 50/92] Add missing closing curly brackets --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index d57c205c..ca88f558 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -739,8 +739,8 @@ GetValidationInfo() VALIDATE_DOCKER=$(echo "$VALIDATE_DOCKER" | awk '{print tolower($0)}') 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_ENV=$(echo "$VALIDATE_ENV" | awk '{print tolower($0)') + VALIDATE_CSS=$(echo "$VALIDATE_CSS" | awk '{print tolower($0)}') + VALIDATE_ENV=$(echo "$VALIDATE_ENV" | awk '{print tolower($0)}') ################################################ # Determine if any linters were explicitly set # From 111ffcb69136b5f0890737fa5b7cf5121b03d55e Mon Sep 17 00:00:00 2001 From: Eduardo Sebastian Date: Sat, 20 Jun 2020 06:00:01 +0200 Subject: [PATCH 51/92] Fix some typos --- .automation/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.automation/README.md b/.automation/README.md index 76d3b1e4..812c2aae 100644 --- a/.automation/README.md +++ b/.automation/README.md @@ -1,12 +1,12 @@ # .automation This folder holds automation scripts to help `deploy` and `cleanup` **DockerHub** images of the **Super-Linter** -## cleanup-docker.md +## cleanup-docker.sh This script uses **GitHub Actions** so that when a PR is merged and closed, the **GitHub Action** is triggered. It will then search **DockerHub** for the image that was deployed during the development, and remove it. ## upload-docker.sh -This script uses **GitHub Actions** so that a push to the repository is committed, it will complete the following: +This script uses **GitHub Actions** so that when a push to the repository is committed, it will complete the following: - Checkout the source code - Build the **Docker** container for **Super-Linter** using that source code - Upload the container to **DockerHub** @@ -16,7 +16,7 @@ When the script is triggered in a branch, it will push with the tag:**NameOfBran - *testing* - *troubleshooting* - *debugging* -- **Note:** The branch name will be reduced to AlpaNumeric for consistency and uploading +- **Note:** The branch name will be reduced to alphanumeric for consistency and uploading ## test This folder holds all **Test Cases** to help run the *CI/CT/CD* process for the **Super-Linter**. From f5b22dfefd45fa6137d7bb3de05a24dcf1751e49 Mon Sep 17 00:00:00 2001 From: Grachev Mikhail Date: Sat, 20 Jun 2020 11:42:58 +0300 Subject: [PATCH 52/92] Fix typo --- docs/disabling-linters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 0a2af8b6..b972d31c 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -477,7 +477,7 @@ alert('foo') -------------------------------------------------------------------------------- ## Dockerfile --[dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) +- [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) ### Dockerfilelint standard Config file - `.github/linters/.dockerfilelintrc` From 46a1d1eb25a82872c9a41d9f58b9c7415a0d059e Mon Sep 17 00:00:00 2001 From: Antoine Leblanc Date: Sat, 20 Jun 2020 12:18:41 +0200 Subject: [PATCH 53/92] Update anchor for both CSS and Env linter in the table of content Signed-off-by: Antoine Leblanc --- docs/disabling-linters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 0a2af8b6..bb418456 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -20,8 +20,8 @@ Below is examples and documentation for each language and the various methods to - [Golang](#golang) - [Dockerfile](#dockerfile) - [Terraform](#terraform) -- [CSS](#stylelint) -- [ENV](#dotenv-linter) +- [CSS](#css) +- [ENV](#env) From a6c760f672f4527a5de337f65aadd42f8aa9c633 Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Sat, 20 Jun 2020 10:15:07 -0700 Subject: [PATCH 54/92] Advertise newest version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our documentation should probably prompt people to use the version that doesn't contain a bug 😅 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ab2353f1..8e6d6f39 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: docker://github/super-linter:v2.1.0 + uses: docker://github/super-linter:v2.1.1 env: VALIDATE_ALL_CODEBASE: false VALIDATE_ANSIBLE: false From 502883f2245651e783baa15423f06c161084d511 Mon Sep 17 00:00:00 2001 From: Nicholas Chambers Date: Sat, 20 Jun 2020 12:51:24 -0500 Subject: [PATCH 55/92] Turn the pipe operator into the proper or operator --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index ca88f558..d96c55c0 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -223,7 +223,7 @@ GetLinterVersions() ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ] | [ -z "${GET_VERSION_CMD[*]}" ]; then + if [ $ERROR_CODE -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then echo "WARN! Failed to get version info for:[$LINTER]" echo "---------------------------------------------" else From e4fecc1c8d69da71ccdda926050cfdf8bd2fc559 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 20 Jun 2020 23:49:32 -0400 Subject: [PATCH 56/92] spelling: against --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index ca88f558..4874df78 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2018,7 +2018,7 @@ RunTestCases() # version of linter.sh, and a new container is built with the latest codebase # for testing. That container is spun up, and ran, # with the flag: TEST_CASE_RUN=true - # So that the new code can be validated againt the test cases + # So that the new code can be validated against the test cases ################# # Header prints # From 246396b570fe0f270a76d011f5f1de3030d061f4 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 20 Jun 2020 23:50:18 -0400 Subject: [PATCH 57/92] spelling: changeset --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 4874df78..86ce20a4 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1636,7 +1636,7 @@ LintCodebase() if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "$VALIDATE_ALL_CODEBASE" == "false" ]; then # No files found in commit and user has asked to not validate code base SKIP_FLAG=1 - # echo " - No files found in chageset to lint for language:[$FILE_TYPE]" + # echo " - No files found in changeset to lint for language:[$FILE_TYPE]" elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then # We have files added to array of files to check LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list From 44cade916171621afc84af741b3c339d126d3158 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 20 Jun 2020 23:50:46 -0400 Subject: [PATCH 58/92] spelling: commits --- lib/linter.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 86ce20a4..f9b3fbfb 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1261,9 +1261,9 @@ BuildFileList() echo "Generating Diff with:[git diff --name-only '$DEFAULT_BRANCH..$GITHUB_SHA' --diff-filter=d]" fi - ################################################ - # Get the Array of files changed in the comits # - ################################################ + ################################################# + # Get the Array of files changed in the commits # + ################################################# # shellcheck disable=SC2207 RAW_FILE_ARRAY=($(cd "$GITHUB_WORKSPACE" || exit; git diff --name-only "$DEFAULT_BRANCH..$GITHUB_SHA" --diff-filter=d 2>&1)) From f5039368ca473977461511680de661b2a1e3c5a6 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 20 Jun 2020 23:53:07 -0400 Subject: [PATCH 59/92] spelling: commencing --- .automation/test/coffeescript/coffeescript_bad_1.coffee | 2 +- .automation/test/coffeescript/coffeescript_good_1.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.automation/test/coffeescript/coffeescript_bad_1.coffee b/.automation/test/coffeescript/coffeescript_bad_1.coffee index 624cb3cd..5efeeacb 100644 --- a/.automation/test/coffeescript/coffeescript_bad_1.coffee +++ b/.automation/test/coffeescript/coffeescript_bad_1.coffee @@ -60,7 +60,7 @@ module.exports = (robot) -> ) # Drop the hammer # ################### robot.respond /drop the hammer/i, (msg) -> - msg.send "Commmencing the hammer dropping..." + msg.send "Commencing the hammer dropping..." msg.send msg.random dropHammer ############### diff --git a/.automation/test/coffeescript/coffeescript_good_1.coffee b/.automation/test/coffeescript/coffeescript_good_1.coffee index 40bc1264..62f2a4fe 100644 --- a/.automation/test/coffeescript/coffeescript_good_1.coffee +++ b/.automation/test/coffeescript/coffeescript_good_1.coffee @@ -62,7 +62,7 @@ module.exports = (robot) -> # Drop the hammer # ################### robot.respond /drop the hammer/i, (msg) -> - msg.send "Commmencing the hammer dropping..." + msg.send "Commencing the hammer dropping..." msg.send msg.random dropHammer ############### From 6e8aa549cb27e87febc9d5f920131bfbe61d6257 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 20 Jun 2020 23:53:54 -0400 Subject: [PATCH 60/92] spelling: disable --- .github/linters/.yaml-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml index faccea80..2aa49bd1 100644 --- a/.github/linters/.yaml-lint.yml +++ b/.github/linters/.yaml-lint.yml @@ -3,7 +3,7 @@ # These are the rules used for # # linting all the yaml files in the stack # # NOTE: # -# You can disble line with: # +# You can disable line with: # # # yamllint disable-line # ########################################### rules: From 8ec0bd8f61576c876b5eeddf466f7176b418004d Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 20 Jun 2020 23:54:43 -0400 Subject: [PATCH 61/92] spelling: iterate --- lib/linter.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index f9b3fbfb..9fd5af02 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1282,9 +1282,9 @@ BuildFileList() exit 1 fi - ################################################# - # Itterate through the array of all files found # - ################################################# + ################################################ + # Iterate through the array of all files found # + ################################################ echo "" echo "----------------------------------------------" echo "Files that have been modified in the commit(s):" From 566cd3d5574d553e598a1bd62522d146a1f8a464 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 20 Jun 2020 23:55:10 -0400 Subject: [PATCH 62/92] spelling: languages --- lib/linter.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 9fd5af02..4ca5911f 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2075,9 +2075,9 @@ Header # needed to connect back and update checks GetGitHubVars -########################################## -# Get the langugages we need to validate # -########################################## +######################################### +# Get the languages we need to validate # +######################################### GetValidationInfo ######################## From d542dc4d76efa259a95840b3938cf2111652136f Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 20 Jun 2020 23:56:56 -0400 Subject: [PATCH 63/92] spelling: numeric --- .automation/cleanup-docker.sh | 6 +++--- .automation/upload-docker.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index ba2cb758..131daf6a 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -115,9 +115,9 @@ ValidateInput() # Check if we need to get the name of the branch # ################################################## if [[ "$IMAGE_VERSION" != "latest" ]]; then - ################################### - # Remove non alpha-numberic chars # - ################################### + ################################## + # Remove non alpha-numeric chars # + ################################## IMAGE_VERSION=$(echo "$IMAGE_VERSION" | tr -cd '[:alnum:]') else ############################################# diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index 644bee8d..c41adb33 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -120,9 +120,9 @@ ValidateInput() exit 1 fi - ################################### - # Remove non alpha-numberic chars # - ################################### + ################################## + # Remove non alpha-numeric chars # + ################################## BRANCH_NAME=$(echo "$BRANCH_NAME" | tr -cd '[:alnum:]') ############################################ From 64c1dfe67b5304569b5edad72b89a978f0467d56 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 20 Jun 2020 23:57:39 -0400 Subject: [PATCH 64/92] spelling: promote --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a93c72bc..de08dd4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -81,7 +81,7 @@ RUN git clone https://github.com/replicatedhq/dockerfilelint.git && cd /dockerfi RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0 # Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default -# We then need to promot the correct verion, uninstall, and fix deps +# We then need to promote the correct verion, uninstall, and fix deps RUN sh -c 'gem install --default rubocop:0.74.0; yes | gem uninstall rubocop:0.85.1 -a -x -I; gem install rubocop:0.74.0' ###################### From f3b12894a2996f8829c42522ce4065bb055d5501 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sun, 21 Jun 2020 00:00:08 -0400 Subject: [PATCH 65/92] spelling: settings --- .../ansible/ghe-initialize/tasks/collectd-settings.yml | 6 +++--- .../ghe-initialize/tasks/ghe-initial-configuration.yml | 8 ++++---- .../test/ansible/ghe-initialize/tasks/splunk-settings.yml | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.automation/test/ansible/ghe-initialize/tasks/collectd-settings.yml b/.automation/test/ansible/ghe-initialize/tasks/collectd-settings.yml index f6f08485..0c73fc94 100644 --- a/.automation/test/ansible/ghe-initialize/tasks/collectd-settings.yml +++ b/.automation/test/ansible/ghe-initialize/tasks/collectd-settings.yml @@ -42,9 +42,9 @@ group: admin mode: 0644 - ######################################################### - # Set up Admin password, License, and Initial Setttings # - ######################################################### + ######################################################## + # Set up Admin password, License, and Initial Settings # + ######################################################## - name: Setup Grafana # yamllint disable shell: curl --fail -Lk \ diff --git a/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml b/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml index 91865d3c..d44e2101 100644 --- a/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml +++ b/.automation/test/ansible/ghe-initialize/tasks/ghe-initial-configuration.yml @@ -57,10 +57,10 @@ group: admin mode: 0644 - ######################################################### - # Set up Admin password, License, and Initial Setttings # - ######################################################### - - name: Setup License, Admin Password, and Initial Setttings + ######################################################## + # Set up Admin password, License, and Initial Settings # + ######################################################## + - name: Setup License, Admin Password, and Initial Settings command: curl --fail -Lk \ -X POST "https://{{ ansible_host }}:8443/setup/api/start" \ -F license=@/tmp/ghe-license.ghl \ diff --git a/.automation/test/ansible/ghe-initialize/tasks/splunk-settings.yml b/.automation/test/ansible/ghe-initialize/tasks/splunk-settings.yml index 33919111..aaaa0780 100644 --- a/.automation/test/ansible/ghe-initialize/tasks/splunk-settings.yml +++ b/.automation/test/ansible/ghe-initialize/tasks/splunk-settings.yml @@ -42,9 +42,9 @@ group: admin mode: 0644 - ######################################################### - # Set up Admin password, License, and Initial Setttings # - ######################################################### + ######################################################## + # Set up Admin password, License, and Initial Settings # + ######################################################## - name: Setup Splunk # yamllint disable shell: curl --fail -Lk \ From 0408343139e86064e48d8aeb888cd83ba9ae83f1 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sun, 21 Jun 2020 00:00:46 -0400 Subject: [PATCH 66/92] spelling: typescript --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 4ca5911f..2a925646 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -32,7 +32,7 @@ COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to JAVASCRIPT_FILE_NAME='.eslintrc.yml' # Name of the file JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard -# Typecript Vars +# Typescript Vars TYPESCRIPT_FILE_NAME='.eslintrc.yml' # Name of the file TYPESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TYPESCRIPT_FILE_NAME" # Path to the Typescript lint rules TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard From 3bf84dbb9ca86f601618b9b318b5cfd9200a2d0c Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sun, 21 Jun 2020 00:01:16 -0400 Subject: [PATCH 67/92] spelling: version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index de08dd4d..fc6a0212 100644 --- a/Dockerfile +++ b/Dockerfile @@ -81,7 +81,7 @@ RUN git clone https://github.com/replicatedhq/dockerfilelint.git && cd /dockerfi RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0 # Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default -# We then need to promote the correct verion, uninstall, and fix deps +# We then need to promote the correct version, uninstall, and fix deps RUN sh -c 'gem install --default rubocop:0.74.0; yes | gem uninstall rubocop:0.85.1 -a -x -I; gem install rubocop:0.74.0' ###################### From aed53d0ee5aca96103393f41d0a916ef8f9922db Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sun, 21 Jun 2020 00:02:45 -0400 Subject: [PATCH 68/92] spelling: visible --- .automation/test/javascript/javascript_bad_1.js | 2 +- .automation/test/javascript/javascript_good_1.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.automation/test/javascript/javascript_bad_1.js b/.automation/test/javascript/javascript_bad_1.js index 0ed075fc..98e5ee29 100644 --- a/.automation/test/javascript/javascript_bad_1.js +++ b/.automation/test/javascript/javascript_bad_1.js @@ -7,7 +7,7 @@ var userArray = [ 'user1' ] here is some garbage = that var teamDescription = Team of Robots -var teamPrivacy = 'closed' // closed (visibile) / secret (hidden) are options here +var teamPrivacy = 'closed' // closed (visible) / secret (hidden) are options here var teamName = process.env.GHES_TEAM_NAME var teamAccess = 'pull' // pull,push,admin options here diff --git a/.automation/test/javascript/javascript_good_1.js b/.automation/test/javascript/javascript_good_1.js index 09417a6b..ad32089f 100644 --- a/.automation/test/javascript/javascript_good_1.js +++ b/.automation/test/javascript/javascript_good_1.js @@ -5,7 +5,7 @@ var handler = createHandler({ path: '/webhook', secret: (process.env.SECRET) }) var userArray = ['user1'] var teamDescription = 'Team of Robots' -var teamPrivacy = 'closed' // closed (visibile) / secret (hidden) are options here +var teamPrivacy = 'closed' // closed (visible) / secret (hidden) are options here var teamName = process.env.GHES_TEAM_NAME var teamAccess = 'pull' // pull,push,admin options here From b2836561770b0afa46793b640e0011672576dfb4 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sun, 21 Jun 2020 00:03:30 -0400 Subject: [PATCH 69/92] spelling: whitespace --- lib/linter.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 2a925646..d88d0a6d 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -354,9 +354,9 @@ GetStandardRules() ENV_STRING+="--env ${ENV} " done - ######################################## - # Remove trailing and ending witespace # - ######################################## + ######################################### + # Remove trailing and ending whitespace # + ######################################### if [[ "$LINTER" == "javascript" ]]; then JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" elif [[ "$LINTER" == "typescript" ]]; then From 865f6005fdda6c1cfe88238f0c68a728bd5a0001 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Sun, 21 Jun 2020 11:02:36 -0700 Subject: [PATCH 70/92] spelling fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e6d6f39..1cf0539b 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ The **Super-Linter** has *CI/CT/CD* configured utilizing **GitHub** Actions. - `.automation/test` contains all test cases for each language that should be validated - These **GitHub** Actions utilize the Checks API and Protected Branches to help follow the SDLC - When the Pull Request is merged to master, the **Super-Linter** **Docker** container is then updated and deployed with the new codebase - - **Note:** The branches **Docker** container is also removed from **DockerHub** to cleanup after itself + - **Note:** The branch's **Docker** container is also removed from **DockerHub** to cleanup after itself ## Limitations Below are a list of the known limitations for the **GitHub Super-Linter**: From 081e267c15a77104434f980190c57491a1f16b70 Mon Sep 17 00:00:00 2001 From: Grachev Mikhail Date: Sat, 20 Jun 2020 13:02:14 +0300 Subject: [PATCH 71/92] Add support more variants names of env files Update linter.sh Update Dockerfile Update linter.sh --- Dockerfile | 4 ++-- lib/linter.sh | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index a93c72bc..4d2c7908 100644 --- a/Dockerfile +++ b/Dockerfile @@ -102,9 +102,9 @@ 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 dotenv-linter # -################## +######################### RUN wget "https://github.com/dotenv-linter/dotenv-linter/releases/latest/download/dotenv-linter-alpine-x86_64.tar.gz" -O - -q | tar -xzf - \ && mv "dotenv-linter" /usr/bin diff --git a/lib/linter.sh b/lib/linter.sh index ca88f558..4b174c18 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1020,9 +1020,9 @@ GetValidationInfo() VALIDATE_CSS="true" fi - #################################### + ################################### # Validate if we should check ENV # - #################################### + ################################### if [[ "$ANY_SET" == "true" ]]; then # Some linter flags were set - only run those set to true if [[ -z "$VALIDATE_ENV" ]]; then @@ -2050,7 +2050,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 "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" + TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" ################# # Footer prints # @@ -2336,15 +2336,15 @@ if [ "$VALIDATE_CSS" == "true" ]; then LintCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" "${FILE_ARRAY_CSS[@]}" fi -################ +############### # ENV LINTING # -################ +############### if [ "$VALIDATE_ENV" == "true" ]; then ####################### # Lint the env files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "${FILE_ARRAY_ENV[@]}" + LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" "${FILE_ARRAY_ENV[@]}" fi ################## From 96242befa3a96b5ab3c82fe0550a602dd2f25887 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 08:20:50 -0500 Subject: [PATCH 72/92] fixed or statement --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index ba4a12be..6fabb8bc 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -770,7 +770,7 @@ GetValidationInfo() -n "$VALIDATE_DOCKER" || \ -n "$VALIDATE_GO" || \ -n "$VALIDATE_TERRAFORM" || \ - -n "$VALIDATE_POWERSHELL" \ + -n "$VALIDATE_POWERSHELL" || \ -n "$VALIDATE_CSS" || \ -n "$VALIDATE_ENV" ]]; then ANY_SET="true" @@ -2409,4 +2409,4 @@ fi ########## # Footer # ########## -Footer \ No newline at end of file +Footer From 2d7275249687d36cbc33f755f3678a8e3c9b603a Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 08:23:46 -0500 Subject: [PATCH 73/92] fix loops --- lib/linter.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/linter.sh b/lib/linter.sh index 6fabb8bc..70b99760 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1026,6 +1026,7 @@ GetValidationInfo() else # No linter flags were set - default all to true VALIDATE_POWERSHELL="true" + fi ################################### # Validate if we should check CSS # @@ -1147,6 +1148,7 @@ GetValidationInfo() PRINT_ARRAY+=("- Validating [POWERSHELL] files in code base...") else PRINT_ARRAY+=("- Excluding [POWERSHELL] files in code base...") + fi if [[ "$VALIDATE_CSS" == "true" ]]; then PRINT_ARRAY+=("- Validating [CSS] files in code base...") else From e1edf788e208ba146a16b92e3b90bf3d080ae0a7 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 08:26:38 -0500 Subject: [PATCH 74/92] fixed readme --- .automation/test/powershell/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .automation/test/powershell/README.md diff --git a/.automation/test/powershell/README.md b/.automation/test/powershell/README.md new file mode 100644 index 00000000..5a778c98 --- /dev/null +++ b/.automation/test/powershell/README.md @@ -0,0 +1,13 @@ +# PowerShell Test Cases +This folder holds the test cases for **PowerShell**. + +## 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. From 85c273d94750113ef7c11174a98f861976f1b39a Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 08:40:09 -0500 Subject: [PATCH 75/92] adding more test cases --- .automation/test/powershell/powershell_bad_1.psd1 | 3 +++ .automation/test/powershell/powershell_bad_1.psm1 | 1 + .../powershell/{powershell.psd1 => powershell_good_1.psd1} | 0 .../powershell/{powershell.psm1 => powershell_good_1.psm1} | 0 4 files changed, 4 insertions(+) create mode 100644 .automation/test/powershell/powershell_bad_1.psd1 create mode 100644 .automation/test/powershell/powershell_bad_1.psm1 rename .automation/test/powershell/{powershell.psd1 => powershell_good_1.psd1} (100%) rename .automation/test/powershell/{powershell.psm1 => powershell_good_1.psm1} (100%) diff --git a/.automation/test/powershell/powershell_bad_1.psd1 b/.automation/test/powershell/powershell_bad_1.psd1 new file mode 100644 index 00000000..5940164c --- /dev/null +++ b/.automation/test/powershell/powershell_bad_1.psd1 @@ -0,0 +1,3 @@ +@{ + 'Hello'='World +} diff --git a/.automation/test/powershell/powershell_bad_1.psm1 b/.automation/test/powershell/powershell_bad_1.psm1 new file mode 100644 index 00000000..60d812b1 --- /dev/null +++ b/.automation/test/powershell/powershell_bad_1.psm1 @@ -0,0 +1 @@ +Write-Output "hello world! diff --git a/.automation/test/powershell/powershell.psd1 b/.automation/test/powershell/powershell_good_1.psd1 similarity index 100% rename from .automation/test/powershell/powershell.psd1 rename to .automation/test/powershell/powershell_good_1.psd1 diff --git a/.automation/test/powershell/powershell.psm1 b/.automation/test/powershell/powershell_good_1.psm1 similarity index 100% rename from .automation/test/powershell/powershell.psm1 rename to .automation/test/powershell/powershell_good_1.psm1 From b95544805ef2bb044784e5bf29e58990939bb154 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 09:40:19 -0500 Subject: [PATCH 76/92] fix version to variable --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1f159db1..709a7d27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ RUN apk add --no-cache \ ca-certificates less ncurses-terminfo-base \ krb5-libs libgcc libintl libssl1.1 libstdc++ \ tzdata userspace-rcu zlib icu-libs lttng-ust - + ######################################### # Install Powershell + PSScriptAnalyzer # ######################################### @@ -100,7 +100,9 @@ RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0 # Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default # We then need to promote the correct version, uninstall, and fix deps -RUN sh -c 'gem install --default rubocop:0.74.0; yes | gem uninstall rubocop:0.85.1 -a -x -I; gem install rubocop:0.74.0' +RUN sh -c 'INCORRECT_VERSION=$(gem list rhc -e rubocop |grep rubocop |awk "{print $2}" |cut -d"(" -f2|cut -d"," -f1); \ + gem install --default rubocop:0.74.0; \ + yes | gem uninstall rubocop:$INCORRECT_VERSION -a -x -I; gem install rubocop:0.74.0' ###################### # Install shellcheck # @@ -173,4 +175,4 @@ COPY TEMPLATES /action/lib/.automation ###################### # Set the entrypoint # ###################### -ENTRYPOINT ["/action/lib/linter.sh"] \ No newline at end of file +ENTRYPOINT ["/action/lib/linter.sh"] From 247f156c83a23cc955afeb59a900d8d1e686ce9d Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 09:41:04 -0500 Subject: [PATCH 77/92] fix format --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 709a7d27..068f5edb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -100,9 +100,10 @@ RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0 # Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default # We then need to promote the correct version, uninstall, and fix deps -RUN sh -c 'INCORRECT_VERSION=$(gem list rhc -e rubocop |grep rubocop |awk "{print $2}" |cut -d"(" -f2|cut -d"," -f1); \ +RUN sh -c 'INCORRECT_VERSION=$(gem list rhc -e rubocop | grep rubocop | awk "{print $2}" | cut -d"(" -f2| cut -d"," -f1); \ gem install --default rubocop:0.74.0; \ - yes | gem uninstall rubocop:$INCORRECT_VERSION -a -x -I; gem install rubocop:0.74.0' + yes | gem uninstall rubocop:$INCORRECT_VERSION -a -x -I; \ + gem install rubocop:0.74.0' ###################### # Install shellcheck # From f0e1f999abfa4787ce2835d6695bd9bd68410773 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 09:42:04 -0500 Subject: [PATCH 78/92] space --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 068f5edb..01f00e31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -100,7 +100,7 @@ RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0 # Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default # We then need to promote the correct version, uninstall, and fix deps -RUN sh -c 'INCORRECT_VERSION=$(gem list rhc -e rubocop | grep rubocop | awk "{print $2}" | cut -d"(" -f2| cut -d"," -f1); \ +RUN sh -c 'INCORRECT_VERSION=$(gem list rhc -e rubocop | grep rubocop | awk "{print $2}" | cut -d"(" -f2 | cut -d"," -f1); \ gem install --default rubocop:0.74.0; \ yes | gem uninstall rubocop:$INCORRECT_VERSION -a -x -I; \ gem install rubocop:0.74.0' From 948c8c4f5da4ef77841bc02a25407233166cfbc4 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 09:54:09 -0500 Subject: [PATCH 79/92] make exec --- lib/pwshlint.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 lib/pwshlint.ps1 diff --git a/lib/pwshlint.ps1 b/lib/pwshlint.ps1 old mode 100644 new mode 100755 From e01b7fc4e472957e386f8c6cae6f42f3f0bf2be3 Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Mon, 22 Jun 2020 09:58:04 -0500 Subject: [PATCH 80/92] Add IAmHughes as CODEOWNER --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c70dda77..c9921dce 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ ###################################################################### # These owners will be the default owners for everything in the repo # ###################################################################### -* @admiralawkbar @jwiebalk @zkoppert \ No newline at end of file +* @admiralawkbar @jwiebalk @zkoppert @IAmHughes From 25f89245892b4b7d1f8e60dd22f9ad905d5ad0f9 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 10:09:46 -0500 Subject: [PATCH 81/92] fix output --- lib/pwshlint.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pwshlint.ps1 b/lib/pwshlint.ps1 index a3a7cfd7..4131e8ba 100755 --- a/lib/pwshlint.ps1 +++ b/lib/pwshlint.ps1 @@ -3,4 +3,4 @@ param( [String]$SettingsPath, [String]$FileToAnalyze ) -$ScriptAnalyzerResults = Invoke-ScriptAnalyzer -EnableExit -Settings $SettingsPath -Path $FileToAnalyze \ No newline at end of file +Invoke-ScriptAnalyzer -EnableExit -Settings $SettingsPath -Path $FileToAnalyze From 5bbaf3f5a069970c7436f0601c651e686db2a6a0 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 10:29:34 -0500 Subject: [PATCH 82/92] convert to more command line style --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 70b99760..fb3f0e0c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2405,7 +2405,7 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # Lint the powershell files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "POWERSHELL" "/action/lib/pwshlint.ps1" "/action/lib/pwshlint.ps1 $POWERSHELL_LINTER_RULES " ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" + LintCodebase "POWERSHELL" "PowerShell" "pwsh -c 'Invoke-ScriptAnalyzer -Settings $POWERSHELL_LINTER_RULES $POWERSHELL_LINTER_RULES'" ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi ########## From 1ecb355954e0052b3439ea3dc73864c80010d77b Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 10:36:06 -0500 Subject: [PATCH 83/92] fixed pathing --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index fb3f0e0c..1dddd5d8 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2085,7 +2085,7 @@ RunTestCases() TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(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 -Settings $POWERSHELL_LINTER_RULES'" ".*\.\(ps\.\*\)\$" + TestCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path'" ".*\.\(ps\.\*\)\$" TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" @@ -2405,7 +2405,7 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # Lint the powershell files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "POWERSHELL" "PowerShell" "pwsh -c 'Invoke-ScriptAnalyzer -Settings $POWERSHELL_LINTER_RULES $POWERSHELL_LINTER_RULES'" ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" + LintCodebase "POWERSHELL" "PowerShell" "pwsh -c 'Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path'" ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi ########## From d709a18a6ce5fe3f3141cebaeabaf9b4c56dcef3 Mon Sep 17 00:00:00 2001 From: Broder Peters Date: Mon, 22 Jun 2020 17:39:05 +0200 Subject: [PATCH 84/92] Point linter.yml example to existing version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cf0539b..43f040a1 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: docker://github/super-linter:v2.1.1 + uses: docker://github/super-linter:v2.1.0 env: VALIDATE_ALL_CODEBASE: false VALIDATE_ANSIBLE: false From dc7137b504cbeb69c2420bcc38ec9072f98fcb92 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 10:58:52 -0500 Subject: [PATCH 85/92] add all file types --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 1dddd5d8..82bf140c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2405,7 +2405,7 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # Lint the powershell files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "POWERSHELL" "PowerShell" "pwsh -c 'Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path'" ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" + LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path'" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi ########## From 209529d93b576c8bb52d4c0e96ac6e186154739c Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 11:16:45 -0500 Subject: [PATCH 86/92] cleanup --- lib/linter.sh | 2 +- lib/pwshlint.ps1 | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100755 lib/pwshlint.ps1 diff --git a/lib/linter.sh b/lib/linter.sh index 82bf140c..14e63131 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -2085,7 +2085,7 @@ RunTestCases() TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(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'" ".*\.\(ps\.\*\)\$" + 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\)\$" diff --git a/lib/pwshlint.ps1 b/lib/pwshlint.ps1 deleted file mode 100755 index 4131e8ba..00000000 --- a/lib/pwshlint.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/pwsh -param( - [String]$SettingsPath, - [String]$FileToAnalyze -) -Invoke-ScriptAnalyzer -EnableExit -Settings $SettingsPath -Path $FileToAnalyze From 32232a2442ac9c6dcbba5be6b6a4f3674e0a25e1 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 11:35:31 -0500 Subject: [PATCH 87/92] fixed quotes --- lib/linter.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 14e63131..810adef6 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1909,6 +1909,12 @@ TestCodebase() # Lint the file with the rules # ################################ LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/ansible" || exit; $LINTER_COMMAND "$FILE" 2>&1) + elif [[ "$FILE_TYPE" == "POWERSHELL" ]]; then + ################################ + # Lint the file with the rules # + ################################ + # Need to append "'" to make the pwsh call syntax correct + LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE" \' 2>&1) else ################################ # Lint the file with the rules # @@ -2085,7 +2091,7 @@ RunTestCases() TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(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\)\$" + 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\)\$" @@ -2405,7 +2411,8 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # Lint the powershell files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path'" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}" + # NOTE: the offset of the missing "'" is taken care of in the loop logic + LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi ########## From 64dba67f88e71e530494934ff341a202164c6da4 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 12:16:32 -0500 Subject: [PATCH 88/92] fixed error codes --- lib/linter.sh | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 810adef6..cfd6a5e9 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1739,10 +1739,26 @@ LintCodebase() echo "---------------------------" echo "File:[$FILE]" - ################################ - # Lint the file with the rules # - ################################ - LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1) + #################### + # Set the base Var # + #################### + LINT_CMD='' + + ####################################### + # Corner case for Powershell subshell # + ####################################### + if [[ "$FILE_TYPE" == "POWERSHELL" ]]; then + ################################ + # Lint the file with the rules # + ################################ + # Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell + LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE" \' 2>&1 ; exit "$?") + else + ################################ + # Lint the file with the rules # + ################################ + LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1) + fi ####################### # Load the error code # @@ -1913,8 +1929,8 @@ TestCodebase() ################################ # Lint the file with the rules # ################################ - # Need to append "'" to make the pwsh call syntax correct - LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE" \' 2>&1) + # Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell + LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE" \' 2>&1 ; exit "$?") else ################################ # Lint the file with the rules # From 107387d10aefe426ff8bce80de84d2c395b84604 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 12:27:54 -0500 Subject: [PATCH 89/92] fixing order --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index cfd6a5e9..6f0d732c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1752,7 +1752,7 @@ LintCodebase() # Lint the file with the rules # ################################ # Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell - LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE" \' 2>&1 ; exit "$?") + LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE"; exit $?\' 2>&1) else ################################ # Lint the file with the rules # @@ -1930,7 +1930,7 @@ TestCodebase() # Lint the file with the rules # ################################ # Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell - LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE" \' 2>&1 ; exit "$?") + LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE"; exit $?\' 2>&1) else ################################ # Lint the file with the rules # From d7d3e7273980bfa49795d113b39d5eb7ec5a1344 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 12:56:35 -0500 Subject: [PATCH 90/92] testing --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 6f0d732c..fa7e41d0 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x # shellcheck disable=SC1003,SC2016 ################################################################################ From 714855e739c06dca6a35b9191888712d3a30d322 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 13:12:26 -0500 Subject: [PATCH 91/92] fixing quotes --- lib/linter.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index fa7e41d0..4c1a5b08 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash # shellcheck disable=SC1003,SC2016 ################################################################################ @@ -1752,7 +1752,7 @@ LintCodebase() # Lint the file with the rules # ################################ # Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell - LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE"; exit $?\' 2>&1) + LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE"; exit $? 2>&1) else ################################ # Lint the file with the rules # @@ -1930,7 +1930,7 @@ TestCodebase() # Lint the file with the rules # ################################ # Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell - LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE"; exit $?\' 2>&1) + LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE"; exit $? 2>&1) else ################################ # Lint the file with the rules # @@ -2107,7 +2107,7 @@ RunTestCases() TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(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\)\$" + 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\)\$" @@ -2427,8 +2427,7 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # Lint the powershell files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - # NOTE: the offset of the missing "'" is taken care of in the loop logic - LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}" + LintCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi ########## From 22b7a7f073fba60feea4b79f2e5c7b2fc4fd8679 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 13:55:41 -0500 Subject: [PATCH 92/92] fix rubocop logic --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4d2c7908..58e6444b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -82,7 +82,10 @@ RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0 # Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default # We then need to promot the correct verion, uninstall, and fix deps -RUN sh -c 'gem install --default rubocop:0.74.0; yes | gem uninstall rubocop:0.85.1 -a -x -I; gem install rubocop:0.74.0' +RUN sh -c 'INCORRECT_VERSION=$(gem list rhc -e rubocop | grep rubocop | awk "{print $2}" | cut -d"(" -f2 | cut -d"," -f1); \ + gem install --default rubocop:0.74.0; \ + yes | gem uninstall rubocop:$INCORRECT_VERSION -a -x -I; \ + gem install rubocop:0.74.0' ###################### # Install shellcheck #