-
Notifications
You must be signed in to change notification settings - Fork 45
Add basic linting and formatting checks #68
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
Merged
nfelt14
merged 8 commits into
master
from
nfelt14/add-basic-linting-and-formatting-checks
Aug 12, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
21a3678
Added configurations for basic linting and formatting checks
nfelt14 4637c66
whitespace changes on files (removing tabs and replacing with spaces)
nfelt14 c500264
simplify the used ruff ruleset for now
nfelt14 01470c6
Add GitHub Workflow to perform linting and show results
nfelt14 da77adf
Turn off the tab checking hooks
nfelt14 c9dd6ba
Revert "whitespace changes on files (removing tabs and replacing with…
nfelt14 ef8a665
Reduce the necessary repo checks
nfelt14 d975472
Reduce the necessary repo checks
nfelt14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,25 @@ | ||
| --- | ||
| name: Lint Code | ||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [master] | ||
| # Cancel running jobs for the same workflow and branch. | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} | ||
| jobs: | ||
| lint-python: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: x # any version | ||
| check-latest: true | ||
| - name: Install tox | ||
| run: python -m pip install tox | ||
| - name: Test | ||
| run: tox -ve linting | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,151 +1,39 @@ | ||
| --- | ||
| name: tek-repo-lint | ||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| branches: [master] | ||
| workflow_dispatch: | ||
|
|
||
| # select correct state for repository | ||
| env: | ||
| # state: private | ||
| state: public | ||
|
|
||
| jobs: | ||
| public-or-private-repo: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| repostate: ${{ steps.repo-state.outputs.repostate }} | ||
| steps: | ||
|
|
||
| - name: Repo state | ||
| id: repo-state | ||
| run: echo "repostate=${{env.state}}" >> $GITHUB_OUTPUT | ||
| - name: Repo public? | ||
| if: "${{ env.state == 'public' }}" | ||
| run: echo "Workflow has repo set as public. If this is incorrect, uncomment line 11." | ||
| - name: Repo private? | ||
| if: "${{ env.state == 'private' }}" | ||
| run: echo "Workflow has repo set as private. If this is incorrect, uncomment line 12." | ||
|
|
||
| check-for-codeowners-file: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
| - name: Checkout repo | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Check for CODEOWNERS | ||
| id: codeowners_file | ||
| uses: initialstate/file-check-action@v1 | ||
| with: | ||
| file: ".github/CODEOWNERS" | ||
|
|
||
| - name: CODEOWNERS file Output Test | ||
| run: echo ${{ steps.codeowners_file.outputs.file_exists }} | ||
|
|
||
| - name: CODEOWNERS file exists with content | ||
| if: steps.codeowners_file.outputs.file_exists == 'true' | ||
| run: echo CODEOWNERS file exists! | ||
|
|
||
| - name: CODEOWNERS file does not exist | ||
| if: steps.codeowners_file.outputs.file_exists == 'false' | ||
| run: echo CODEOWNERS file does not exist! | ||
|
|
||
| check-for-readme-file: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
| - name: Checkout repo | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Check for README.md | ||
| id: readme_file | ||
| uses: initialstate/file-check-action@v1 | ||
| with: | ||
| file: "README" | ||
|
|
||
| - name: README file Output Test | ||
| run: echo ${{ steps.readme_file.outputs.file_exists }} | ||
|
|
||
| - name: README file exists with content | ||
| if: steps.readme_file.outputs.file_exists == 'true' | ||
| run: echo README file exists! | ||
|
|
||
| - name: README file does not exist | ||
| if: steps.readme_file.outputs.file_exists == 'false' | ||
| run: echo README file does not exist! | ||
|
|
||
| check-for-license: | ||
| needs: public-or-private-repo | ||
| if: needs.public-or-private-repo.outputs.repostate == 'public' | ||
| check-for-file: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| filename: | ||
| - .github/CODEOWNERS | ||
| - README.@(md|rst) | ||
| - LICENSE.@(md|rst) | ||
| - .github/workflows/codeql.yml | ||
| steps: | ||
|
|
||
| - name: Checkout repo | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Check for LICENSE.md | ||
| id: license_file | ||
| uses: initialstate/file-check-action@v1 | ||
| - uses: actions/checkout@v4 | ||
| - name: Ensure ${{ matrix.filename }} exists | ||
| uses: andstor/file-existence-action@v3 | ||
| with: | ||
| file: "LICENSE" | ||
|
|
||
| - name: LICENSE file Output Test | ||
| run: echo ${{ steps.license_file.outputs.file_exists }} | ||
|
|
||
| - name: LICENSE file exists with content | ||
| if: steps.license_file.outputs.file_exists == 'true' | ||
| run: echo LICENSE file exists! | ||
|
|
||
| - name: LICENSE file does not exist | ||
| if: steps.license_file.outputs.file_exists == 'false' | ||
| run: echo LICENSE file does not exist! | ||
|
|
||
| check-for-dependabot-file: | ||
| files: ${{ matrix.filename }} | ||
| ignore_case: false | ||
| follow_symbolic_links: false | ||
| fail: true # Set the step to fail if the file doesn't exist | ||
| # Check that all jobs passed | ||
| check-repo-lint-passed: | ||
| if: ${{ !cancelled() }} | ||
| needs: [check-for-file] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
| - name: Checkout repo | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Check for dependabot.yml | ||
| id: dependabot_file | ||
| uses: initialstate/file-check-action@v1 | ||
| - name: Decide whether the needed jobs succeeded or failed | ||
| uses: re-actors/alls-green@release/v1 | ||
| with: | ||
| file: ".github/dependabot.yml" | ||
|
|
||
| - name: dependabot.yml file Output Test | ||
| run: echo ${{ steps.dependabot_file.outputs.file_exists }} | ||
|
|
||
| - name: dependabot file exists with content | ||
| if: steps.dependabot_file.outputs.file_exists == 'true' | ||
| run: echo dependabot file exists! | ||
|
|
||
| - name: dependabot file does not exist | ||
| if: steps.dependabot_file.outputs.file_exists == 'false' | ||
| run: echo dependabot file does not exist! | ||
|
|
||
| check-for-codeql-file: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
| - name: Checkout repo | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Check for codeql-analysis.yml | ||
| id: codeql-analysis_file | ||
| uses: initialstate/file-check-action@v1 | ||
| with: | ||
| file: ".github/workflows/codeql-analysis.yml" | ||
|
|
||
| - name: codeql-analysis.yml file Output Test | ||
| run: echo ${{ steps.codeql-analysis_file.outputs.file_exists }} | ||
|
|
||
| - name: codeql-analysis file exists with content | ||
| if: steps.codeql-analysis_file.outputs.file_exists == 'true' | ||
| run: echo codeql-analysis file exists! | ||
|
|
||
| - name: codeql-analysis file does not exist | ||
| if: steps.codeql-analysis_file.outputs.file_exists == 'false' | ||
| run: echo codeql-analysis file does not exist! | ||
| jobs: ${{ toJSON(needs) }} |
This file contains hidden or 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,13 @@ | ||
| # Ignore IDE config folders | ||
| .idea/ | ||
| .vscode/ | ||
|
|
||
| # Ignore caches and binaries | ||
| .ruff_cache/ | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .tox/ | ||
|
|
||
| # Ignore virtual environments | ||
| *env*/ | ||
| *venv*/ |
This file contains hidden or 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,46 @@ | ||
| --- | ||
| default_install_hook_types: [pre-commit] | ||
| default_stages: [pre-commit] | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.6.0 | ||
| hooks: | ||
| - id: check-yaml | ||
| args: [--unsafe] | ||
| - id: check-toml | ||
| - id: check-json | ||
| - id: check-xml | ||
| - id: requirements-txt-fixer | ||
| # - id: trailing-whitespace # TODO: enable | ||
| # - id: end-of-file-fixer # TODO: enable | ||
| - id: check-case-conflict | ||
| - id: check-merge-conflict | ||
| - id: forbid-submodules | ||
| # TODO: enable these hooks | ||
| # - repo: https://github.com/Lucas-C/pre-commit-hooks | ||
| # rev: v1.5.5 | ||
| # hooks: | ||
| # - id: remove-tabs | ||
| # - id: forbid-tabs | ||
| - repo: https://github.com/python-jsonschema/check-jsonschema | ||
| rev: 0.29.0 | ||
| hooks: | ||
| - id: check-github-workflows | ||
| args: [--verbose] | ||
| - repo: https://github.com/pappasam/toml-sort | ||
| rev: v0.23.1 | ||
| hooks: | ||
| - id: toml-sort-fix | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.5.4 | ||
| hooks: | ||
| - id: ruff | ||
| # args: [--fix, --exit-non-zero-on-fix] | ||
| - id: ruff-format | ||
| args: [--check, --diff] | ||
| - repo: https://github.com/PyCQA/docformatter | ||
| rev: v1.7.5 | ||
| hooks: | ||
| - id: docformatter | ||
| additional_dependencies: [tomli] | ||
| args: [--check, --diff] |
This file contains hidden or 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 hidden or 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 hidden or 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,54 @@ | ||
| [tool.docformatter] | ||
| close-quotes-on-newline = true | ||
| in-place = true | ||
| recursive = true | ||
| wrap-descriptions = 100 | ||
| wrap-summaries = 0 | ||
|
|
||
| [tool.ruff] | ||
| line-length = 100 | ||
| target-version = "py38" # always generate Python 3.8 compatible code | ||
|
|
||
| [tool.ruff.lint] | ||
| fixable = ["ALL"] | ||
| flake8-quotes = {docstring-quotes = "double"} | ||
| ignore = [ | ||
| "T201" # `print` found | ||
| ] | ||
| pydocstyle = {convention = "google"} | ||
| # https://beta.ruff.rs/docs/rules/ | ||
| select = [ | ||
| # "ALL" # TODO: enable ALL | ||
| "E", | ||
| "F", | ||
| "I", | ||
| "N", | ||
| "PLE", | ||
| "Q", | ||
| "RUF" | ||
| ] | ||
|
|
||
| [tool.ruff.lint.isort] | ||
| force-sort-within-sections = false | ||
| lines-between-types = 1 | ||
| order-by-type = false | ||
|
|
||
| [tool.tomlsort] | ||
| all = true | ||
| in_place = true | ||
| spaces_before_inline_comment = 2 | ||
|
|
||
| [tool.tox] | ||
| legacy_tox_ini = """ | ||
| [tox] | ||
| requires = tox>4 | ||
| no_package = True | ||
| envlist = linting | ||
| skip_missing_interpreters = True | ||
|
|
||
| [testenv:linting] | ||
| deps = | ||
| pre-commit | ||
| commands = | ||
| pre-commit run --all-files | ||
| """ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.