Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSCPD Doesn't Run Unless TEST_CASE_RUN is set #5483

Closed
1 task done
ccolella-mdc opened this issue Apr 5, 2024 · 7 comments · Fixed by #5499 or #5482
Closed
1 task done

JSCPD Doesn't Run Unless TEST_CASE_RUN is set #5483

ccolella-mdc opened this issue Apr 5, 2024 · 7 comments · Fixed by #5499 or #5482
Labels
bug Something isn't working

Comments

@ccolella-mdc
Copy link

ccolella-mdc commented Apr 5, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

JSCPD only runs if you specify TEST_CASE_RUN as true or false

Expected Behavior

JSCPD should still run even if you don't specify a value for TEST_CASE_RUN

Super-Linter version

v6.3.1

Relevant log output

  2024-04-05 01:20:31 [DEBUG]   Categorizing the following files: /github/workspace/.github/workflows/linting.yml /github/workspace
  2024-04-05 01:20:31 [DEBUG]   FILTER_REGEX_INCLUDE: , FILTER_REGEX_EXCLUDE: 
  2024-04-05 01:20:31 [DEBUG]   IGNORE_GENERATED_FILES has a valid boolean string value: false
  2024-04-05 01:20:31 [DEBUG]   IGNORE_GITIGNORED_FILES has a valid boolean string value: false
  2024-04-05 01:20:31 [DEBUG]   FILE: /github/workspace/.github/workflows/linting.yml, FILE_TYPE: yml, BASE_FILE: linting.yml, FILE_DIR_NAME: /github/workspace/.github/workflows
  2024-04-05 01:20:31 [DEBUG]   File:[/github/workspace/.github/workflows/linting.yml], File extension:[yml], File type: [/github/workspace/.github/workflows/linting.yml: ASCII text]
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/workflows/linting.yml is NOT a supported shell script. Skipping
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is a GitHub Actions file...
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/workflows/linting.yml is GitHub Actions file.
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is a Cloud Formation file...
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is an OpenAPI file...
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/workflows/linting.yml is NOT an OpenAPI descriptor
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is a Tekton file...
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is a Kubernetes descriptor...
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/workflows/linting.yml is NOT a Kubernetes descriptor
  2024-04-05 01:20:31 [DEBUG]   FILE: /github/workspace, FILE_TYPE: /github/workspace, BASE_FILE: workspace, FILE_DIR_NAME: /github
  2024-04-05 01:20:31 [DEBUG]   /github/workspace matches with /github/workspace. Adding it to the list of directories to lint for linters that are expected to lint the whole codebase
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/linters/.checkov.yml contains a 'directory:' configuration option
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/linters/.checkov.yml doesn't contain a 'directory:' statement
  2024-04-05 01:20:31 [DEBUG]   Adding /github/workspace to the list of directories to analyze with Checkov.
  ",
      "Stderr": ""
    }
  ]
  2024-04-05 01:20:31 [INFO]   Command output when building the file list:
  ------
  2024-04-05 01:20:31 [DEBUG]   Categorizing the following files: /github/workspace/.github/workflows/linting.yml /github/workspace
  2024-04-05 01:20:31 [DEBUG]   FILTER_REGEX_INCLUDE: , FILTER_REGEX_EXCLUDE: .*\.dll|MDClarityWeb\/.*\.min\.(js|css)|MDClarityWeb\/(js|css)\/modules\/.*
  2024-04-05 01:20:31 [DEBUG]   IGNORE_GENERATED_FILES has a valid boolean string value: false
  2024-04-05 01:20:31 [DEBUG]   IGNORE_GITIGNORED_FILES has a valid boolean string value: false
  2024-04-05 01:20:31 [DEBUG]   FILE: /github/workspace/.github/workflows/linting.yml, FILE_TYPE: yml, BASE_FILE: linting.yml, FILE_DIR_NAME: /github/workspace/.github/workflows
  2024-04-05 01:20:31 [DEBUG]   File:[/github/workspace/.github/workflows/linting.yml], File extension:[yml], File type: [/github/workspace/.github/workflows/linting.yml: ASCII text]
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/workflows/linting.yml is NOT a supported shell script. Skipping
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is a GitHub Actions file...
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/workflows/linting.yml is GitHub Actions file.
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is a Cloud Formation file...
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is an OpenAPI file...
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/workflows/linting.yml is NOT an OpenAPI descriptor
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is a Tekton file...
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/workflows/linting.yml is a Kubernetes descriptor...
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/workflows/linting.yml is NOT a Kubernetes descriptor
  2024-04-05 01:20:31 [DEBUG]   FILE: /github/workspace, FILE_TYPE: /github/workspace, BASE_FILE: workspace, FILE_DIR_NAME: /github
  2024-04-05 01:20:31 [DEBUG]   /github/workspace matches with /github/workspace. Adding it to the list of directories to lint for linters that are expected to lint the whole codebase
  2024-04-05 01:20:31 [DEBUG]   Checking if /github/workspace/.github/linters/.checkov.yml contains a 'directory:' configuration option
  2024-04-05 01:20:31 [DEBUG]   /github/workspace/.github/linters/.checkov.yml doesn't contain a 'directory:' statement
  2024-04-05 01:20:31 [DEBUG]   Adding /github/workspace to the list of directories to analyze with Checkov.
  ------
  2024-04-05 01:20:31 [DEBUG]   Stderr when building the file list is empty
  2024-04-05 01:20:31 [INFO]   Successfully gathered list of files...
  2024-04-05 01:20:31 [DEBUG]   Ending GitHub Actions log group: Super-Linter initialization

