-
Notifications
You must be signed in to change notification settings - Fork 55
CM-24997 - Integrate Ruff linter #134
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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,36 @@ | ||
| name: Ruff (linter) | ||
|
|
||
| on: [ pull_request, push ] | ||
|
|
||
| jobs: | ||
| ruff: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Run Cimon | ||
| uses: cycodelabs/cimon-action@v0 | ||
| with: | ||
| client-id: ${{ secrets.CIMON_CLIENT_ID }} | ||
| secret: ${{ secrets.CIMON_SECRET }} | ||
| prevent: true | ||
| allowed-hosts: > | ||
| files.pythonhosted.org | ||
| install.python-poetry.org | ||
| pypi.org | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: 3.7 | ||
|
|
||
| - name: Setup Poetry | ||
| uses: snok/install-poetry@v1 | ||
|
|
||
| - name: Install dependencies | ||
| run: poetry install | ||
|
|
||
| - name: Run linter check | ||
| run: poetry run ruff check . | ||
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 |
|---|---|---|
| @@ -1,61 +1,60 @@ | ||
| import os | ||
|
|
||
| import click | ||
|
|
||
|
|
||
| def github_action_range(): | ||
| before_sha = os.getenv("BEFORE_SHA") | ||
| push_base_sha = os.getenv("BASE_SHA") | ||
| pr_base_sha = os.getenv("PR_BASE_SHA") | ||
| default_branch = os.getenv("DEFAULT_BRANCH") | ||
| head_sha = os.getenv("GITHUB_SHA") | ||
| ref = os.getenv("GITHUB_REF") | ||
|
|
||
| click.echo(f"{before_sha}, {push_base_sha}, {pr_base_sha}, {default_branch}, {head_sha}, {ref}") | ||
| before_sha = os.getenv('BEFORE_SHA') | ||
| push_base_sha = os.getenv('BASE_SHA') | ||
| pr_base_sha = os.getenv('PR_BASE_SHA') | ||
| default_branch = os.getenv('DEFAULT_BRANCH') | ||
| head_sha = os.getenv('GITHUB_SHA') | ||
| ref = os.getenv('GITHUB_REF') | ||
|
|
||
| click.echo(f'{before_sha}, {push_base_sha}, {pr_base_sha}, {default_branch}, {head_sha}, {ref}') | ||
| if before_sha and before_sha != NO_COMMITS: | ||
| return f"{before_sha}..." | ||
| return f'{before_sha}...' | ||
|
|
||
| return "..." | ||
| return '...' | ||
|
|
||
| # if pr_base_sha and pr_base_sha != FIRST_COMMIT: | ||
| # return f"{pr_base_sha}..." | ||
| # | ||
| # if push_base_sha and push_base_sha != "null": | ||
| # return f"{push_base_sha}..." | ||
|
|
||
|
|
||
| def circleci_range(): | ||
| before_sha = os.getenv("BEFORE_SHA") | ||
| current_sha = os.getenv("CURRENT_SHA") | ||
| commit_range = f"{before_sha}...{current_sha}" | ||
| click.echo(f"commit range: {commit_range}") | ||
| before_sha = os.getenv('BEFORE_SHA') | ||
| current_sha = os.getenv('CURRENT_SHA') | ||
| commit_range = f'{before_sha}...{current_sha}' | ||
| click.echo(f'commit range: {commit_range}') | ||
|
|
||
| if not commit_range.startswith('...'): | ||
| return commit_range | ||
|
|
||
| commit_sha = os.getenv("CIRCLE_SHA1", "HEAD") | ||
| commit_sha = os.getenv('CIRCLE_SHA1', 'HEAD') | ||
|
|
||
| return f'{commit_sha}~1...' | ||
|
|
||
|
|
||
| def gitlab_range(): | ||
| before_sha = os.getenv("CI_COMMIT_BEFORE_SHA") | ||
| commit_sha = os.getenv("CI_COMMIT_SHA", "HEAD") | ||
| before_sha = os.getenv('CI_COMMIT_BEFORE_SHA') | ||
| commit_sha = os.getenv('CI_COMMIT_SHA', 'HEAD') | ||
|
|
||
| if before_sha and before_sha != NO_COMMITS: | ||
| return f"{before_sha}..." | ||
| return f'{before_sha}...' | ||
|
|
||
| return f"{commit_sha}" | ||
| return f'{commit_sha}' | ||
|
|
||
|
|
||
| def get_commit_range(): | ||
| if os.getenv("GITHUB_ACTIONS"): | ||
| if os.getenv('GITHUB_ACTIONS'): | ||
| return github_action_range() | ||
| elif os.getenv("CIRCLECI"): | ||
| if os.getenv('CIRCLECI'): | ||
| return circleci_range() | ||
| elif os.getenv("GITLAB_CI"): | ||
| if os.getenv('GITLAB_CI'): | ||
| return gitlab_range() | ||
| else: | ||
| raise click.ClickException("CI framework is not supported") | ||
|
|
||
| raise click.ClickException('CI framework is not supported') | ||
|
|
||
|
|
||
| NO_COMMITS = "0000000000000000000000000000000000000000" | ||
| NO_COMMITS = '0000000000000000000000000000000000000000' |
Oops, something went wrong.
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.