diff --git a/.automation/test/raku/README.md b/.automation/test/raku/README.md new file mode 100644 index 00000000..9e654ca1 --- /dev/null +++ b/.automation/test/raku/README.md @@ -0,0 +1,13 @@ +# Raku Test Cases +This folder holds the test cases for **Raku**. + +## 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/raku/raku_bad_1.raku b/.automation/test/raku/raku_bad_1.raku new file mode 100644 index 00000000..a5b14536 --- /dev/null +++ b/.automation/test/raku/raku_bad_1.raku @@ -0,0 +1,4 @@ +use v6.d; + +my @foo; +$foo[1] = 42 diff --git a/.automation/test/raku/raku_good_1.raku b/.automation/test/raku/raku_good_1.raku new file mode 100644 index 00000000..9133a9cd --- /dev/null +++ b/.automation/test/raku/raku_good_1.raku @@ -0,0 +1,4 @@ +use v6; + +my @foo; +@foo[1] = 42 diff --git a/Dockerfile b/Dockerfile index 39b37c9d..355afbff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,10 @@ ARG ARM_TTK_DIRECTORY='/opt/microsoft/arm-ttk' ARG CLJ_KONDO_VERSION='2020.06.21' # Go Linter ARG GO_VERSION='v1.27.0' +# Raku Linter +ARG RAKU_VER="2020.06" +ARG RAKU_INSTALL_PATH=/usr +ARG RAKUBREW_HOME=/tmp/rakubrew #################### # Run APK installs # @@ -47,7 +51,9 @@ RUN apk add --no-cache \ php7 \ ca-certificates less ncurses-terminfo-base \ krb5-libs libgcc libintl libssl1.1 libstdc++ \ - tzdata userspace-rcu zlib icu-libs lttng-ust + tzdata userspace-rcu zlib icu-libs lttng-ust \ + libffi-dev openssl-dev + ######################################### # Install Powershell + PSScriptAnalyzer # @@ -181,6 +187,24 @@ RUN curl -sLO https://github.com/borkdude/clj-kondo/releases/download/v${CLJ_KON RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktlint && chmod a+x ktlint \ && mv "ktlint" /usr/bin/ +################ +# Install Raku # +################ + +# Environment +ENV PATH="$RAKU_INSTALL_PATH/share/perl6/site/bin:${PATH}" + + +# Basic setup, programs and init +RUN mkdir -p $RAKUBREW_HOME/bin \ + && curl -sSLo $RAKUBREW_HOME/bin/rakubrew https://rakubrew.org/perl/rakubrew \ + && chmod 755 $RAKUBREW_HOME/bin/rakubrew \ + && eval "$($RAKUBREW_HOME/bin/rakubrew init Sh)"\ + && rakubrew build moar $RAKU_VER --configure-opts='--prefix=$RAKU_INSTALL_PATH' \ + && rm -rf $RAKUBREW_HOME/versions/moar-$RAKU_VER \ + && rakubrew build-zef \ + && rm -rf $RAKUBREW_HOME + ################################ # Install editorconfig-checker # ################################ @@ -202,6 +226,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ VALIDATE_MD=${VALIDATE_MD} \ VALIDATE_BASH=${VALIDATE_BASH} \ VALIDATE_PERL=${VALIDATE_PERL} \ + VALIDATE_RAKU=${VALIDATE_RAKU} \ VALIDATE_PHP=${VALIDATE_PHP} \ VALIDATE_PYTHON=${VALIDATE_PYTHON} \ VALIDATE_RUBY=${VALIDATE_RUBY} \ diff --git a/README.md b/README.md index cc3b533e..798b512a 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | | **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) | | **Python3** | [pylint](https://www.pylint.org/) | +| **Raku** | [raku](https://raku.org) | | **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) | | **Terraform** | [tflint](https://github.com/terraform-linters/tflint) | @@ -159,6 +160,7 @@ and won't run anything unexpected. | **VALIDATE_MD** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the language. | +| **VALIDATE_RAKU** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the language. | diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 596e847c..fb622005 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -21,6 +21,7 @@ For some linters it is also possible to override rules on a case by case level w - [JSON](#json) - [Markdown](#markdown) - [Perl](#perl) +- [Raku](#raku) - [PHP](#php) - [XML](#xml) - [Coffeescript](#coffeescript) @@ -354,6 +355,24 @@ Here is more data -------------------------------------------------------------------------------- +## Raku +- [raku](https://raku.org) + +### Raku Config file +- There is no top level *configuration file* available at this time + +### Raku disable single line +- There is currently **No** way to disable rules inline of the file(s) + +### Raku disable code block +- There is currently **No** way to disable rules inline of the file(s) + +### Raku disable entire file +- There is currently **No** way to disable rules inline of the file(s) + +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- + ## PHP - [PHP](https://www.php.net/) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 46594101..4cda6582 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -209,6 +209,20 @@ function BuildFileList() { ########################################################## READ_ONLY_CHANGE_FLAG=1 ###################### + # Get the RAKU files # + ###################### + elif [ "$FILE_TYPE" == "raku" ] || [ "$FILE_TYPE" == "rakumod" ] \ + || [ "$FILE_TYPE" == "rakutest" ] || [ "$FILE_TYPE" == "pm6" ] \ + || [ "$FILE_TYPE" == "pl6" ] || [ "$FILE_TYPE" == "p6" ] ; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_RAKU+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ###################### # Get the PHP files # ###################### elif [ "$FILE_TYPE" == "php" ]; then diff --git a/lib/linter.sh b/lib/linter.sh index 63bb6f1e..991908df 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -88,7 +88,7 @@ HTML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$HTML_FILE_NAME" # Path t # Linter array for information prints # ####################################### LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" - "pylint" "perl" "rubocop" "coffeelint" "eslint" "standard" + "pylint" "perl" "raku" "rubocop" "coffeelint" "eslint" "standard" "ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint" "stylelint" "dotenv-linter" "pwsh" "arm-ttk" "ktlint" "protolint" "clj-kondo" "spectral" "cfn-lint" "htmlhint") @@ -96,7 +96,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" ############################# # Language array for prints # ############################# -LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'PHP' 'RUBY' 'PYTHON' +LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RAKU' 'PHP' 'RUBY' 'PYTHON' 'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS' 'ENV' 'POWERSHELL' 'ARM' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI' @@ -117,6 +117,7 @@ VALIDATE_XML="${VALIDATE_XML}" # Boolean to vali VALIDATE_MD="${VALIDATE_MD}" # Boolean to validate language VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language +VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language VALIDATE_PYTHON="${VALIDATE_PYTHON}" # Boolean to validate language VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language @@ -180,6 +181,7 @@ FILE_ARRAY_XML=() # Array of files to check FILE_ARRAY_MD=() # Array of files to check FILE_ARRAY_BASH=() # Array of files to check FILE_ARRAY_PERL=() # Array of files to check +FILE_ARRAY_RAKU=() # Array of files to check FILE_ARRAY_PHP=() # Array of files to check FILE_ARRAY_RUBY=() # Array of files to check FILE_ARRAY_PYTHON=() # Array of files to check @@ -211,6 +213,7 @@ ERRORS_FOUND_XML=0 # Count of errors found ERRORS_FOUND_MARKDOWN=0 # Count of errors found ERRORS_FOUND_BASH=0 # Count of errors found ERRORS_FOUND_PERL=0 # Count of errors found +ERRORS_FOUND_RAKU=0 # Count of errors found ERRORS_FOUND_PHP=0 # Count of errors found ERRORS_FOUND_RUBY=0 # Count of errors found ERRORS_FOUND_PYTHON=0 # Count of errors found @@ -769,6 +772,7 @@ Footer() { [ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || [ "$ERRORS_FOUND_BASH" -ne 0 ] || [ "$ERRORS_FOUND_PERL" -ne 0 ] || + [ "$ERRORS_FOUND_RAKU" -ne 0 ] || [ "$ERRORS_FOUND_PHP" -ne 0 ] || [ "$ERRORS_FOUND_PYTHON" -ne 0 ] || [ "$ERRORS_FOUND_COFFEESCRIPT" -ne 0 ] || @@ -983,6 +987,21 @@ if [ "$VALIDATE_PERL" == "true" ]; then LintCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "${FILE_ARRAY_PERL[@]}" fi +################ +# RAKU LINTING # +################ +if [ "$VALIDATE_RAKU" == "true" ]; then + ####################### + # Lint the raku files # + ####################### + echo "$GITHUB_WORKSPACE/META6.json" + if [ -e "$GITHUB_WORKSPACE/META6.json" ]; then + cd "$GITHUB_WORKSPACE" && zef install --deps-only --/test . + fi + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "RAKU" "raku" "raku -I $GITHUB_WORKSPACE/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILE_ARRAY_RAKU[@]}" +fi + ################ # PHP LINTING # ################ diff --git a/lib/validation.sh b/lib/validation.sh index ba01368b..17f53a3d 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -52,6 +52,7 @@ function GetValidationInfo() { VALIDATE_MD=$(echo "$VALIDATE_MD" | awk '{print tolower($0)}') VALIDATE_BASH=$(echo "$VALIDATE_BASH" | awk '{print tolower($0)}') VALIDATE_PERL=$(echo "$VALIDATE_PERL" | awk '{print tolower($0)}') + VALIDATE_RAKU=$(echo "$VALIDATE_RAKU" | awk '{print tolower($0)}') VALIDATE_PHP=$(echo "$VALIDATE_PHP" | awk '{print tolower($0)}') VALIDATE_PYTHON=$(echo "$VALIDATE_PYTHON" | awk '{print tolower($0)}') VALIDATE_RUBY=$(echo "$VALIDATE_RUBY" | awk '{print tolower($0)}') @@ -85,6 +86,7 @@ function GetValidationInfo() { $VALIDATE_MD || -n \ $VALIDATE_BASH || -n \ $VALIDATE_PERL || -n \ + $VALIDATE_RAKU || -n \ $VALIDATE_PHP || -n \ $VALIDATE_PYTHON || -n \ $VALIDATE_RUBY || -n \ @@ -194,6 +196,20 @@ function GetValidationInfo() { VALIDATE_PERL="true" fi + #################################### + # Validate if we should check RAKU # + #################################### + if [[ $ANY_SET == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z $VALIDATE_RAKU ]]; then + # RAKU flag was not set - default to false + VALIDATE_RAKU="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_RAKU="true" + fi + #################################### # Validate if we should check PHP # #################################### @@ -535,6 +551,11 @@ function GetValidationInfo() { else PRINT_ARRAY+=("- Excluding [PERL] files in code base...") fi + if [[ $VALIDATE_RAKU == "true" ]]; then + PRINT_ARRAY+=("- Validating [RAKU] files in code base...") + else + PRINT_ARRAY+=("- Excluding [RAKU] files in code base...") + fi if [[ $VALIDATE_PHP == "true" ]]; then PRINT_ARRAY+=("- Validating [PHP] files in code base...") else diff --git a/lib/worker.sh b/lib/worker.sh index e666494f..a7479afc 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -458,6 +458,7 @@ function RunTestCases() { TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell" TestCodebase "PYTHON" "pylint" "pylint --rcfile $PYTHON_LINTER_RULES" ".*\.\(py\)\$" "python" TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" + TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" TestCodebase "RUBY" "rubocop" "rubocop -c $RUBY_LINTER_RULES" ".*\.\(rb\)\$" "ruby" TestCodebase "GO" "golangci-lint" "golangci-lint run -c $GO_LINTER_RULES" ".*\.\(go\)\$" "golang"