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

devcontainer support #3485

Open
robinmordasiewicz opened this issue Apr 12, 2024 · 4 comments
Open

devcontainer support #3485

robinmordasiewicz opened this issue Apr 12, 2024 · 4 comments
Labels
question Further information is requested

Comments

@robinmordasiewicz
Copy link

We are using devcontainers and want to run megalinter from a pre-commit, but devcontainer mounts the workspace repo to a folder in the devcontainer at location "/workspace/reponame" but megalinter is not aware of this mount inside the devcontainer. Is there a way to run megalinter from a pre-commit hook within the devcontainer and pass in an environment variable with the original filesystem mount location ?

@robinmordasiewicz robinmordasiewicz added the question Further information is requested label Apr 12, 2024
@nvuillam
Copy link
Member

The .devcontainer file in MegaLinter is an inheritance from SuperLinter and i'm not sure it ever worked

It is possible to use MegaLinter as pre-commit ( @Kurt-von-Laven does it a lot ^^ ) , according to the documentation: https://megalinter.io/latest/mega-linter-runner/#pre-commit-hook

About devcontainer + pre-commit + env variable.... as i'm not a devcontainer user, I'm sorry but on my side I have no answer :(

@rjaegers
Copy link

rjaegers commented Apr 24, 2024

I have written a bit of CMake code to run MegaLinter from within a devcontainer on code that is either mounted as a volume or bind mounted. The respective code can be found here: https://github.com/philips-software/amp-embedded-infra-lib/blob/main/cmake/emil_docker_tools.cmake. It should be fairly trivial to extract it to any type of language or scripting that you would like to use it in.

One detail: for the bind mount scenario you need to pass in an environment variable LOCAL_WORKSPACE_FOLDER in your devcontainer.json (I add this by default to all our devcontainers https://github.com/philips-software/amp-devcontainer).

"remoteEnv": {
      "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
    }

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 May 25, 2024
@nvuillam
Copy link
Member

@rjaegers would you like to update the .devcontainer of MegaLinter to see if it works ? :)

@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 May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants