Skip to content

Add a soundness check to lint Python files #14

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 1 commit into from
Oct 11, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Oct 3, 2024

No description provided.

@ahoppen ahoppen requested a review from shahmishal as a code owner October 3, 2024 23:58
ahoppen added a commit to ahoppen/swift-format that referenced this pull request Oct 4, 2024
ahoppen added a commit to ahoppen/swift-format that referenced this pull request Oct 4, 2024
@ahoppen ahoppen force-pushed the python-lint branch 3 times, most recently from 6460120 to ac9d4de Compare October 9, 2024 16:09
@ahoppen ahoppen requested a review from FranzBusch October 10, 2024 00:22
Copy link
Member

@shahmishal shahmishal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shahmishal
Copy link
Member

@FranzBusch, please feel free to merge it once you’ve reviewed it.

@FranzBusch
Copy link
Member

I just merged your other PR @ahoppen but now that I think about it again we might want to fold this into the Swift format PR after all. The reason why is that each new check here is producing a separate check on the repos. Now most repos don't have all the languages. It might be better to just have one general formatting job that does

  • Shellcheck
  • swift-format
  • yamlint
  • python lint
  • etc.
    WDYT?

@ahoppen
Copy link
Member Author

ahoppen commented Oct 10, 2024

I don’t have a strong personal opinion here:

I think the advantages of having a single job are:

  • We only create a single item in the status check for a PR, which is less noisy

The disadvantages are:

  • Running swift-format requires us to use a Swift container, all other tools can run on the image itself. So, either we need to install yamllint etc. in the container or have one job for swift-format and one for all the things that can run on the runner itself.
  • If eg. yamllint fails, we probably won’t continue execution, which means that you might only find the shellcheck issues after fixing all YAML issues. Probably not a huge problem in practice though.
  • If you disable a check, we would just skip it in the job and wouldn’t mark it as skipped in the GitHub PR check UI. Not sure if that’s an advantage or disadvantage though.

@shahmishal What’s your opinion?

@shahmishal
Copy link
Member

Having checks for each lang format/lint makes it easier to figure out what failed. Normally people will ignore all of the green check marks and focus on failures.

@ahoppen
Copy link
Member Author

ahoppen commented Oct 10, 2024

OK, sounds like we want to stick with separate jobs for each lint then.

Copy link
Member

@FranzBusch FranzBusch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay let's proceed with this then. Just some naming nits to stay consistent

@@ -59,6 +59,10 @@ on:
type: boolean
description: "Boolean to enable the YAML lint job. Defaults to true."
default: true
python_lint_enabled:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
python_lint_enabled:
python_lint_check_enabled:

@@ -59,6 +59,10 @@ on:
type: boolean
description: "Boolean to enable the YAML lint job. Defaults to true."
default: true
python_lint_enabled:
type: boolean
description: "Boolean to enable the Python lint job. Defaults to true."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "Boolean to enable the Python lint job. Defaults to true."
description: "Boolean to enable the Python lint check job. Defaults to true."

@@ -200,3 +204,18 @@ jobs:
run: |
curl -s https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/configs/yamllint.yml > /tmp/yamllint.yml
yamllint --strict --config-file /tmp/yamllint.yml ${GITHUB_WORKSPACE}
python-lint:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
python-lint:
python-lint-check:

@@ -200,3 +204,18 @@ jobs:
run: |
curl -s https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/configs/yamllint.yml > /tmp/yamllint.yml
yamllint --strict --config-file /tmp/yamllint.yml ${GITHUB_WORKSPACE}
python-lint:
name: Python lint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Python lint
name: Python lint check

@ahoppen
Copy link
Member Author

ahoppen commented Oct 11, 2024

Should we go the opposite way and remove check from all of these jobs? It feels redundant to me because I would expect all CI jobs to check something.

@ahoppen ahoppen requested a review from a team as a code owner October 11, 2024 22:02
@ahoppen
Copy link
Member Author

ahoppen commented Oct 11, 2024

Discussed offline that we want to use check in the name.

@ahoppen ahoppen merged commit 5411ae3 into swiftlang:main Oct 11, 2024
8 checks passed
@ahoppen ahoppen deleted the python-lint branch October 11, 2024 22:04
persist-credentials: false
- name: Run flake8
run: |
pip3 install flake8 flake8-import-order --break-system-packages
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you may know, it seems that ubuntu-latest on GitHub-hosted runners is currently in the process of migrating to Ubuntu 24.04. Until it's completed, Ubuntu 22.04 may be used, and on Ubuntu 22.04, this command will fail because its pip3 is old and does not have --break-system-packages.

Announcement: actions/runner-images#10636

Failure case: https://github.com/kkebo/swift-format/actions/runs/11299915833/job/31431847497

Since the migration will be completed soon, I think we can ignore it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixed it: #28

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants