From dbfdea2ff347c2bc3a2242118b446b2c6d6eb11d Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Fri, 12 Jun 2020 10:39:38 -0700 Subject: [PATCH 1/8] Implement restructured flag parsing We implement the new method of determining if the YAML linter should be enabled, which takes into account if any linters have been explicitly enabled. Currently we only implement this for YAML as a testbed. --- lib/linter.sh | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 89497cae..54a15783 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -706,20 +706,40 @@ GetValidationInfo() ###################### PRINT_ARRAY=() - ############################### - # Convert string to lowercase # - ############################### + ################################ + # Convert strings to lowercase # + ################################ VALIDATE_YAML=$(echo "$VALIDATE_YAML" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_YAML" != "false" ]]; then - # Set to true - VALIDATE_YAML="$DEFAULT_VALIDATE_LANGUAGE" - PRINT_ARRAY+=("- Validating [YML] files in code base...") + + ################################################ + # Determine if any linters were explicitly set # + ################################################ + ANY_SET="false" + if [[ -n "$VALIDATE_YAML" ]]; then + ANY_SET="true" + fi + + #################################### + # Validate if we should check YAML # + #################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_YAML" ]]; then + # YAML flag was not set - default to false + VALIDATE_YAML="false" + fi else - # Its false - PRINT_ARRAY+=("- Excluding [YML] files in code base...") + # No linter flags were set - default all to true + VALIDATE_YAML="true" + fi + + ####################################### + # Print which linters we are enabling # + ####################################### + if [[ "$VALIDATE_YAML" == "true" ]]; then + PRINT_ARRAY+=("- Validating [YAML] files in code base...") + else + PRINT_ARRAY+=("- Excluding [YAML] files in code base...") fi ############################### From b3dc7159a9f57af77cedfc7ce28b77c72e513ec8 Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Fri, 12 Jun 2020 10:42:31 -0700 Subject: [PATCH 2/8] Adds JSON to new structure We implement the same structure for reading the flag with the JSON parser. --- lib/linter.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 54a15783..d2ae2554 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -710,12 +710,13 @@ GetValidationInfo() # Convert strings to lowercase # ################################ VALIDATE_YAML=$(echo "$VALIDATE_YAML" | awk '{print tolower($0)}') + VALIDATE_JSON=$(echo "$VALIDATE_JSON" | awk '{print tolower($0)}') ################################################ # Determine if any linters were explicitly set # ################################################ ANY_SET="false" - if [[ -n "$VALIDATE_YAML" ]]; then + if [[ -n "$VALIDATE_YAML" || -n "$VALIDATE_JSON" ]]; then ANY_SET="true" fi @@ -733,6 +734,20 @@ GetValidationInfo() VALIDATE_YAML="true" fi + #################################### + # Validate if we should check JSON # + #################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_JSON" ]]; then + # JSON flag was not set - default to false + VALIDATE_JSON="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_JSON="true" + fi + ####################################### # Print which linters we are enabling # ####################################### @@ -741,20 +756,9 @@ GetValidationInfo() else PRINT_ARRAY+=("- Excluding [YAML] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_JSON=$(echo "$VALIDATE_JSON" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_JSON" != "false" ]]; then - # Set to true - VALIDATE_JSON="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_JSON" == "true" ]]; then PRINT_ARRAY+=("- Validating [JSON] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [JSON] files in code base...") fi From 8b08dbbdf0fcf89db638706e597f8f0f830a4dc9 Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Fri, 12 Jun 2020 14:53:02 -0700 Subject: [PATCH 3/8] Migrate remaining linter options The remaining linters are all enabled/disabled based on the same logic implemented previously for YAML and JSON. --- lib/linter.sh | 438 +++++++++++++++++++++++++++++--------------------- 1 file changed, 257 insertions(+), 181 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index d2ae2554..03277471 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -711,12 +711,43 @@ GetValidationInfo() ################################ VALIDATE_YAML=$(echo "$VALIDATE_YAML" | awk '{print tolower($0)}') VALIDATE_JSON=$(echo "$VALIDATE_JSON" | awk '{print tolower($0)}') + VALIDATE_XML=$(echo "$VALIDATE_XML" | awk '{print tolower($0)}') + 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_PYTHON=$(echo "$VALIDATE_PYTHON" | awk '{print tolower($0)}') + VALIDATE_RUBY=$(echo "$VALIDATE_RUBY" | awk '{print tolower($0)}') + VALIDATE_COFFEE=$(echo "$VALIDATE_COFFEE" | awk '{print tolower($0)}') + VALIDATE_ANSIBLE=$(echo "$VALIDATE_ANSIBLE" | awk '{print tolower($0)}') + VALIDATE_JAVASCRIPT_ES=$(echo "$VALIDATE_JAVASCRIPT_ES" | awk '{print tolower($0)}') + VALIDATE_JAVASCRIPT_STANDARD=$(echo "$VALIDATE_JAVASCRIPT_STANDARD" | awk '{print tolower($0)}') + VALIDATE_TYPESCRIPT_ES=$(echo "$VALIDATE_TYPESCRIPT_ES" | awk '{print tolower($0)}') + VALIDATE_TYPESCRIPT_STANDARD=$(echo "$VALIDATE_TYPESCRIPT_STANDARD" | awk '{print tolower($0)}') + 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)}') ################################################ # Determine if any linters were explicitly set # ################################################ ANY_SET="false" - if [[ -n "$VALIDATE_YAML" || -n "$VALIDATE_JSON" ]]; then + if [[ -n "$VALIDATE_YAML" || \ + -n "$VALIDATE_JSON" || \ + -n "$VALIDATE_XML" || \ + -n "$VALIDATE_MD" || \ + -n "$VALIDATE_BASH" || \ + -n "$VALIDATE_PERL" || \ + -n "$VALIDATE_PYTHON" || \ + -n "$VALIDATE_RUBY" || \ + -n "$VALIDATE_COFFEE" || \ + -n "$VALIDATE_ANSIBLE" || \ + -n "$VALIDATE_JAVASCRIPT_ES" || \ + -n "$VALIDATE_JAVASCRIPT_STANDARD" || \ + -n "$VALIDATE_TYPESCRIPT_ES" || \ + -n "$VALIDATE_TYPESCRIPT_STANDARD" || \ + -n "$VALIDATE_DOCKER" || \ + -n "$VALIDATE_GO" || \ + -n "$VALIDATE_TERRAFORM" ]]; then ANY_SET="true" fi @@ -748,6 +779,216 @@ GetValidationInfo() VALIDATE_JSON="true" fi + ################################### + # Validate if we should check XML # + ################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_XML" ]]; then + # XML flag was not set - default to false + VALIDATE_XML="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_XML="true" + fi + + ######################################## + # Validate if we should check MARKDOWN # + ######################################## + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_MD" ]]; then + # MD flag was not set - default to false + VALIDATE_MD="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_MD="true" + fi + + #################################### + # Validate if we should check BASH # + #################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_BASH" ]]; then + # BASH flag was not set - default to false + VALIDATE_BASH="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_BASH="true" + fi + + #################################### + # Validate if we should check PERL # + #################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_PERL" ]]; then + # PERL flag was not set - default to false + VALIDATE_PERL="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_PERL="true" + fi + + ###################################### + # Validate if we should check PYTHON # + ###################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_PYTHON" ]]; then + # PYTHON flag was not set - default to false + VALIDATE_PYTHON="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_PYTHON="true" + fi + + #################################### + # Validate if we should check RUBY # + #################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_RUBY" ]]; then + # RUBY flag was not set - default to false + VALIDATE_RUBY="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_RUBY="true" + fi + + ###################################### + # Validate if we should check COFFEE # + ###################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_COFFEE" ]]; then + # COFFEE flag was not set - default to false + VALIDATE_COFFEE="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_COFFEE="true" + fi + + ####################################### + # Validate if we should check ANSIBLE # + ####################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_ANSIBLE" ]]; then + # ANSIBLE flag was not set - default to false + VALIDATE_ANSIBLE="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_ANSIBLE="true" + fi + + ############################################# + # Validate if we should check JAVASCRIPT_ES # + ############################################# + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_JAVASCRIPT_ES" ]]; then + # JAVASCRIPT_ES flag was not set - default to false + VALIDATE_JAVASCRIPT_ES="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_JAVASCRIPT_ES="true" + fi + + ################################################### + # Validate if we should check JAVASCRIPT_STANDARD # + ################################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_JAVASCRIPT_STANDARD" ]]; then + # JAVASCRIPT_STANDARD flag was not set - default to false + VALIDATE_JAVASCRIPT_STANDARD="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_JAVASCRIPT_STANDARD="true" + fi + + ############################################# + # Validate if we should check TYPESCRIPT_ES # + ############################################# + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_TYPESCRIPT_ES" ]]; then + # TYPESCRIPT_ES flag was not set - default to false + VALIDATE_TYPESCRIPT_ES="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_TYPESCRIPT_ES="true" + fi + + ################################################### + # Validate if we should check TYPESCRIPT_STANDARD # + ################################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_TYPESCRIPT_STANDARD" ]]; then + # TYPESCRIPT_STANDARD flag was not set - default to false + VALIDATE_TYPESCRIPT_STANDARD="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_TYPESCRIPT_STANDARD="true" + fi + + ###################################### + # Validate if we should check DOCKER # + ###################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_DOCKER" ]]; then + # DOCKER flag was not set - default to false + VALIDATE_DOCKER="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_DOCKER="true" + fi + + ################################## + # Validate if we should check GO # + ################################## + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_GO" ]]; then + # GO flag was not set - default to false + VALIDATE_GO="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_GO="true" + fi + + ######################################### + # Validate if we should check TERRAFORM # + ######################################### + if [[ "$ANY_SET" == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z "$VALIDATE_TERRAFORM" ]]; then + # TERRAFORM flag was not set - default to false + VALIDATE_TERRAFORM="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_TERRAFORM="true" + fi + ####################################### # Print which linters we are enabling # ####################################### @@ -761,244 +1002,79 @@ GetValidationInfo() else PRINT_ARRAY+=("- Excluding [JSON] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_XML=$(echo "$VALIDATE_XML" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_XML" != "false" ]]; then - # Set to true - VALIDATE_XML="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_XML" == "true" ]]; then PRINT_ARRAY+=("- Validating [XML] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [XML] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_MD=$(echo "$VALIDATE_MD" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_MD" != "false" ]]; then - # Set to true - VALIDATE_MD="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_MD" == "true" ]]; then PRINT_ARRAY+=("- Validating [MARKDOWN] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [MARKDOWN] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_BASH=$(echo "$VALIDATE_BASH" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_BASH" != "false" ]]; then - # Set to true - VALIDATE_BASH="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_BASH" == "true" ]]; then PRINT_ARRAY+=("- Validating [BASH] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [BASH] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_PERL=$(echo "$VALIDATE_PERL" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_PERL" != "false" ]]; then - # Set to true - VALIDATE_PERL="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_PERL" == "true" ]]; then PRINT_ARRAY+=("- Validating [PERL] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [PERL] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_PYTHON=$(echo "$VALIDATE_PYTHON" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_PYTHON" != "false" ]]; then - # Set to true - VALIDATE_PYTHON="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_PYTHON" == "true" ]]; then PRINT_ARRAY+=("- Validating [PYTHON] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [PYTHON] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_RUBY=$(echo "$VALIDATE_RUBY" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_RUBY" != "false" ]]; then - # Set to true - VALIDATE_RUBY="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_RUBY" == "true" ]]; then PRINT_ARRAY+=("- Validating [RUBY] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [RUBY] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_COFFEE=$(echo "$VALIDATE_COFFEE" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_COFFEE" != "false" ]]; then - # Set to true - VALIDATE_COFFEE="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_COFFEE" == "true" ]]; then PRINT_ARRAY+=("- Validating [COFFEE] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [COFFEE] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_ANSIBLE=$(echo "$VALIDATE_ANSIBLE" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_ANSIBLE" != "false" ]]; then - # Set to true - VALIDATE_ANSIBLE="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_ANSIBLE" == "true" ]]; then PRINT_ARRAY+=("- Validating [ANSIBLE] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [ANSIBLE] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_JAVASCRIPT_ES=$(echo "$VALIDATE_JAVASCRIPT_ES" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_JAVASCRIPT_ES" != "false" ]]; then - # Set to true - VALIDATE_JAVASCRIPT_ES="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_JAVASCRIPT_ES" == "true" ]]; then PRINT_ARRAY+=("- Validating [JAVASCRIPT(eslint)] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [JAVASCRIPT(eslint)] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_JAVASCRIPT_STANDARD=$(echo "$VALIDATE_JAVASCRIPT_STANDARD" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_JAVASCRIPT_STANDARD" != "false" ]]; then - # Set to true - VALIDATE_JAVASCRIPT_STANDARD="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_JAVASCRIPT_STANDARD" == "true" ]]; then PRINT_ARRAY+=("- Validating [JAVASCRIPT(standard)] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [JAVASCRIPT(standard)] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_TYPESCRIPT_ES=$(echo "$VALIDATE_TYPESCRIPT_ES" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_TYPESCRIPT_ES" != "false" ]]; then - # Set to true - VALIDATE_TYPESCRIPT_ES="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_TYPESCRIPT_ES" == "true" ]]; then PRINT_ARRAY+=("- Validating [TYPESCRIPT(eslint)] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [TYPESCRIPT(eslint)] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_TYPESCRIPT_STANDARD=$(echo "$VALIDATE_TYPESCRIPT_STANDARD" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_TYPESCRIPT_STANDARD" != "false" ]]; then - # Set to true - VALIDATE_TYPESCRIPT_STANDARD="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_TYPESCRIPT_STANDARD" == "true" ]]; then PRINT_ARRAY+=("- Validating [TYPESCRIPT(standard)] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [TYPESCRIPT(standard)] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_DOCKER=$(echo "$VALIDATE_DOCKER" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_DOCKER" != "false" ]]; then - # Set to true - VALIDATE_DOCKER="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_DOCKER" == "true" ]]; then PRINT_ARRAY+=("- Validating [DOCKER] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [DOCKER] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_GO=$(echo "$VALIDATE_GO" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_GO" != "false" ]]; then - # Set to true - VALIDATE_GO="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_GO" == "true" ]]; then PRINT_ARRAY+=("- Validating [GOLANG] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [GOLANG] files in code base...") fi - - ############################### - # Convert string to lowercase # - ############################### - VALIDATE_TERRAFORM=$(echo "$VALIDATE_TERRAFORM" | awk '{print tolower($0)}') - ###################################### - # Validate we should check all files # - ###################################### - if [[ "$VALIDATE_TERRAFORM" != "false" ]]; then - # Set to true - VALIDATE_TERRAFORM="$DEFAULT_VALIDATE_LANGUAGE" + if [[ "$VALIDATE_TERRAFORM" == "true" ]]; then PRINT_ARRAY+=("- Validating [TERRAFORM] files in code base...") else - # Its false PRINT_ARRAY+=("- Excluding [TERRAFORM] files in code base...") fi From 401a9f8fbf4fc1994da3ea5da1033d9d9865e7a9 Mon Sep 17 00:00:00 2001 From: Philip Mallegol-Hansen Date: Fri, 12 Jun 2020 15:10:18 -0700 Subject: [PATCH 4/8] Clean up documentation We add documentation on how the variables now work, and remove duplication in run-linter-locally.md --- README.md | 11 +++++++++-- docs/run-linter-locally.md | 24 +----------------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 7dc3d3b8..a4775109 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,14 @@ jobs: ``` ## Environment variables -The super-linter allows you to pass the following `ENV` variables to be able to trigger different functionality: +The super-linter allows you to pass the following `ENV` variables to be able to trigger different functionality. + +*Note:* All the `VALIDATE_[LANGAUGE]` variables behave in a specific way. +If none of them are passed, then they all default to true. +However if any one of the variables are set, we default to leaving any unset variable to false. +This means that if you run the linter "out of the box", all langauges will be checked. +But if you wish to select specific linters, we give you full control to choose which linters are run, +and won't run anything unexpected. | **ENV VAR** | **Default Value** | **Notes** | | --- | --- | --- | @@ -120,10 +127,10 @@ The super-linter allows you to pass the following `ENV` variables to be able to | **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) | | **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) | | **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) | -| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). | | **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the language. | +| **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. | ### Template rules files diff --git a/docs/run-linter-locally.md b/docs/run-linter-locally.md index a1803746..06117349 100644 --- a/docs/run-linter-locally.md +++ b/docs/run-linter-locally.md @@ -23,29 +23,7 @@ Once the container has been downloaded to your local environment, you can then b - **NOTE:** The flag:`RUN_LOCAL` will set: `VALIDATE_ALL_CODEBASE` to true. This means it will scan **all** the files in the directory you have mapped. If you want to only validate a subset of your codebase, map a folder with only the files you wish to have linted ### Flags for running Locally -You can add as many **Additional** flags as needed: - -| **ENV VAR** | **Command** | **Default Value** | **Notes** | -| --- | --- | --- | --- | -| **VALIDATE_YAML** | `-e VALIDATE_YAML=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_JSON** | `-e VALIDATE_JSON=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_XML** | `-e VALIDATE_XML=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_MD** | `-e VALIDATE_MD=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_BASH** | `-e VALIDATE_BASH=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_PERL** | `-e VALIDATE_PERL=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_PYTHON** | `-e VALIDATE_PYTHON=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_RUBY** | `-e VALIDATE_RUBY=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_COFFEE** | `-e VALIDATE_COFFEE=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_ANSIBLE** | `-e VALIDATE_ANSIBLE=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_JAVASCRIPT_ES** | `-e VALIDATE_JAVASCRIPT_ES=` | `true` | Flag to enable or disable the linting process of the language (Utilizing: eslint) | -| **VALIDATE_JAVASCRIPT_STANDARD** | `-e VALIDATE_JAVASCRIPT_STANDARD=` | `true` | Flag to enable or disable the linting process of the language (Utilizing: standard) | -| **VALIDATE_TYPESCRIPT_ES** | `-e VALIDATE_TYPESCRIPT_ES=` | `true` | Flag to enable or disable the linting process of the language (Utilizing: eslint) | -| **VALIDATE_TYPESCRIPT_STANDARD** | `-e VALIDATE_TYPESCRIPT_STANDARD=` | `true` | Flag to enable or disable the linting process of the language (Utilizing: standard) | -| **VALIDATE_DOCKER** | `-e VALIDATE_DOCKER=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_GO** | `-e VALIDATE_GO=` | `true` | Flag to enable or disable the linting process of the language | -| **VALIDATE_TERRAFORM** | `-e VALIDATE_TERRAFORM=` | `true` | Flag to enable or disable the linting process of the language | -| **ANSIBLE_DIRECTORY** | `-e ANSIBLE_DIRECTORY=` | `/ansible` | Flag to set the root directory for Ansible file location(s) | -| **ACTIONS_RUNNER_DEBUG** | `-e ACTIONS_RUNNER_DEBUG=` | `false` | Flag to enable or disable additional debug info | +You can add as many **Additional** flags as needed, documented in [README.md](../README.md#Environment-variables) ## Troubleshooting From f269b85ebe9e5ef15e0ce71524519481606daedf Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Tue, 16 Jun 2020 15:22:54 -0700 Subject: [PATCH 5/8] Remove init of DEFAULT_VALIDATE_LANGUAGE var is no longer in use --- lib/linter.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/linter.sh b/lib/linter.sh index 03277471..4ea4461b 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -100,7 +100,6 @@ 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_VALIDATE_LANGUAGE='true' # Default to validate language 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 From 945d5aad5dcac95396d0d57965823d0c89a1f088 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Tue, 16 Jun 2020 15:54:58 -0700 Subject: [PATCH 6/8] Update shellcheck URL see details at https://github.com/koalaman/shellcheck/issues/1871 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c5340d85..fb53be14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ RUN gem install rubocop:0.74 rubocop-rails rubocop-github:0.13 ###################### # Install shellcheck # ###################### -RUN wget -qO- "https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv \ +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/ ##################### From 059754c8b35a5f260d370ccb32c2cc99860fd3c9 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 17 Jun 2020 09:36:57 -0500 Subject: [PATCH 7/8] super nasty bug fix --- .automation/test/ruby/.gitignore | 106 ++++++++++++++++++++++++ .automation/test/ruby/LICENSE | 21 +++++ .automation/test/ruby/README0.md | 5 ++ .automation/test/ruby/importWIT.js | 77 +++++++++++++++++ .automation/test/ruby/package-lock.json | 35 ++++++++ .automation/test/ruby/wit.csv | 12 +++ Dockerfile | 6 +- 7 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 .automation/test/ruby/.gitignore create mode 100644 .automation/test/ruby/LICENSE create mode 100644 .automation/test/ruby/README0.md create mode 100644 .automation/test/ruby/importWIT.js create mode 100644 .automation/test/ruby/package-lock.json create mode 100644 .automation/test/ruby/wit.csv diff --git a/.automation/test/ruby/.gitignore b/.automation/test/ruby/.gitignore new file mode 100644 index 00000000..11a77a44 --- /dev/null +++ b/.automation/test/ruby/.gitignore @@ -0,0 +1,106 @@ + + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port diff --git a/.automation/test/ruby/LICENSE b/.automation/test/ruby/LICENSE new file mode 100644 index 00000000..c2b32069 --- /dev/null +++ b/.automation/test/ruby/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Dave McKinstry + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/.automation/test/ruby/README0.md b/.automation/test/ruby/README0.md new file mode 100644 index 00000000..51299da0 --- /dev/null +++ b/.automation/test/ruby/README0.md @@ -0,0 +1,5 @@ +# csv-issue-import + +Sample script to import a CSV file (assumedly from an Azure Boards export) to GitHub issues. + +This script is a starting point - you'll need to update for user name mappings, your own GITHUB_TOKEN, repo name, etc. It isn't a complex or robust solution, but it does show an approach to map into GitHub issues... diff --git a/.automation/test/ruby/importWIT.js b/.automation/test/ruby/importWIT.js new file mode 100644 index 00000000..8afaa339 --- /dev/null +++ b/.automation/test/ruby/importWIT.js @@ -0,0 +1,77 @@ +const fs = require('fs'); +const axios=require('axios'); + +// UPDATE THESE (and set your GITHUB_TOKEN in the environment) +const owner = 'LukasTestOrganization'; +const repo = 'TestImportRepo'; +const token = process.env.GITHUB_TOKEN + +// Configure HTTP client +const url = `https://api.github.com/repos/${owner}/${repo}/issues`; +axios.defaults.headers.post.Accept = "application/vnd.github.v3+json"; +axios.defaults.headers.post.Authorization = `token ${token}`; + +//----------------------------------------------------------------- +// getGitHubUser function - maps TFS users to GitHub users +const userMap = [ + [ "Sample User1", "admiralawkbar"], + [ "Sample User2", ""], // Not mapped in the GitHub side + [ "No Suchuser", "admiralawkbar"] +]; + +function getGitHubUser( user ) { + var foundUser = userMap.find( function( value, index, results) { + return (user === value[0]); + }); + if (foundUser === undefined) { + return ""; + } else { + return foundUser[1]; + } +} + +//----------------------------------------------------------------- +// createIssue function +// Work Item Type and state are stored as a labels +function createIssue( title, workitem_type, state, description, assignee ) { + var body = { + title: title, + body: description, + assignees: [ getGitHubUser(assignee) ], + labels: [ workitem_type, state ] + }; + + var response = axios.post(url, body) + .then((res) => { + var issueNumber = res.data.number; + console.log(`Created issue #${issueNumber}`); + }) + .catch((error) => { + console.error(error) + }); +} + +//----------------------------------------------------------------- +fs.readFile('wit.csv', function(err, charBuffer) { + var fileContents = charBuffer.toString(); + var lines = fileContents.split('\n'); + // The first line is the server name, so skip it + // The second line is column headers (skipped) which is hard coded as: + // ID,Work Item Type,Title,Assigned To,State,Tags + // We are capturing all of it as historical description + for( var i=2; i< lines.length; i++ ) { + columns = lines[i].split(','); + var id = columns[0]; + var workitem_type = columns[1]; + var title = columns[2]; + var user = columns[3]; + var state = columns[4]; + var tags = columns[5]; + + var description = `Imported ${workitem_type} #${id} from TFS, TITLE: ${title}, ASSIGNED TO: ${user}, STATE: ${state}, TAGS: ${tags}`; + + if (id > 0 ) { + createIssue( title, workitem_type, state, description, user ); + } + } +}); diff --git a/.automation/test/ruby/package-lock.json b/.automation/test/ruby/package-lock.json new file mode 100644 index 00000000..1f21ebc3 --- /dev/null +++ b/.automation/test/ruby/package-lock.json @@ -0,0 +1,35 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "axios": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", + "requires": { + "follow-redirects": "1.5.10" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } +} diff --git a/.automation/test/ruby/wit.csv b/.automation/test/ruby/wit.csv new file mode 100644 index 00000000..82fa83fb --- /dev/null +++ b/.automation/test/ruby/wit.csv @@ -0,0 +1,12 @@ +Project: etc... Ignore +ID,Work Item Type,Title,Assigned To,State,Tags +1,Task,Sample task #1,Sample User1,Closed, +2,Task,Sample task #2,Sample User1,Closed, +43,Bug,Sample bug #1,Sample User2,Closed, +44,Task,Sample task #3,Sample User1,Closed, +55,Bug,Sample bug #2,Sample User3,Resolved, +107,Task,Sample task #4,,Active, +108,Task,Sample task #5,,Active, +117,Test Case,Sample Test Case A,Sample User2,Closed, +118,Issue,Sample Issue X,User X,Closed, +2624,Task,Sample Task #6,Somebody Else,Active, diff --git a/Dockerfile b/Dockerfile index fb53be14..47e5ce3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,7 +72,11 @@ RUN git clone https://github.com/replicatedhq/dockerfilelint.git && cd /dockerfi #################### # Run GEM installs # #################### -RUN gem install rubocop:0.74 rubocop-rails rubocop-github:0.13 +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 # From b2b8d16809b65a9951f1d637e2182c56af7b8920 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 17 Jun 2020 09:48:34 -0500 Subject: [PATCH 8/8] remove files that should not be here --- .automation/test/ruby/.gitignore | 106 ------------------------ .automation/test/ruby/LICENSE | 21 ----- .automation/test/ruby/README0.md | 5 -- .automation/test/ruby/importWIT.js | 77 ----------------- .automation/test/ruby/package-lock.json | 35 -------- .automation/test/ruby/wit.csv | 12 --- 6 files changed, 256 deletions(-) delete mode 100644 .automation/test/ruby/.gitignore delete mode 100644 .automation/test/ruby/LICENSE delete mode 100644 .automation/test/ruby/README0.md delete mode 100644 .automation/test/ruby/importWIT.js delete mode 100644 .automation/test/ruby/package-lock.json delete mode 100644 .automation/test/ruby/wit.csv diff --git a/.automation/test/ruby/.gitignore b/.automation/test/ruby/.gitignore deleted file mode 100644 index 11a77a44..00000000 --- a/.automation/test/ruby/.gitignore +++ /dev/null @@ -1,106 +0,0 @@ - - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# Next.js build output -.next - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and *not* Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port diff --git a/.automation/test/ruby/LICENSE b/.automation/test/ruby/LICENSE deleted file mode 100644 index c2b32069..00000000 --- a/.automation/test/ruby/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Dave McKinstry - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/.automation/test/ruby/README0.md b/.automation/test/ruby/README0.md deleted file mode 100644 index 51299da0..00000000 --- a/.automation/test/ruby/README0.md +++ /dev/null @@ -1,5 +0,0 @@ -# csv-issue-import - -Sample script to import a CSV file (assumedly from an Azure Boards export) to GitHub issues. - -This script is a starting point - you'll need to update for user name mappings, your own GITHUB_TOKEN, repo name, etc. It isn't a complex or robust solution, but it does show an approach to map into GitHub issues... diff --git a/.automation/test/ruby/importWIT.js b/.automation/test/ruby/importWIT.js deleted file mode 100644 index 8afaa339..00000000 --- a/.automation/test/ruby/importWIT.js +++ /dev/null @@ -1,77 +0,0 @@ -const fs = require('fs'); -const axios=require('axios'); - -// UPDATE THESE (and set your GITHUB_TOKEN in the environment) -const owner = 'LukasTestOrganization'; -const repo = 'TestImportRepo'; -const token = process.env.GITHUB_TOKEN - -// Configure HTTP client -const url = `https://api.github.com/repos/${owner}/${repo}/issues`; -axios.defaults.headers.post.Accept = "application/vnd.github.v3+json"; -axios.defaults.headers.post.Authorization = `token ${token}`; - -//----------------------------------------------------------------- -// getGitHubUser function - maps TFS users to GitHub users -const userMap = [ - [ "Sample User1", "admiralawkbar"], - [ "Sample User2", ""], // Not mapped in the GitHub side - [ "No Suchuser", "admiralawkbar"] -]; - -function getGitHubUser( user ) { - var foundUser = userMap.find( function( value, index, results) { - return (user === value[0]); - }); - if (foundUser === undefined) { - return ""; - } else { - return foundUser[1]; - } -} - -//----------------------------------------------------------------- -// createIssue function -// Work Item Type and state are stored as a labels -function createIssue( title, workitem_type, state, description, assignee ) { - var body = { - title: title, - body: description, - assignees: [ getGitHubUser(assignee) ], - labels: [ workitem_type, state ] - }; - - var response = axios.post(url, body) - .then((res) => { - var issueNumber = res.data.number; - console.log(`Created issue #${issueNumber}`); - }) - .catch((error) => { - console.error(error) - }); -} - -//----------------------------------------------------------------- -fs.readFile('wit.csv', function(err, charBuffer) { - var fileContents = charBuffer.toString(); - var lines = fileContents.split('\n'); - // The first line is the server name, so skip it - // The second line is column headers (skipped) which is hard coded as: - // ID,Work Item Type,Title,Assigned To,State,Tags - // We are capturing all of it as historical description - for( var i=2; i< lines.length; i++ ) { - columns = lines[i].split(','); - var id = columns[0]; - var workitem_type = columns[1]; - var title = columns[2]; - var user = columns[3]; - var state = columns[4]; - var tags = columns[5]; - - var description = `Imported ${workitem_type} #${id} from TFS, TITLE: ${title}, ASSIGNED TO: ${user}, STATE: ${state}, TAGS: ${tags}`; - - if (id > 0 ) { - createIssue( title, workitem_type, state, description, user ); - } - } -}); diff --git a/.automation/test/ruby/package-lock.json b/.automation/test/ruby/package-lock.json deleted file mode 100644 index 1f21ebc3..00000000 --- a/.automation/test/ruby/package-lock.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "requires": true, - "lockfileVersion": 1, - "dependencies": { - "axios": { - "version": "0.19.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", - "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", - "requires": { - "follow-redirects": "1.5.10" - } - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } - }, - "follow-redirects": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", - "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", - "requires": { - "debug": "=3.1.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } - } -} diff --git a/.automation/test/ruby/wit.csv b/.automation/test/ruby/wit.csv deleted file mode 100644 index 82fa83fb..00000000 --- a/.automation/test/ruby/wit.csv +++ /dev/null @@ -1,12 +0,0 @@ -Project: etc... Ignore -ID,Work Item Type,Title,Assigned To,State,Tags -1,Task,Sample task #1,Sample User1,Closed, -2,Task,Sample task #2,Sample User1,Closed, -43,Bug,Sample bug #1,Sample User2,Closed, -44,Task,Sample task #3,Sample User1,Closed, -55,Bug,Sample bug #2,Sample User3,Resolved, -107,Task,Sample task #4,,Active, -108,Task,Sample task #5,,Active, -117,Test Case,Sample Test Case A,Sample User2,Closed, -118,Issue,Sample Issue X,User X,Closed, -2624,Task,Sample Task #6,Somebody Else,Active,