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

Set matrix based on changed file types #6

Open
p5 opened this issue May 8, 2024 · 4 comments
Open

Set matrix based on changed file types #6

p5 opened this issue May 8, 2024 · 4 comments

Comments

@p5
Copy link

p5 commented May 8, 2024

Currently, CodeQL runs all languages defined in the array, even when a pull request does not touch a particular language. For example a single change to index.js triggers Python tests if that repo contains any Python at all.

Some of the checks take much longer than the others, so engineers are often sat waiting around for Python checks to pass when they didn't change any Python.

It would be great if this action was able to check the file extensions changed in a Pull Request, and set the matrix accordingly.

@LeShadow
Copy link
Contributor

LeShadow commented Oct 16, 2024

@CallMeGreg I'd like to take this on if that works for you?

@p5 Some engineering teams may prefer to maintain control over this aspect themselves. It might be worthwhile to consider adding an option where, if specific files are provided to the action, it returns the detected languages based on their extensions.

In the absence of any specified files, the action could default to its current behavior, returning all detected languages?

@p5
Copy link
Author

p5 commented Oct 17, 2024

if specific files are provided to the action, it returns the detected languages based on their extensions.

Apologies for not quite following your suggestion here regarding the specific files being provided. Do you mean having a custom step before this which will query git for the changed files, feeding all of them into this action as an input?

- run: echo "changed-files=$(git list changed files)" >> $GITHUB_OUTPUT 
  id: changed-files

- uses: <this-action>
  with:
    changed-files: ${{ steps.changed-files.output.changed-files }}

I agree that we should try and keep the current usage available to consumers of the action, so I was thinking of an input such as filter-changed-file-types: true|false (defaulting to the current behaviour of false).

@CallMeGreg
Copy link
Contributor

CallMeGreg commented Oct 17, 2024

@LeShadow by all means, thanks for contributing! FWIW, I believe GitHub uses linguist to determine languages in repositories. Love the idea @p5 shared about an input parameter along the lines of only-scan-changed-file-types defaulting to false.

cc @leftrightleft

@LeShadow
Copy link
Contributor

LeShadow commented Oct 17, 2024

@CallMeGreg Thanks! I already started on something in the background!

@p5 Exactly!

I would use something like this action: https://github.com/tj-actions/changed-files
(It can output changed files in a multitude of ways, like separated by a comma, or in json format)

And then feed the output of that action into this action where we can return languages based on the extensions found in the list of files.

However, if the argument is empty, we just return all detected languages.

Does that make sense?

PS: I think that if we add functionality to detect changed files to this action, instead of feeding it a list, that it would overcomplicate things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants