From 5212a5b016b32a96bef00c9e5d9a05effb339d17 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Fri, 19 Jun 2020 11:53:22 -0700 Subject: [PATCH 01/64] 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 2e94f3c355d0b8b343387048ab63c4db77db7de0 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 15:10:34 +0000 Subject: [PATCH 02/64] 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 03/64] 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 04/64] 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 05/64] 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 06/64] 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 07/64] 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 08/64] 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 09/64] 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 10/64] 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 46a1d1eb25a82872c9a41d9f58b9c7415a0d059e Mon Sep 17 00:00:00 2001 From: Antoine Leblanc Date: Sat, 20 Jun 2020 12:18:41 +0200 Subject: [PATCH 11/64] 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 21c3bb86e95fa847b8b158d4552fa34b6b0b3159 Mon Sep 17 00:00:00 2001 From: sayboras Date: Fri, 19 Jun 2020 15:11:54 +1000 Subject: [PATCH 12/64] feat(config): Add support for LINTER_PATH param To add support for LINT_PATH param. This will make super-lint more usable for existing projects, which might have lint rule file in other location. The default value is still .github/lints. Closes #161 --- Dockerfile | 1 + README.md | 1 + lib/linter.sh | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/Dockerfile b/Dockerfile index a93c72bc..e6a9652d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -116,6 +116,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ DEFAULT_BRANCH=${DEFAULT_BRANCH} \ VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \ + LINTER_PATH=${LINTER_PATH} \ VALIDATE_YAML=${VALIDATE_YAML} \ VALIDATE_JSON=${VALIDATE_JSON} \ VALIDATE_XML=${VALIDATE_XML} \ diff --git a/README.md b/README.md index 8e6d6f39..e1db8751 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ and won't run anything unexpected. | --- | --- | --- | | **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. | +| **LINTER_PATH** | `.github/linters` | Directory for all linter configuration rules. | | **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. | diff --git a/lib/linter.sh b/lib/linter.sh index ca88f558..cbda9146 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -98,6 +98,7 @@ VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate lang VALIDATE_ENV="${VALIDATE_ENV}" # 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 +LINTER_PATH="${LINTER_PATH}" # Linter Path Directory ############## # Debug Vars # @@ -569,6 +570,16 @@ GetGitHubVars() ############################### TEST_CASE_RUN=$(echo "$TEST_CASE_RUN" | awk '{print tolower($0)}') + ##################################### + # Get the Linter path # + ##################################### + if [ -z "$LINTER_PATH" ]; then + ################################### + # No flag passed, set to default # + ################################### + LINTER_PATH="$DEFAULT_LINTER_PATH" + fi + ########################## # Get the run local flag # ########################## From 037865ec11141b80b0da29a28e25cd7b8ff1e295 Mon Sep 17 00:00:00 2001 From: Wonjun Kim Date: Sun, 21 Jun 2020 16:59:18 +0900 Subject: [PATCH 13/64] Add kotlin support to super-linter --- .automation/test/kotlin/README.md | 13 ++++++ .automation/test/kotlin/kotlin_bad_1.kt | 6 +++ .automation/test/kotlin/kotlint_good_1.kt | 6 +++ Dockerfile | 9 +++- README.md | 2 + docs/disabling-linters.md | 25 +++++++++++ lib/linter.sh | 55 +++++++++++++++++++++-- 7 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 .automation/test/kotlin/README.md create mode 100644 .automation/test/kotlin/kotlin_bad_1.kt create mode 100644 .automation/test/kotlin/kotlint_good_1.kt diff --git a/.automation/test/kotlin/README.md b/.automation/test/kotlin/README.md new file mode 100644 index 00000000..f1fd9cfe --- /dev/null +++ b/.automation/test/kotlin/README.md @@ -0,0 +1,13 @@ +# Kotlin Test Cases +This folder holds the test cases for **Kotlin**. + +## 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/kotlin/kotlin_bad_1.kt b/.automation/test/kotlin/kotlin_bad_1.kt new file mode 100644 index 00000000..ad02ddc8 --- /dev/null +++ b/.automation/test/kotlin/kotlin_bad_1.kt @@ -0,0 +1,6 @@ +fun main() { + val n = "World"; + val v = "Hello, ${n}!"; + + println(v); +} \ No newline at end of file diff --git a/.automation/test/kotlin/kotlint_good_1.kt b/.automation/test/kotlin/kotlint_good_1.kt new file mode 100644 index 00000000..6e1f1a51 --- /dev/null +++ b/.automation/test/kotlin/kotlint_good_1.kt @@ -0,0 +1,6 @@ +fun main() { + val n = "World" + val v = "Hello, $n!" + + println(v) +} diff --git a/Dockerfile b/Dockerfile index a93c72bc..1021e0bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ RUN apk add --no-cache \ libxml2-utils perl \ ruby ruby-dev ruby-bundler ruby-rdoc make \ py3-setuptools ansible-lint \ - go + go openjdk8-jre ##################### # Run Pip3 Installs # @@ -108,6 +108,12 @@ RUN curl -Ls "$(curl -Ls https://api.github.com/repos/terraform-linters/tflint/r 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 +################## +# Install ktlint # +################## +RUN curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.37.2/ktlint && chmod a+x ktlint \ + && mv "ktlint" /usr/bin/ + ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### @@ -135,6 +141,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \ VALIDATE_CSS=${VALIDATE_CSS} \ VALIDATE_ENV=${VALIDATE_ENV} \ + VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \ ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \ RUN_LOCAL=${RUN_LOCAL} \ TEST_CASE_RUN=${TEST_CASE_RUN} \ diff --git a/README.md b/README.md index 8e6d6f39..0c3328f0 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **XML** | [LibXML](http://xmlsoft.org/) | | **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | | **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | +| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | ## How to use To use this **GitHub** Action you will need to complete the following: @@ -137,6 +138,7 @@ and won't run anything unexpected. | **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. | +| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the language. | | **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | | **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | | **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index b972d31c..0972bfda 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -22,6 +22,7 @@ Below is examples and documentation for each language and the various methods to - [Terraform](#terraform) - [CSS](#stylelint) - [ENV](#dotenv-linter) +- [Kotlin](#kotlin) @@ -564,3 +565,27 @@ a {} ### dotenv-linter disable entire file - There is currently **No** way to disable rules inline of the file(s) + +-------------------------------------------------------------------------------- + +## Kotlin +- [ktlint](https://github.com/pinterest/ktlint) + +### ktlint Config file +- There is no top level *configuration file* available at this time + +### ktlint disable single line +```kotlin +import package.* // ktlint-disable no-wildcard-imports +``` + +### ktlint disable code block +```kotlin +/* ktlint-disable no-wildcard-imports */ +import package.a.* +import package.b.* +/* ktlint-enable no-wildcard-imports */ +``` + +### ktlint 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 ca88f558..5d468ab0 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" "dotenv-linter") + "stylelint" "dotenv-linter" "ktlint") ############################# # 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' "ENV") + 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS' 'ENV' 'KOTLIN') ################### # GitHub ENV Vars # @@ -96,6 +96,7 @@ VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate lang VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language +VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # 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 @@ -140,6 +141,7 @@ 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 +FILE_ARRAY_KOTLIN=() # Array of files to check ############ # Counters # @@ -163,6 +165,7 @@ 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 +ERRORS_FOUND_KOTLIN=0 # Count of errors found ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -741,6 +744,7 @@ GetValidationInfo() 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_KOTLIN=$(echo "$VALIDATE_KOTLIN" | awk '{print tolower($0)}') ################################################ # Determine if any linters were explicitly set # @@ -764,7 +768,8 @@ GetValidationInfo() -n "$VALIDATE_GO" || \ -n "$VALIDATE_TERRAFORM" || \ -n "$VALIDATE_CSS" || \ - -n "$VALIDATE_ENV" ]]; then + -n "$VALIDATE_ENV" || \ + -n "$VALIDATE_KOTLIN" ]]; then ANY_SET="true" fi @@ -1034,6 +1039,21 @@ GetValidationInfo() VALIDATE_ENV="true" fi + ###################################### + # Validate if we should check KOTLIN # + ###################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_KOTLIN" ]]; then + # ENV flag was not set - default to false + VALIDATE_KOTLIN="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_KOTLIN="true" + fi + + ####################################### # Print which linters we are enabling # ####################################### @@ -1132,6 +1152,11 @@ GetValidationInfo() else PRINT_ARRAY+=("- Excluding [ENV] files in code base...") fi + if [[ "$VALIDATE_KOTLIN" == "true" ]]; then + PRINT_ARRAY+=("- Validating [KOTLIN] files in code base...") + else + PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...") + fi ############################## # Validate Ansible Directory # @@ -1479,6 +1504,15 @@ BuildFileList() # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 + elif [ "$FILE_TYPE" == "kt" ] || [ "$FILE_TYPE" == "kts" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_KOTLIN+=("$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 # @@ -1992,7 +2026,8 @@ Footer() [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || \ [ "$ERRORS_FOUND_RUBY" -ne 0 ] || \ [ "$ERRORS_FOUND_CSS" -ne 0 ] || \ - [ "$ERRORS_FOUND_ENV" -ne 0 ]; then + [ "$ERRORS_FOUND_ENV" -ne 0 ] || \ + [ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then # Failed exit echo "Exiting with errors found!" exit 1 @@ -2051,6 +2086,7 @@ RunTestCases() TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" + TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" ################# # Footer prints # @@ -2347,6 +2383,17 @@ if [ "$VALIDATE_ENV" == "true" ]; then LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "${FILE_ARRAY_ENV[@]}" fi +################## +# KOTLIN LINTING # +################## +if [ "$VALIDATE_KOTLIN" == "true" ]; then + ####################### + # Lint the Kotlin files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILE_ARRAY_ENV[@]}" +fi + ################## # DOCKER LINTING # ################## From 95e8a759580681054b22547bd6b90b7e13ff1b6b Mon Sep 17 00:00:00 2001 From: Wonjun Kim Date: Mon, 22 Jun 2020 11:07:39 +0900 Subject: [PATCH 14/64] Update ktlint to latest version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1021e0bd..13aacf77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -111,7 +111,7 @@ RUN wget "https://github.com/dotenv-linter/dotenv-linter/releases/latest/downloa ################## # Install ktlint # ################## -RUN curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.37.2/ktlint && chmod a+x ktlint \ +RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktlint && chmod a+x ktlint \ && mv "ktlint" /usr/bin/ ########################################### From 081e267c15a77104434f980190c57491a1f16b70 Mon Sep 17 00:00:00 2001 From: Grachev Mikhail Date: Sat, 20 Jun 2020 13:02:14 +0300 Subject: [PATCH 15/64] 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 16/64] 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 17/64] 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 18/64] 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 19/64] 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 20/64] 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 21/64] 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 22/64] 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 23/64] 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 24/64] 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 25/64] 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 26/64] 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 27/64] 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 28/64] 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 29/64] 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 30/64] 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 31/64] 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 32/64] 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 33/64] 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 34/64] 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 35/64] 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 f7ca82806feb8cfbca00de8466537cb36d5c8de4 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Thu, 18 Jun 2020 19:53:24 +0200 Subject: [PATCH 36/64] Add PHP linting foundation --- .automation/test/php/README.md | 13 ++++++++ .automation/test/php/php_bad_1.php | 5 +++ .automation/test/php/php_good_1.php | 5 +++ Dockerfile | 4 ++- README.md | 2 ++ docs/disabling-linters.md | 18 ++++++++++ lib/linter.sh | 51 ++++++++++++++++++++++++++++- 7 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 .automation/test/php/README.md create mode 100644 .automation/test/php/php_bad_1.php create mode 100644 .automation/test/php/php_good_1.php diff --git a/.automation/test/php/README.md b/.automation/test/php/README.md new file mode 100644 index 00000000..7ab89f43 --- /dev/null +++ b/.automation/test/php/README.md @@ -0,0 +1,13 @@ +# PHP Test Cases +This folder holds the test cases for **PHP**. + +## 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/php/php_bad_1.php b/.automation/test/php/php_bad_1.php new file mode 100644 index 00000000..9c2999f6 --- /dev/null +++ b/.automation/test/php/php_bad_1.php @@ -0,0 +1,5 @@ + Date: Mon, 22 Jun 2020 13:55:41 -0500 Subject: [PATCH 37/64] 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 # From c82c02cf55cc4c5601d86e5f21aefceca4f1163d Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 22 Jun 2020 14:42:49 -0500 Subject: [PATCH 38/64] removing hard coded errors --- .automation/test/php/php_bad_1.php | 2 -- .automation/test/php/php_good_1.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/.automation/test/php/php_bad_1.php b/.automation/test/php/php_bad_1.php index 9c2999f6..e564fc66 100644 --- a/.automation/test/php/php_bad_1.php +++ b/.automation/test/php/php_bad_1.php @@ -1,5 +1,3 @@ Date: Tue, 23 Jun 2020 07:58:56 -0500 Subject: [PATCH 39/64] fixed some logic and names --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e6a9652d..edb96af6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -116,7 +116,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \ DEFAULT_BRANCH=${DEFAULT_BRANCH} \ VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \ - LINTER_PATH=${LINTER_PATH} \ + LINTER_RULES_PATH=${LINTER_RULES_PATH} \ VALIDATE_YAML=${VALIDATE_YAML} \ VALIDATE_JSON=${VALIDATE_JSON} \ VALIDATE_XML=${VALIDATE_XML} \ From ae13786085817cae424be56fc646b593ff9c6229 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 07:59:14 -0500 Subject: [PATCH 40/64] now with it saved --- README.md | 2 +- lib/linter.sh | 34 ++++++++++++---------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index e1db8751..5a960ad1 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ and won't run anything unexpected. | --- | --- | --- | | **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. | -| **LINTER_PATH** | `.github/linters` | Directory for all linter configuration rules. | +| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. | | **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. | diff --git a/lib/linter.sh b/lib/linter.sh index cbda9146..9c9ec2f5 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -12,7 +12,7 @@ ########### # Default Vars DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location -LINTER_PATH='.github/linters' # Default linter path +DEFAULT_LINTER_RULES_PATH='.github/linters' # Default linter path # YAML Vars YAML_FILE_NAME='.yaml-lint.yml' # Name of the file YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules @@ -91,14 +91,14 @@ VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to val VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language -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 -VALIDATE_ENV="${VALIDATE_ENV}" # 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 -LINTER_PATH="${LINTER_PATH}" # Linter Path Directory +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 +VALIDATE_ENV="${VALIDATE_ENV}" # 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 +LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory ############## # Debug Vars # @@ -251,14 +251,14 @@ GetLinterRules() ##################################### # Validate we have the linter rules # ##################################### - if [ -f "$GITHUB_WORKSPACE/$LINTER_PATH/$FILE_NAME" ]; then + if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" ]; then echo "----------------------------------------------" echo "User provided file:[$FILE_NAME], setting rules file..." #################################### # Copy users into default location # #################################### - CP_CMD=$(cp "$GITHUB_WORKSPACE/$LINTER_PATH/$FILE_NAME" "$FILE_LOCATION" 2>&1) + CP_CMD=$(cp "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/$FILE_NAME" "$FILE_LOCATION" 2>&1) ################### # Load Error code # @@ -278,7 +278,7 @@ GetLinterRules() # No user default provided, using the template default # ######################################################## if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then - echo " -> Codebase does NOT have file:[$LINTER_PATH/$FILE_NAME], using Default rules at:[$FILE_LOCATION]" + echo " -> Codebase does NOT have file:[$LINTER_RULES_PATH/$FILE_NAME], using Default rules at:[$FILE_LOCATION]" fi fi } @@ -570,16 +570,6 @@ GetGitHubVars() ############################### TEST_CASE_RUN=$(echo "$TEST_CASE_RUN" | awk '{print tolower($0)}') - ##################################### - # Get the Linter path # - ##################################### - if [ -z "$LINTER_PATH" ]; then - ################################### - # No flag passed, set to default # - ################################### - LINTER_PATH="$DEFAULT_LINTER_PATH" - fi - ########################## # Get the run local flag # ########################## From 8ee90e6e35dfe1fc2a58ef894283a98bf6bf352c Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 08:23:14 -0500 Subject: [PATCH 41/64] fixed var name --- lib/linter.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 9c9ec2f5..33cccd05 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -12,7 +12,7 @@ ########### # Default Vars DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location -DEFAULT_LINTER_RULES_PATH='.github/linters' # Default linter path +LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory # YAML Vars YAML_FILE_NAME='.yaml-lint.yml' # Name of the file YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules @@ -91,14 +91,13 @@ VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to val VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language -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 -VALIDATE_ENV="${VALIDATE_ENV}" # 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 -LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory +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 +VALIDATE_ENV="${VALIDATE_ENV}" # 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 # From 10c6787b1ef8efe2a8d16c13e3f3377ce0930b6f Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 08:28:38 -0500 Subject: [PATCH 42/64] fixed collision --- lib/linter.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index d399b175..e1115cd6 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -95,10 +95,15 @@ VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to val VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language +VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language +VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language +VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language +VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language +VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # 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 +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 # From 956d9863f229879d5791d18de6569743a5aa0a01 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Tue, 23 Jun 2020 06:41:52 -0700 Subject: [PATCH 43/64] update docs to v2.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5cc133b3..414c0de4 100644 --- a/README.md +++ b/README.md @@ -98,14 +98,14 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: docker://github/super-linter:v2.1.0 + uses: docker://github/super-linter:v2.2.0 env: VALIDATE_ALL_CODEBASE: false VALIDATE_ANSIBLE: false ... ``` -**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... +**NOTE:** Using the line:`uses: docker://github/super-linter:v2.2.0` will pull the image down from **DockerHub** and run the **GitHub Super-Linter**. Using the line: `uses: github/super-linter@v2.2.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 f7ae986830849198cbbb4394693881be3a6dce25 Mon Sep 17 00:00:00 2001 From: Thomas Hughes Date: Tue, 23 Jun 2020 09:05:21 -0500 Subject: [PATCH 44/64] Update cleanup-dev to point to proper docker image --- .github/workflows/cleanup-DEV.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup-DEV.yml b/.github/workflows/cleanup-DEV.yml index 63d46c7a..53ef1f6a 100644 --- a/.github/workflows/cleanup-DEV.yml +++ b/.github/workflows/cleanup-DEV.yml @@ -47,7 +47,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: ${{ github.event.pull_request.head.ref }} shell: bash run: .automation/cleanup-docker.sh From db4662123ef0e24f13b190bf2d9f0563889f2e29 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 09:56:16 -0500 Subject: [PATCH 45/64] Adding deploy --- .github/workflows/deploy-RELEASE.yml | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/deploy-RELEASE.yml diff --git a/.github/workflows/deploy-RELEASE.yml b/.github/workflows/deploy-RELEASE.yml new file mode 100644 index 00000000..263dbe26 --- /dev/null +++ b/.github/workflows/deploy-RELEASE.yml @@ -0,0 +1,66 @@ +--- +######################### +######################### +## Deploy Docker Image ## +######################### +######################### + +# +# Documentation: +# https://help.github.com/en/articles/workflow-syntax-for-github-actions +# + +####################################### +# Start the job on all push to master # +####################################### +on: + release: + # Want to run the automation when a release is created + types: ['created'] + +############### +# Set the Job # +############### +jobs: + build: + # Name the Job + name: Deploy Docker Image - Release + # Set the agent to run on + runs-on: ubuntu-latest + ################## + # Load all steps # + ################## + steps: + ########################## + # Checkout the code base # + ########################## + - name: Checkout Code + uses: actions/checkout@v2 + + ################################### + # Run Deploy script for Dockerhub # + ################################### + - name: Deploy Release image to Dockerhub + env: + # Set the Env Vars + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + IMAGE_REPO: github/super-linter + IMAGE_VERSION: ${{ github.ref }} + DOCKERFILE_PATH: Dockerfile + shell: bash + run: .automation/upload-docker.sh + + ############################# + # Run Deploy script for GPR # + ############################# + - name: Deploy Release image to GitHub Package Registry + env: + # Set the Env Vars + DOCKER_USERNAME: ${{ secrets.GPR_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.GPR_PASSWORD }} + IMAGE_REPO: github/super-linter + IMAGE_VERSION: ${{ github.ref }} + DOCKERFILE_PATH: Dockerfile + shell: bash + run: .automation/upload-docker.sh From 60a6b9eb63763d99eb61e57218d71a3696e78226 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 23 Jun 2020 11:02:45 -0500 Subject: [PATCH 46/64] Use portable shebang --- .automation/cleanup-docker.sh | 2 +- .../test/ansible/ghe-initialize/templates/ghe-config-apply.sh | 2 +- .automation/test/shell/shell_bad_1.sh | 2 +- .automation/test/shell/shell_good_1.sh | 2 +- .automation/upload-docker.sh | 2 +- lib/linter.sh | 2 +- lib/possum.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index 131daf6a..e6a81770 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ################################################################################ ############# Cleanup Image on DockerHub @admiralawkbar ######################## diff --git a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh index 06e2e712..6ddf4d71 100644 --- a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh +++ b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ################################################################################ # Script to run ghe-config-apply on the primary GHES instance diff --git a/.automation/test/shell/shell_bad_1.sh b/.automation/test/shell/shell_bad_1.sh index 041c57ae..aa2a95e7 100644 --- a/.automation/test/shell/shell_bad_1.sh +++ b/.automation/test/shell/shell_bad_1.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # CMD HELLO_WORLD=($(echo "Hello World" | cut -f1 -d' ' 2>&1)) diff --git a/.automation/test/shell/shell_good_1.sh b/.automation/test/shell/shell_good_1.sh index 66430423..9a1f5bc5 100644 --- a/.automation/test/shell/shell_good_1.sh +++ b/.automation/test/shell/shell_good_1.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # CMD HELLO_WORLD=$(echo "Hello World" | cut -f1 -d' ' 2>&1) diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index c41adb33..2ee2b144 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ################################################################################ ############# Deploy Container to DockerHub @admiralawkbar ##################### diff --git a/lib/linter.sh b/lib/linter.sh index e1115cd6..188edf92 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # shellcheck disable=SC1003,SC2016 ################################################################################ diff --git a/lib/possum.sh b/lib/possum.sh index f23e60a7..dd87d952 100755 --- a/lib/possum.sh +++ b/lib/possum.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash cat < Date: Tue, 23 Jun 2020 12:06:12 -0500 Subject: [PATCH 47/64] Updating code to allow for both registry --- .automation/upload-docker.sh | 147 +++++++++++++++++++++++++++-------- 1 file changed, 116 insertions(+), 31 deletions(-) diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index c41adb33..500e9535 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -20,6 +20,9 @@ GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub +GPR_USERNAME="${GPR_USERNAME}" # Username to login to GitHub package registry +GPR_TOKEN="${GPR_TOKEN}" # Password to login to GitHub package registry +REGISTRY="${REGISTRY}" # What registry to upload | or IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image IMAGE_VERSION="${IMAGE_VERSION}" # Version to tag the image DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded @@ -33,7 +36,7 @@ Header() { echo "" echo "-------------------------------------------------------" - echo "------ GitHub Actions Upload image to DockerHub -------" + echo "---- GitHub Actions Upload image to [$REGISTRY] ----" echo "-------------------------------------------------------" echo "" } @@ -51,9 +54,9 @@ ValidateInput() echo "----------------------------------------------" echo "" - ############################ + ############################# # Validate GITHUB_WORKSPACE # - ############################ + ############################# if [ -z "$GITHUB_WORKSPACE" ]; then echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" echo "ERROR:[$GITHUB_WORKSPACE]" @@ -62,28 +65,77 @@ ValidateInput() echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" fi - ############################ - # Validate DOCKER_USERNAME # - ############################ - if [ -z "$DOCKER_USERNAME" ]; then - echo "ERROR! Failed to get [DOCKER_USERNAME]!" - echo "ERROR:[$DOCKER_USERNAME]" + ##################### + # Validate REGISTRY # + ##################### + if [ -z "$REGISTRY" ]; then + echo "ERROR! Failed to get [REGISTRY]!" + echo "ERROR:[$REGISTRY]" exit 1 else - echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]" + echo "Successfully found:[REGISTRY], value:[$REGISTRY]" fi - ############################ - # Validate DOCKER_PASSWORD # - ############################ - if [ -z "$DOCKER_PASSWORD" ]; then - echo "ERROR! Failed to get [DOCKER_PASSWORD]!" - echo "ERROR:[$DOCKER_PASSWORD]" - exit 1 + ##################################################### + # See if we need values for GitHub package Registry # + ##################################################### + if [[ "$REGISTRY" == "GPR" ]]; then + ######################### + # Validate GPR_USERNAME # + ######################### + if [ -z "$GPR_USERNAME" ]; then + echo "ERROR! Failed to get [GPR_USERNAME]!" + echo "ERROR:[$GPR_USERNAME]" + exit 1 + else + echo "Successfully found:[GPR_USERNAME], value:[$GPR_USERNAME]" + fi + + ###################### + # Validate GPR_TOKEN # + ###################### + if [ -z "$GPR_TOKEN" ]; then + echo "ERROR! Failed to get [GPR_TOKEN]!" + echo "ERROR:[$GPR_TOKEN]" + exit 1 + else + echo "Successfully found:[GPR_TOKEN], value:[********]" + fi + ######################################## + # See if we need values for Ducker hub # + ######################################## + elif [[ "$REGISTRY" == "Docker" ]]; then + ############################ + # Validate DOCKER_USERNAME # + ############################ + if [ -z "$DOCKER_USERNAME" ]; then + echo "ERROR! Failed to get [DOCKER_USERNAME]!" + echo "ERROR:[$DOCKER_USERNAME]" + exit 1 + else + echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]" + fi + + ############################ + # Validate DOCKER_PASSWORD # + ############################ + if [ -z "$DOCKER_PASSWORD" ]; then + echo "ERROR! Failed to get [DOCKER_PASSWORD]!" + echo "ERROR:[$DOCKER_PASSWORD]" + exit 1 + else + echo "Successfully found:[DOCKER_PASSWORD], value:[********]" + fi + ########################################### + # We were not passed a registry to update # + ########################################### else - echo "Successfully found:[DOCKER_PASSWORD], value:[********]" + echo "ERROR! Failed to find a valid registry!" + echo "Registry:[$REGISTRY]" + exit 1 fi + ####################### # Validate IMAGE_REPO # ####################### @@ -93,6 +145,14 @@ ValidateInput() exit 1 else echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]" + ############################################### + # Need to see if GPR registry and update name # + ############################################### + if [[ "$REGISTRY" == "GPR" ]]; then + NAME="docker.pkg.github/$IMAGE_REPO" + IMAGE_REPO="$NAME" + echo "Updated [IMAGE_REPO] to:[$IMAGE_REPO] for GPR" + fi fi ########################## @@ -146,22 +206,30 @@ ValidateInput() fi } ################################################################################ -#### Function LoginToDocker #################################################### -LoginToDocker() +#### Function Authenticate ##################################################### +Authenticate() { + ################ + # Pull in Vars # + ################ + USERNAME="$1" # Name to auth with + PASSWD="$2" # Password to auth with + URL="$3" # Url to auth towards + NAME="$4" # name of the service + ################ # Print header # ################ echo "" echo "----------------------------------------------" - echo "Login to DockerHub..." + echo "Login to $NAME..." echo "----------------------------------------------" echo "" - ###################### - # Login to DockerHub # - ###################### - LOGIN_CMD=$(docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD" 2>&1) + ################### + # Auth to service # + ################### + LOGIN_CMD=$(docker login "$URL" --username "$USERNAME" --password "$PASSWORD" 2>&1) ####################### # Load the error code # @@ -173,12 +241,12 @@ LoginToDocker() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! Failed to authenticate to DockerHub!" + echo "ERROR! Failed to authenticate to $NAME!" echo "ERROR:[$LOGIN_CMD]" exit 1 else # SUCCESS - echo "Successfully authenticated to DockerHub!" + echo "Successfully authenticated to $NAME!" fi } ################################################################################ @@ -194,7 +262,6 @@ BuildImage() echo "----------------------------------------------" echo "" - ################################ # Validate the DOCKERFILE_PATH # ################################ @@ -238,7 +305,7 @@ UploadImage() ################ echo "" echo "----------------------------------------------" - echo "Uploading the DockerFile image..." + echo "Uploading the DockerFile image to $REGISTRY..." echo "----------------------------------------------" echo "" @@ -261,7 +328,7 @@ UploadImage() exit 1 else # SUCCESS - echo "Successfully Uploaded Docker image to DockerHub!" + echo "Successfully Uploaded Docker image to $REGISTRY!" fi ######################### @@ -332,7 +399,25 @@ ValidateInput ###################### # Login to DockerHub # ###################### -LoginToDocker +if [[ "$REGISTRY" == "Docker" ]]; then + # Authenticate "Username" "Password" "Url" "Name" + Authenticate "$DOCKER_USERNAME" "$DOCKER_PASSWORD" "https://docker.com" "Dockerhub" + +#################################### +# Login to GitHub Package Registry # +#################################### +elif [[ "$REGISTRY" == "GPR" ]]; then + # Authenticate "Username" "Password" "Url" "Name" + Authenticate "$GPR_USERNAME" "$GPR_TOKEN" "https://docker.pkg.github.com" "GitHub Package Registry" + +else + ######### + # ERROR # + ######### + echo "ERROR! Registry not set correctly!" + echo "Registry:[$REGISTRY]" + exit 1 +fi ################### # Build the image # From 509fc7c7bbbe336fdcecb90358886883ef3b57ab Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 12:08:33 -0500 Subject: [PATCH 48/64] Updating workflows --- .github/workflows/deploy-DEV.yml | 3 ++- .github/workflows/deploy-PROD.yml | 3 ++- .github/workflows/deploy-RELEASE.yml | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-DEV.yml b/.github/workflows/deploy-DEV.yml index 4b6975d7..d9af1b44 100644 --- a/.github/workflows/deploy-DEV.yml +++ b/.github/workflows/deploy-DEV.yml @@ -43,13 +43,14 @@ jobs: ##################### # Run Deploy script # ##################### - - name: Deploy image to DockerHub + - name: Deploy DEV image to DockerHub env: # Set the Env Vars DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} IMAGE_REPO: github/super-linter DOCKERFILE_PATH: Dockerfile + REGISTRY: Docker shell: bash run: .automation/upload-docker.sh diff --git a/.github/workflows/deploy-PROD.yml b/.github/workflows/deploy-PROD.yml index fd39563b..b2306c80 100644 --- a/.github/workflows/deploy-PROD.yml +++ b/.github/workflows/deploy-PROD.yml @@ -40,7 +40,7 @@ jobs: ##################### # Run Deploy script # ##################### - - name: Deploy image to DockerHub + - name: Deploy latest image to DockerHub env: # Set the Env Vars DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} @@ -48,5 +48,6 @@ jobs: IMAGE_REPO: github/super-linter IMAGE_VERSION: latest DOCKERFILE_PATH: Dockerfile + REGISTRY: Docker shell: bash run: .automation/upload-docker.sh diff --git a/.github/workflows/deploy-RELEASE.yml b/.github/workflows/deploy-RELEASE.yml index 263dbe26..27a3a4a4 100644 --- a/.github/workflows/deploy-RELEASE.yml +++ b/.github/workflows/deploy-RELEASE.yml @@ -48,6 +48,7 @@ jobs: IMAGE_REPO: github/super-linter IMAGE_VERSION: ${{ github.ref }} DOCKERFILE_PATH: Dockerfile + REGISTRY: Docker shell: bash run: .automation/upload-docker.sh @@ -62,5 +63,6 @@ jobs: IMAGE_REPO: github/super-linter IMAGE_VERSION: ${{ github.ref }} DOCKERFILE_PATH: Dockerfile + REGISTRY: GPR shell: bash run: .automation/upload-docker.sh From f3fbf867fcc3055434f11aa9070cd8cbb0380889 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 12:10:36 -0500 Subject: [PATCH 49/64] fix var name --- .automation/upload-docker.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index 500e9535..74e3f0aa 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -212,10 +212,10 @@ Authenticate() ################ # Pull in Vars # ################ - USERNAME="$1" # Name to auth with - PASSWD="$2" # Password to auth with - URL="$3" # Url to auth towards - NAME="$4" # name of the service + USERNAME="$1" # Name to auth with + PASSWORD="$2" # Password to auth with + URL="$3" # Url to auth towards + NAME="$4" # name of the service ################ # Print header # From 57cd6822980f8b6e63a8f0dbeed703ad9a795711 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 12:19:37 -0500 Subject: [PATCH 50/64] Change of order --- .automation/upload-docker.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index 74e3f0aa..8564ef28 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -396,6 +396,11 @@ Header ################## ValidateInput +################### +# Build the image # +################### +BuildImage + ###################### # Login to DockerHub # ###################### @@ -419,11 +424,6 @@ else exit 1 fi -################### -# Build the image # -################### -BuildImage - #################### # Upload the image # #################### From 1084ce762c80b991e08c5f74ae43e15a9e0e52ad Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 12:26:28 -0500 Subject: [PATCH 51/64] less verbose --- .automation/upload-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index 8564ef28..b814de01 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -406,7 +406,7 @@ BuildImage ###################### if [[ "$REGISTRY" == "Docker" ]]; then # Authenticate "Username" "Password" "Url" "Name" - Authenticate "$DOCKER_USERNAME" "$DOCKER_PASSWORD" "https://docker.com" "Dockerhub" + Authenticate "$DOCKER_USERNAME" "$DOCKER_PASSWORD" "" "Dockerhub" #################################### # Login to GitHub Package Registry # From 1f27f86381c55a79a4e6b339615c6a7972443160 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 12:39:07 -0500 Subject: [PATCH 52/64] updated doc --- .github/CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index e2302dd8..253b1933 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -33,8 +33,8 @@ Draft pull requests are also welcome to get feedback early on, or if there is so If you are the current maintainer of this action: 1. Update `README.md` and the wiki to reflect new version number in the example workflow file sections 2. Draft [Release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) with a summarized changelog -3. Publish the docker image to GitHub package registry -4. Publish the docker image to Docker Hub +3. A GitHub Action will Publish the Docker image to GitHub Package Registry once a Release is created +4. A GitHub Action will Publish the Docker image to Docker Hub once a Release is created 5. Look for approval from [CODEOWNERS](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners) ## Resources From e03f876d8217d2efa2fdabf779daf0cb77b433b7 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 14:13:19 -0500 Subject: [PATCH 53/64] fixed space --- .automation/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.automation/README.md b/.automation/README.md index 812c2aae..485e97ec 100644 --- a/.automation/README.md +++ b/.automation/README.md @@ -19,4 +19,5 @@ When the script is triggered in a branch, it will push with the tag:**NameOfBran - **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 beaa2de473471622be6810cef25e81cf4268b20a Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 14:38:23 -0500 Subject: [PATCH 54/64] fixed relase version --- .github/workflows/deploy-RELEASE.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-RELEASE.yml b/.github/workflows/deploy-RELEASE.yml index 27a3a4a4..4a3a1d2a 100644 --- a/.github/workflows/deploy-RELEASE.yml +++ b/.github/workflows/deploy-RELEASE.yml @@ -37,6 +37,13 @@ jobs: - name: Checkout Code uses: actions/checkout@v2 + ########################## + # Get the Relase version # + ########################## + - name: Extract Release Version + shell: bash + run: echo "::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF/refs\/tags\//})" + ################################### # Run Deploy script for Dockerhub # ################################### @@ -46,7 +53,7 @@ jobs: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} IMAGE_REPO: github/super-linter - IMAGE_VERSION: ${{ github.ref }} + IMAGE_VERSION: ${RELEASE_VERSION} DOCKERFILE_PATH: Dockerfile REGISTRY: Docker shell: bash @@ -61,7 +68,7 @@ jobs: DOCKER_USERNAME: ${{ secrets.GPR_USERNAME }} DOCKER_PASSWORD: ${{ secrets.GPR_PASSWORD }} IMAGE_REPO: github/super-linter - IMAGE_VERSION: ${{ github.ref }} + IMAGE_VERSION: ${RELEASE_VERSION} DOCKERFILE_PATH: Dockerfile REGISTRY: GPR shell: bash From b8608095da9f6ef8d934302576b3a49daa6cef01 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 14:43:59 -0500 Subject: [PATCH 55/64] fixed the var --- .github/workflows/deploy-RELEASE.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-RELEASE.yml b/.github/workflows/deploy-RELEASE.yml index 4a3a1d2a..ea103f7b 100644 --- a/.github/workflows/deploy-RELEASE.yml +++ b/.github/workflows/deploy-RELEASE.yml @@ -37,13 +37,6 @@ jobs: - name: Checkout Code uses: actions/checkout@v2 - ########################## - # Get the Relase version # - ########################## - - name: Extract Release Version - shell: bash - run: echo "::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF/refs\/tags\//})" - ################################### # Run Deploy script for Dockerhub # ################################### @@ -53,7 +46,7 @@ jobs: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} IMAGE_REPO: github/super-linter - IMAGE_VERSION: ${RELEASE_VERSION} + IMAGE_VERSION: ${{ github.event.release.tag_name }} DOCKERFILE_PATH: Dockerfile REGISTRY: Docker shell: bash @@ -68,7 +61,7 @@ jobs: DOCKER_USERNAME: ${{ secrets.GPR_USERNAME }} DOCKER_PASSWORD: ${{ secrets.GPR_PASSWORD }} IMAGE_REPO: github/super-linter - IMAGE_VERSION: ${RELEASE_VERSION} + IMAGE_VERSION: ${{ github.event.release.tag_name }} DOCKERFILE_PATH: Dockerfile REGISTRY: GPR shell: bash From f94c19f8e2303ce8c4a0a116e5e75ad99b171a9f Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 23 Jun 2020 14:57:30 -0500 Subject: [PATCH 56/64] typo --- .github/workflows/deploy-RELEASE.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-RELEASE.yml b/.github/workflows/deploy-RELEASE.yml index ea103f7b..4417ed4b 100644 --- a/.github/workflows/deploy-RELEASE.yml +++ b/.github/workflows/deploy-RELEASE.yml @@ -58,8 +58,8 @@ jobs: - name: Deploy Release image to GitHub Package Registry env: # Set the Env Vars - DOCKER_USERNAME: ${{ secrets.GPR_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.GPR_PASSWORD }} + GPR_USERNAME: ${{ secrets.GPR_USERNAME }} + GPR_TOKEN: ${{ secrets.GPR_TOKEN }} IMAGE_REPO: github/super-linter IMAGE_VERSION: ${{ github.event.release.tag_name }} DOCKERFILE_PATH: Dockerfile From 52d6e690b2b8202b7a67a74cb3decb00d6515130 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Tue, 23 Jun 2020 22:18:46 +0200 Subject: [PATCH 57/64] linter.sh: fix align After Powershell PR --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 188edf92..9bad8c8b 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -145,7 +145,7 @@ FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check FILE_ARRAY_DOCKER=() # Array of files to check FILE_ARRAY_GO=() # Array of files to check FILE_ARRAY_TERRAFORM=() # Array of files to check -FILE_ARRAY_POWERSHELL=() # Array of files to check +FILE_ARRAY_POWERSHELL=() # Array of files to check FILE_ARRAY_CSS=() # Array of files to check FILE_ARRAY_ENV=() # Array of files to check FILE_ARRAY_KOTLIN=() # Array of files to check From a3a4ba3369872c700735bbcdda4f77b5ab5f071f Mon Sep 17 00:00:00 2001 From: Akash Date: Wed, 24 Jun 2020 02:07:28 +0530 Subject: [PATCH 58/64] Fix Typo In .ansible-lint.yml fixed a typo of that to then and added a comma between push and add. --- TEMPLATES/.ansible-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TEMPLATES/.ansible-lint.yml b/TEMPLATES/.ansible-lint.yml index 0007c68d..a84da4b0 100644 --- a/TEMPLATES/.ansible-lint.yml +++ b/TEMPLATES/.ansible-lint.yml @@ -29,9 +29,9 @@ quiet: true ################ skip_list: - '602' # Allow compare to empty string - - '204' # Allow string length greater that 160 chars + - '204' # Allow string length greater than 160 chars - '301' # False positives for running command shells - - '303' # Allow git commands for push add, etc... + - '303' # Allow git commands for push, add, etc... - '305' # Allow use of shell when you want - '503' # Allow step to run like handler From 01a32fba76f165d32d2b835eb21bef05aec18e91 Mon Sep 17 00:00:00 2001 From: Akash Date: Wed, 24 Jun 2020 02:25:33 +0530 Subject: [PATCH 59/64] Fixed Typo is examples -> are examples --- 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 0efb4d27..567a6e2a 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -1,7 +1,7 @@ # Disabling linters and Rules If you find you need to ignore certain **errors** and **warnings**, you will need to know the *format* to disable the **Super-Linter** rules. Below is examples and documentation for each language and the various methods to disable. - +Below are examples and documentation for each language and various methods to disable. ## Table of Linters - [Ruby](#ruby) - [Shell](#shell) From bae87a4c281819b641babe70554bcd84de16f541 Mon Sep 17 00:00:00 2001 From: Akash Date: Wed, 24 Jun 2020 10:20:54 +0530 Subject: [PATCH 60/64] Revert " Fixed Typo" This reverts commit 01a32fba76f165d32d2b835eb21bef05aec18e91. --- 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 567a6e2a..0efb4d27 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -1,7 +1,7 @@ # Disabling linters and Rules If you find you need to ignore certain **errors** and **warnings**, you will need to know the *format* to disable the **Super-Linter** rules. Below is examples and documentation for each language and the various methods to disable. -Below are examples and documentation for each language and various methods to disable. + ## Table of Linters - [Ruby](#ruby) - [Shell](#shell) From 0ec783ee6c4ff0453cd3f358b57360a052bc7a5a Mon Sep 17 00:00:00 2001 From: Akash Date: Wed, 24 Jun 2020 10:22:43 +0530 Subject: [PATCH 61/64] Fix typo is examples -> are examples --- 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 0efb4d27..c738bdbd 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -1,6 +1,6 @@ # Disabling linters and Rules If you find you need to ignore certain **errors** and **warnings**, you will need to know the *format* to disable the **Super-Linter** rules. -Below is examples and documentation for each language and the various methods to disable. +Below are examples and documentation for each language and the various methods to disable. ## Table of Linters - [Ruby](#ruby) From 26f16f42cb4990ceb8b80a4ed6f3ba3add40c2b6 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 24 Jun 2020 07:45:11 -0500 Subject: [PATCH 62/64] fixed ansible and powershell --- lib/linter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 9bad8c8b..9ed553f6 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1822,7 +1822,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" || exit; $LINTER_COMMAND "$FILE"; exit $? 2>&1) else ################################ # Lint the file with the rules # From d9c21f2599a42f3ebaa18d5bca7aaaa2b7a9acbb Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 24 Jun 2020 07:58:27 -0500 Subject: [PATCH 63/64] Adding ansible --- lib/linter.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 9ed553f6..9716eaa0 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -78,7 +78,7 @@ GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the comm 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 +ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:-ansible}" # Ansible Directory VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language @@ -114,16 +114,16 @@ 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="${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 -DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugging output -RAW_FILE_ARRAY=() # Array of all files that were changed -READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md -TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore -DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors +DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files +DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally +DEFAULT_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/$ANSIBLE_DIRECTORY" # 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 +DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugging output +RAW_FILE_ARRAY=() # Array of all files that were changed +READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md +TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore +DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors ########################## # Array of changed files # @@ -1922,7 +1922,7 @@ TestCodebase() # Get list of all files to lint # ################################# # shellcheck disable=SC2207,SC2086 - LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; find . -type f -regex "$FILE_EXTENSIONS" ! -path "*./ansible*" 2>&1)) + LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; find . -type f -regex "$FILE_EXTENSIONS" ! -path "*./$ANSIBLE_DIRECTORY*" 2>&1)) fi ################## @@ -1994,7 +1994,7 @@ TestCodebase() ################################ # Lint the file with the rules # ################################ - LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/ansible" || exit; $LINTER_COMMAND "$FILE" 2>&1) + LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/$ANSIBLE_DIRECTORY" || exit; $LINTER_COMMAND "$FILE" 2>&1) elif [[ "$FILE_TYPE" == "POWERSHELL" ]]; then ################################ # Lint the file with the rules # From 97612aab7eba9cf385024e71e6ee7cf74a3963dd Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 24 Jun 2020 08:12:53 -0500 Subject: [PATCH 64/64] put it back, its magic --- lib/linter.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 9716eaa0..9099b04b 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -78,7 +78,7 @@ GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the comm 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}" # Ansible Directory +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 VALIDATE_JSON="${VALIDATE_JSON}" # Boolean to validate language @@ -114,9 +114,9 @@ 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="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally -DEFAULT_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/$ANSIBLE_DIRECTORY" # Default Ansible Directory +DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate all files +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 DEFAULT_ACTIONS_RUNNER_DEBUG='false' # Default value for debugging output @@ -1922,7 +1922,7 @@ TestCodebase() # Get list of all files to lint # ################################# # shellcheck disable=SC2207,SC2086 - LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; find . -type f -regex "$FILE_EXTENSIONS" ! -path "*./$ANSIBLE_DIRECTORY*" 2>&1)) + LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; find . -type f -regex "$FILE_EXTENSIONS" ! -path "*./ansible*" 2>&1)) fi ################## @@ -1994,7 +1994,7 @@ TestCodebase() ################################ # Lint the file with the rules # ################################ - LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/$ANSIBLE_DIRECTORY" || exit; $LINTER_COMMAND "$FILE" 2>&1) + 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 #