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 56bc44a8..4b288fea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,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 # @@ -159,6 +161,27 @@ 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 # +################ +ARG RAKU_VER="2020.06" + +# Environment +ENV PATH="/root/raku-install/bin:/root/raku-install/share/perl6/site/bin:/root/.rakudobrew/bin:${PATH}" \ + ENV="/root/.profile" + +# Basic setup, programs and init +RUN git clone https://github.com/tadzik/rakudobrew ~/.rakudobrew \ + && eval "$(~/.rakudobrew/bin/rakudobrew init Sh)"\ + && rakudobrew build moar $RAKU_VER --configure-opts='--prefix=/root/raku-install' \ + && rm -rf /root/.rakudobrew/versions/moar-$RAKU_VER \ + && rakudobrew register moar-$RAKU_VER /root/raku-install \ + && rakudobrew global moar-$RAKU_VER \ + && rakudobrew build-zef \ + && rm -rf /root/.rakudobrew + + + ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### @@ -174,6 +197,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 6c1b6520..127db501 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,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) | @@ -156,6 +157,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 93800eb7..0dace390 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) @@ -353,6 +354,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 7334b447..4e1c6196 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -201,6 +201,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 a036dc2c..0ce860d6 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -82,7 +82,7 @@ CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME" # 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" "ktlint" "protolint" "clj-kondo" "spectral" "cfn-lint") @@ -90,7 +90,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' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI' 'CFN') @@ -110,6 +110,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 @@ -170,6 +171,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 @@ -199,6 +201,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 @@ -708,6 +711,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 ] || @@ -915,6 +919,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 988abea5..1e83e0a9 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)}') @@ -82,6 +83,7 @@ function GetValidationInfo() { $VALIDATE_MD || -n \ $VALIDATE_BASH || -n \ $VALIDATE_PERL || -n \ + $VALIDATE_RAKU || -n \ $VALIDATE_PHP || -n \ $VALIDATE_PYTHON || -n \ $VALIDATE_RUBY || -n \ @@ -188,6 +190,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 # #################################### @@ -487,6 +503,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 4382620a..a485e250 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -458,6 +458,7 @@ function RunTestCases() { TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\)\$" "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"