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

Read the path files correctly when setting new default workspace and VALIDATE_ALL_CODEBASE: false #2912

Closed
tomkortjak opened this issue Aug 24, 2023 Discussed in #2906 · 8 comments
Labels
O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity

Comments

@tomkortjak
Copy link

tomkortjak commented Aug 24, 2023

We want to make it possible to configure megalinter to lint only certain projects in a monorepo, without scanning the entire codebase. The problems as described below is now causing line 761 in MegaLinter.py to not read out the files correctly causing it to filter out modified files that should have been linted.

Discussed in #2906

How to configure mega-linter to only lint a certain folder in monorepo?

Originally posted by tomkortjak August 22, 2023
my configuration is as follows:

FAIL_IF_MISSING_LINTER_IN_FLAVOR: true
APPLY_FIXES: all
ENABLE_LINTERS:
  - JAVASCRIPT_ES
  - TYPESCRIPT_ES
  - TSX_ESLINT
  - JSX_ESLINT
#DISABLE:
#  - COPYPASTE
#  - SPELL 
SHOW_ELAPSED_TIME: true
PRINT_ALPACA: false
FILEIO_REPORTER: false
# DISABLE_ERRORS: true
FLAVOR_SUGGESTIONS: true 
VALIDATE_ALL_CODEBASE: false 
LOG_LEVEL: DEBUG
LINTER_RULES_PATH: .

workflow job:

- name: MegaLinter
        id: ml
        uses: oxsecurity/megalinter/flavors/javascript@v7
        env: 
          DEFAULT_WORKSPACE: app/react
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          MEGALINTER_CONFIG: .github/.mega-linter.yml

The project contains a react project in app/react. I basically want to linter to only check for modified files in this directory. When scanning for modified files a get a correct list from the git diff, but the filtered list only includes the .gitignore:

Listing updated files in [/github/workspace] using git diff.
  Failed checking if running in CYGWIN due to: FileNotFoundError(2, 'No such file or directory')
  Popen(['git', 'fetch', 'origin', 'HEAD:refs/remotes/origin/HEAD'], cwd=/github/workspace, universal_newlines=False, shell=None, istream=None)
  Popen(['git', 'diff', '--name-only', 'origin/HEAD'], cwd=/github/workspace, universal_newlines=False, shell=None, istream=None)
  Modified files:
  .github/.mega-linter.yml
  .github/workflows/react_tests.yml
  .gitignore
  app/react/.cspell.json
  app/react/.eslintrc.js
  app/react/.jscpd.json
  app/react/npm-shrinkwrap.json
  app/react/src/pages/administration/inbox/InboxEditForm.tsx
  All found files before filtering:
  - .gitignore
  - File extensions: .js, .jsx, .ts, .tsx, .vue

I suspect it's because of line 761 in MegaLinter.py
if os.path.isfile(self.workspace + os.path.sep + diff_line):

How should I configure the workflow so that it recognises files like "app/react/src/pages/administration/inbox/InboxEditForm.tsx" ?

Additional question, currently we are setting DEFAULT_WORKSPACE: app/react. Otherwise it can't find the .eslintrc.json file. Is there also another to configure the path to this lint file? I wasn't able to find any in the docs.

@aiyajkwebelight
Copy link

+1, facing same.

setting default workplace explicitly with VALIDATE_ALL_CODEBASE: false not working, however VALIDATE_ALL_CODEBASE: true working fine.

@Kurt-von-Laven
Copy link
Collaborator

Have you already tried setting FILTER_REGEX_INCLUDE and/or LINTER_RULES_PATH?

@tomkortjak
Copy link
Author

Have you already tried setting FILTER_REGEX_INCLUDE and/or LINTER_RULES_PATH?

Yes both I have tried

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Sep 25, 2023
@nvuillam nvuillam removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Sep 25, 2023
@Kurt-von-Laven
Copy link
Collaborator

This is probably wishful thinking, but two changes that may be related to this issue were released in MegaLinter v7.4.0. #2964 modified the line you mentioned, and #2917 modified a similar line.

@tomkortjak
Copy link
Author

Just tried 7.4, sadly hasn't fixed it yet.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Oct 27, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2023
@nvuillam nvuillam reopened this Nov 13, 2023
@github-actions github-actions bot removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Nov 14, 2023
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Dec 14, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity
Projects
None yet
Development

No branches or pull requests

4 participants