-
Notifications
You must be signed in to change notification settings - Fork 684
fix: enable CI checks to run from devcontainer #1136
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
base: main
Are you sure you want to change the base?
Changes from all commits
9994dcc
c1ef434
fffd89c
3d5c568
27fae08
5d2fb11
a2af166
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/docker-in-docker:2": { | ||
| "version": "2.17.0", | ||
| "resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c", | ||
| "integrity": "sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,33 +15,41 @@ | |
| } | ||
| }, | ||
|
|
||
| // Set *default* container specific settings.json values on container create. | ||
| "settings": { | ||
| "terminal.integrated.profiles.linux": { | ||
| "bash": { | ||
| "path": "/bin/bash" | ||
| } | ||
| }, | ||
| "python.defaultInterpreterPath": "/usr/local/bin/python", | ||
| "python.languageServer": "Default", | ||
| "python.linting.enabled": true, | ||
| "python.linting.pylintEnabled": true, | ||
| "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", | ||
| "python.formatting.blackPath": "/usr/local/py-utils/bin/black", | ||
| "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", | ||
| "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", | ||
| "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", | ||
| "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", | ||
| "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", | ||
| "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", | ||
| "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" | ||
| // Features to add to the dev container. | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/docker-in-docker:2": {} | ||
| }, | ||
|
|
||
| // Add the IDs of extensions you want installed when the container is created. | ||
| "extensions": [ | ||
| "ms-python.python", | ||
| "ms-python.vscode-pylance" | ||
| ], | ||
| "customizations": { | ||
| "vscode": { | ||
| // Set *default* container specific settings.json values on container create. | ||
| "settings": { | ||
| "terminal.integrated.profiles.linux": { | ||
| "bash": { | ||
| "path": "/bin/bash" | ||
| } | ||
| }, | ||
| "python.defaultInterpreterPath": "/usr/local/bin/python", | ||
| "python.languageServer": "Default", | ||
| "python.linting.enabled": true, | ||
| "python.linting.pylintEnabled": true, | ||
| "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", | ||
| "python.formatting.blackPath": "/usr/local/py-utils/bin/black", | ||
| "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", | ||
| "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", | ||
| "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", | ||
| "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", | ||
| "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", | ||
| "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", | ||
| "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" | ||
| }, | ||
| "extensions": [ | ||
| "ms-python.python", | ||
| "ms-python.vscode-pylance", | ||
| "ms-azuretools.vscode-docker" | ||
| ] | ||
| } | ||
| }, | ||
|
|
||
| // Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
| "forwardPorts": [8000], | ||
|
|
@@ -60,12 +68,12 @@ | |
| // }, | ||
|
|
||
| // Use 'postCreateCommand' to run commands after the container is created. | ||
| "postCreateCommand": "pip3 install -r requirements-docs.txt", | ||
| "postCreateCommand": "pip3 install -r requirements-docs.txt && chmod +x .devcontainer/run-megalinter.sh", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant chmod +x in postCreateCommand — the file is already committed with mode 100755. The chmod is harmless but unnecessary. |
||
|
|
||
| // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
| "remoteUser": "vscode", | ||
|
|
||
| "mounts": [ | ||
| "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind" | ||
| ], | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/usr/bin/env bash | ||
| # Run MegaLinter locally from the devcontainer — mirrors the CI setup in | ||
| # .github/workflows/mega-linter.yml and config in .mega-linter.yml. | ||
| # | ||
| # Usage: | ||
| # .devcontainer/run-megalinter.sh # lint only changed files | ||
| # VALIDATE_ALL_CODEBASE=true .devcontainer/run-megalinter.sh # lint everything | ||
| # | ||
| # Reports are written to ./megalinter-reports/ in the repo root. | ||
| set -euo pipefail | ||
|
|
||
| REPO_ROOT="$(git rev-parse --show-toplevel)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. git rev-parse --show-toplevel will error out if the script is run outside a git worktree — fine for the documented use case, but consider a friendlier error message. |
||
| VALIDATE_ALL="${VALIDATE_ALL_CODEBASE:-false}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MegaLinter's VALIDATE_ALL_CODEBASE=false mode typically needs DEFAULT_WORKSPACE=/tmp/lint set (and a mounted .git) to diff against DEFAULT_BRANCH=main. Worth testing that bash .devcontainer/run-megalinter.sh (no env override) actually detects only changed files rather than silently linting everything. |
||
|
|
||
| echo "Running MegaLinter (VALIDATE_ALL_CODEBASE=${VALIDATE_ALL})..." | ||
| docker run --rm \ | ||
| -v "${REPO_ROOT}:/tmp/lint" \ | ||
| -w /tmp/lint \ | ||
| -e VALIDATE_ALL_CODEBASE="${VALIDATE_ALL}" \ | ||
| -e DEFAULT_BRANCH=main \ | ||
| oxsecurity/megalinter:v8.1.0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v8.1.0 is hardcoded here but .github/workflows/mega-linter.yml has its own pinned version. If they drift, the local run stops mirroring CI, defeating the purpose. Consider sourcing the version from a shared file, or at least adding a comment reminding maintainers to bump both together. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,22 @@ | ||
| nav: | ||
| - ISE Engineering Fundamentals Playbook: README.md | ||
| - Engineering Fundamentals Checklist: engineering-fundamentals-checklist.md | ||
| - The First Week of an ISE Project: the-first-week-of-an-ise-project.md | ||
| - Start Here: start-here | ||
| - Who is ISE?: ISE.md | ||
| - Agile Development: agile-development | ||
| - The First Week of an ISE Project: the-first-week-of-an-ise-project.md | ||
| - Engineering Fundamentals Checklist: engineering-fundamentals-checklist.md | ||
| - Source Control: source-control | ||
| - Code Reviews: code-reviews | ||
| - Automated Testing: automated-testing | ||
| - CI/CD: CI-CD | ||
| - ... | ||
| - AI-Assisted Engineering: ai-assisted-engineering | ||
| - Security: security | ||
| - Observability: observability | ||
| - Agile Development: agile-development | ||
| - Design: design | ||
| - Developer Experience: developer-experience | ||
| - Documentation: documentation | ||
| - Engineering Feedback: engineering-feedback | ||
| - Non-Functional Requirements: non-functional-requirements | ||
| - ML & AI Projects: ml-and-ai-projects | ||
| - UI/UX: UI-UX | ||
| - Resources: resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yarn cleanup runs rm -f before any apt-get update. If another expired repo shows up later, contributors will hit the same class of failure. Consider running apt-get update in the same layer to fail fast at build time rather than at postCreateCommand.