-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI, autofixes, and checks configurations
- Loading branch information
1 parent
a38c1dc
commit ae0c4bd
Showing
18 changed files
with
658 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 120 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{py,pyi}] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
mypy: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest", "windows-latest"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
cache: pip | ||
cache-dependency-path: requirements*.txt | ||
- run: cd canopeum_backend | ||
- run: pip install -r requirements-dev.txt | ||
- run: mypy . --python-version=3.12 | ||
|
||
pyright: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest", "windows-latest"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
cache: pip | ||
cache-dependency-path: requirements*.txt | ||
- run: cd canopeum_backend | ||
- run: pip install -r requirements-dev.txt | ||
- uses: jakebailey/pyright-action@v2 | ||
with: | ||
python-version: "3.12" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"default": true, | ||
"MD013": false, // Use line-wrap for Markdown | ||
"MD029": false // Allow explicit ordered list number for lists split by block codes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# You can run this locally with `pre-commit run [--all]` | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: pretty-format-json | ||
exclude: ".vscode/.*" # Exclude jsonc | ||
args: [--autofix, --no-sort-keys] | ||
- id: trailing-whitespace | ||
args: [--markdown-linebreak-ext=md] | ||
- id: end-of-file-fixer | ||
- id: mixed-line-ending | ||
args: [--fix=lf] | ||
- id: check-yaml | ||
- id: check-toml | ||
- id: check-merge-conflict | ||
- id: check-case-conflict | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.3.4 # must match canopeum_backend/requirements-dev.txt | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [--fix] | ||
# Run the formatter. | ||
- id: ruff-format | ||
|
||
ci: | ||
autoupdate_schedule: quarterly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Keep in alphabetical order | ||
{ | ||
"recommendations": [ | ||
"bierner.github-markdown-preview", | ||
"charliermarsh.ruff", | ||
"davidanson.vscode-markdownlint", | ||
"eamodio.gitlens", | ||
"github.vscode-github-actions", | ||
"ms-python.mypy-type-checker", | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
// "ms-vscode.powershell", | ||
"pkief.material-icon-theme", | ||
// "redhat.vscode-xml", | ||
"redhat.vscode-yaml", | ||
"tamasfe.even-better-toml", | ||
], | ||
"unwantedRecommendations": [ | ||
// Must disable in this workspace // | ||
// https://github.com/microsoft/vscode/issues/40239 // | ||
// | ||
// even-better-toml has format on save | ||
"bungcip.better-toml", | ||
// VSCode has implemented an optimized version | ||
"coenraads.bracket-pair-colorizer", | ||
"coenraads.bracket-pair-colorizer-2", | ||
"shardulm94.trailing-spaces", | ||
// Don't use two mypy extensions simultaneously | ||
"matangover.mypy", | ||
// Obsoleted by Pylance | ||
"ms-pyright.pyright", | ||
// | ||
// Don't recommend to autoinstall // | ||
// | ||
// Use Ruff instead | ||
"ms-python.black-formatter", | ||
"ms-python.flake8", | ||
"ms-python.isort", | ||
"ms-python.pylint", | ||
// We use autopep8 | ||
"ms-python.black-formatter", | ||
// Not configurable per workspace, tends to conflict with other linters | ||
"sonarsource.sonarlint-vscode", | ||
// Prefer using VSCode itself as a text editor | ||
"vscodevim.vim", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
{ | ||
"editor.rulers": [ | ||
80, | ||
120, | ||
], | ||
"[git-commit]": { | ||
"editor.rulers": [ | ||
72, | ||
], | ||
}, | ||
"[markdown]": { | ||
"files.trimTrailingWhitespace": false, | ||
}, | ||
"files.trimTrailingWhitespace": true, | ||
"files.insertFinalNewline": true, | ||
"files.trimFinalNewlines": true, | ||
"files.eol": "\n", | ||
"editor.comments.insertSpace": true, | ||
"editor.insertSpaces": true, | ||
"editor.detectIndentation": false, | ||
"editor.tabSize": 2, | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit", | ||
// Let dedicated linter (Ruff) organize imports | ||
"source.organizeImports": "never", | ||
}, | ||
"files.associations": { | ||
".flake8": "properties", | ||
"*.qrc": "xml", | ||
"*.ui": "xml", | ||
".markdownlint.json": "jsonc", | ||
}, | ||
"search.exclude": { | ||
"**/*.code-search": true, | ||
"*.lock": true, | ||
}, | ||
// Set the default formatter to help avoid Prettier | ||
"[json][jsonc]": { | ||
"editor.defaultFormatter": "vscode.json-language-features", | ||
}, | ||
"[python]": { | ||
"editor.defaultFormatter": "charliermarsh.ruff", | ||
"editor.tabSize": 4, | ||
"editor.rulers": [ | ||
72, // PEP8-17 docstrings | ||
// 79, // PEP8-17 default max | ||
// 88, // Black/Ruff default | ||
// 99, // PEP8-17 acceptable max | ||
120, // Our hard rule | ||
], | ||
}, | ||
"mypy-type-checker.importStrategy": "fromEnvironment", | ||
"mypy-type-checker.args": [ | ||
// https://github.com/microsoft/vscode-mypy/issues/37#issuecomment-1602702174 | ||
"--config-file=${workspaceFolder}/canopeum_backend/pyproject.toml", | ||
], | ||
"python.terminal.activateEnvironment": true, | ||
// python.analysis is Pylance (pyright) configurations | ||
"python.analysis.fixAll": [ | ||
"source.convertImportFormat" | ||
// Explicitly omiting "source.unusedImports", can be annoying when commenting code for debugging | ||
], | ||
"python.analysis.diagnosticMode": "workspace", | ||
"ruff.importStrategy": "fromEnvironment", | ||
// Use the Ruff extension instead | ||
"isort.check": false, | ||
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline", | ||
"powershell.codeFormatting.autoCorrectAliases": true, | ||
"powershell.codeFormatting.trimWhitespaceAroundPipe": true, | ||
"powershell.codeFormatting.useConstantStrings": true, | ||
"powershell.codeFormatting.useCorrectCasing": true, | ||
"powershell.codeFormatting.whitespaceBetweenParameters": true, | ||
"powershell.integratedConsole.showOnStartup": false, | ||
"terminal.integrated.defaultProfile.windows": "PowerShell", | ||
"terminal.integrated.defaultProfile.linux": "pwsh", | ||
"terminal.integrated.defaultProfile.osx": "pwsh", | ||
"xml.codeLens.enabled": true, | ||
"xml.format.spaceBeforeEmptyCloseTag": false, | ||
"xml.format.preserveSpace": [ | ||
// Default | ||
"xsl:text", | ||
"xsl:comment", | ||
"xsl:processing-instruction", | ||
"literallayout", | ||
"programlisting", | ||
"screen", | ||
"synopsis", | ||
"pre", | ||
"xd:pre", | ||
// Custom | ||
"string" | ||
], | ||
"[toml]": { | ||
"editor.defaultFormatter": "tamasfe.even-better-toml" | ||
}, | ||
"evenBetterToml.formatter.alignComments": false, | ||
"evenBetterToml.formatter.alignEntries": false, | ||
"evenBetterToml.formatter.allowedBlankLines": 1, | ||
"evenBetterToml.formatter.arrayAutoCollapse": true, | ||
"evenBetterToml.formatter.arrayAutoExpand": true, | ||
"evenBetterToml.formatter.arrayTrailingComma": true, | ||
"evenBetterToml.formatter.columnWidth": 80, | ||
"evenBetterToml.formatter.compactArrays": true, | ||
"evenBetterToml.formatter.compactEntries": false, | ||
"evenBetterToml.formatter.compactInlineTables": false, | ||
"evenBetterToml.formatter.indentEntries": false, | ||
"evenBetterToml.formatter.indentTables": false, | ||
"evenBetterToml.formatter.inlineTableExpand": false, | ||
"evenBetterToml.formatter.reorderArrays": true, | ||
"evenBetterToml.formatter.trailingNewline": true, | ||
// We like keeping TOML keys in a certain non-alphabetical order that feels more natural | ||
"evenBetterToml.formatter.reorderKeys": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.