Steps To Reproduce

  1. Run super-linter in github-actions with no value set for TEST_CASE_RUN

ex:

      - name: Run Super Linter
        uses: super-linter/super-linter@v6
        env:
          VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' }}
          DEFAULT_BRANCH: master
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CREATE_LOG_FILE: true
          LOG_LEVEL: 'DEBUG'

Anything else?

Relevant piece of code causing the issue:

# JSCPD test cases are handled below because we first need to exclude non-relevant test cases
if [[ "${TEST_CASE_RUN}" == "false" ]]; then
debug "Add ${FILE} to the list of items to lint with JSCPD"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSCPD"
fi

It should either default to false somewhere or this check should be changed to [[ "${TEST_CASE_RUN}" != "true" ]]"

@ccolella-mdc ccolella-mdc added the bug Something isn't working label Apr 5, 2024
@ferrarimarco
Copy link
Collaborator

Hi! Thanks for reporting this.

Since super-linter v6, JSCPD lints the entire code base and not individual files.

That snippet that you reference is to handle testing that particular linter and it's not needed otherwise.

PS: TEST_CASE_RUN default to false already:

TEST_CASE_RUN="${TEST_CASE_RUN:-"false"}"

@ferrarimarco ferrarimarco closed this as not planned Won't fix, can't repro, duplicate, stale Apr 8, 2024
@ccolella-mdc
Copy link
Author

Sure but when I run it without a value for TEST_CASE_RUN JSCPD doesn’t run at all. When I run it with TEST_CASE_RUN: false it does run.

I should not have to include TEST_CASE_RUN to run JSCPD.

@ferrarimarco
Copy link
Collaborator

Sure but when I run it without a value for TEST_CASE_RUN JSCPD doesn’t run at all. When I run it with TEST_CASE_RUN: false it does run.

I should not have to include TEST_CASE_RUN to run JSCPD.

This is correct. Also, when you TEST_CASE_RUN=true, JSCPD runs in a way that checks duplicates within each file, which is not likely what you want.

Can you include the full debug log, not just a fragment, so we can see what's going on?

@ccolella-mdc
Copy link
Author

TEST_CASE_RUN is not documented as a required input. If it is required the docs should say so.

Here's the full log file

super-linter.log

@ferrarimarco
Copy link
Collaborator

Let me reopen this while we investigate.

On line 1814, the process to build the file list terminates successfully, but it doesn't seem to print the expected log line about JSCPD:

# JSCPD test cases are handled below because we first need to exclude non-relevant test cases
if [[ "${TEST_CASE_RUN}" == "false" ]]; then
debug "Add ${FILE} to the list of items to lint with JSCPD"
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSCPD"
fi
,

despite TEST_CASE_RUN being false (line 1782 in your log)

@ferrarimarco ferrarimarco reopened this Apr 8, 2024
ferrarimarco added a commit that referenced this issue Apr 8, 2024
Export the TEST_CASE_RUN variable because subprocesses reference it when
building the file list.

Fix #5483
@ferrarimarco ferrarimarco mentioned this issue Apr 8, 2024
8 tasks
@ferrarimarco
Copy link
Collaborator

I was able to reproduce this. #5499 should fix the bug :)

Thanks for reporting!

@ccolella-mdc
Copy link
Author

Awesome thank you! And of course

ferrarimarco added a commit that referenced this issue Apr 8, 2024
- Export the TEST_CASE_RUN variable because subprocesses reference it
  when building the file list.
- Remove a duplicate file that we didn't catch because Jscpd was not
  running due to the TEST_CASE_RUN variable not being exported.

Fix #5483
ferrarimarco added a commit that referenced this issue Apr 8, 2024
- Export the TEST_CASE_RUN variable because subprocesses reference it
  when building the file list.
- Remove a duplicate file that we didn't catch because Jscpd was not
  running due to the TEST_CASE_RUN variable not being exported.

Fix #5483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants