Skip to content

Commit

Permalink
Feat/add dev container (#23)
Browse files Browse the repository at this point in the history
* feat(dev_container): Add dev container and launch settings.

* feat(launch_config): Add additional launch configs.

* feat(project_config): Add ruff max line length

* delete

* feat(ruff): Add additional settings

* feat(dev_container): Add some extensions and settings.

* feat(dev_container_settings): Add some project settings

* feat(project_settings): Add some additional workspace settings.

* feat(dev_container): Add dev requirements

* refac(project): Change project based on pylance and ruff errors.

* refac(dev_container): Remove pylance since this extension is auto installed by pathon.

* feat(license): Change license to gnu

* refac(dev_container): Remove no longer needed extension

* feat(tasks): Add ruff task to format all files.

* cicd(linter): Add action to check code with ruff

* feat(tasks): Add ruff lint task to project

* feat(ruff): Add some linter settings.

* refac(ruff): Format all files with ruff.

* feat(license): Remove license

* fix(cicd): Add checkout to linter action.
  • Loading branch information
Noahnc authored Nov 16, 2023
1 parent 16625a9 commit a3e5b52
Show file tree
Hide file tree
Showing 21 changed files with 333 additions and 338 deletions.
43 changes: 43 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm",
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/wxw-matt/devcontainer-features/command_runner:0": {},
"ghcr.io/devcontainers-contrib/features/pylint:2": {},
"ghcr.io/akhildevelops/devcontainer-features/pip:0": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip3 install --user -r requirements.txt && pip3 install --user -r requirements-dev.txt",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"njpwerner.autodocstring",
"Gruntfuggly.todo-tree",
"GitHub.copilot",
"github.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"eamodio.gitlens",
"zaaack.markdown-editor",
"yzhang.markdown-all-in-one",
"evendead.help-me-add",
"charliermarsh.ruff",
"streetsidesoftware.code-spell-checker",
"njqdev.vscode-python-typehint"
]
}
}
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
34 changes: 34 additions & 0 deletions .github/workflows/check_format_and_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
pull_request:
types:
- opened
- synchronize
- reopened
- closed
branches:
- main

jobs:
check_code:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.11

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Check code format with ruff
run: ruff format --check .

- name: Check code with ruff
run: ruff check .

42 changes: 42 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "InfraPatch CLI: Report",
"type": "python",
"request": "launch",
"module": "infrapatch.cli",
"args": [
"--debug",
"report"
],
"justMyCode": true
},
{
"name": "InfraPatch CLI: Update",
"type": "python",
"request": "launch",
"module": "infrapatch.cli",
"args": [
"--debug",
"update"
],
"justMyCode": true
},
{
"name": "InfraPatch CLI: custom",
"type": "python",
"request": "launch",
"module": "infrapatch.cli",
"args": "${input:custom_args}",
"justMyCode": true
}
],
"inputs": [
{
"id": "custom_args",
"description": "Space separated list of arguments to pass to the infrapatch cli",
"type": "promptString"
}
]
}
43 changes: 43 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"terminal.integrated.env.osx": {
"PYTHONPATH": "${workspaceFolder}",
},
"terminal.integrated.env.linux": {
"PYTHONPATH": "${workspaceFolder}",
},
"terminal.integrated.env.windows": {
"PYTHONPATH": "${workspaceFolder}",
},
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"files.autoSave": "afterDelay",
"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.inlayHints.pytestParameters": true,
"python.analysis.inlayHints.variableTypes": true,
"python.languageServer": "Default",
"editor.defaultFormatter": "charliermarsh.ruff",
"python.missingPackage.severity": "Error",
"python.terminal.activateEnvInCurrentTerminal": true,
"cSpell.words": [
"infrapatch"
],
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.fixAll": [
"source.unusedImports",
"source.convertImportFormat"
],
"python.analysis.typeCheckingMode": "basic",
"python.analysis.diagnosticMode": "workspace",
"editor.guides.indentation": false,
"editor.guides.bracketPairs": true,
"editor.guides.highlightActiveBracketPair": true,
"editor.guides.bracketPairsHorizontal": false,
}
31 changes: 31 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "format with ruff",
"type": "shell",
"command": "ruff",
"args": [
"format",
"."
],
"presentation": {
"reveal": "always"
},
"problemMatcher": []
},
{
"label": "ruff lint project",
"type": "shell",
"command": "ruff",
"args": [
"check",
"."
],
"presentation": {
"reveal": "always"
},
"problemMatcher": []
}
]
}
Loading

0 comments on commit a3e5b52

Please sign in to comment.