Skip to content

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Feb 15, 2023

Summary of Changes

Fixes # (if applicable - add the number of issue this PR addresses)
Enable SwiftLint in GitHub Actions but disable the failing tests that cannot be auto-fixed so that we do not backslide on the tests that currently pass.

Test Data or Screenshots

By submitting this pull request, you are confirming the following:
  • I have reviewed the Contribution Guidelines.
  • I have performed a self-review of my own code.
  • I have updated my repository to match the develop branch.
  • I have included test data or screenshots that prove my fix is effective or that my feature works.
  • I have checked that all tests work and swiftlint is not throwing any errors/warnings.

@JeneaVranceanu
Copy link
Collaborator

I'm not sure I understand these changes in combination with the description you gave:

disable the failing tests so that we do not backslide on the tests that currently pass

I do not see anything being disabled here.

@cclauss cclauss marked this pull request as draft February 15, 2023 10:36
@cclauss cclauss changed the title pre-commit: SwiftLint: Disable failing tests Draft: pre-commit: SwiftLint: Disable failing tests Feb 15, 2023
@cclauss
Copy link
Contributor Author

cclauss commented Feb 15, 2023

Yes. Moving to Draft status so I can see/fix/disable errors in GHA runs.

@cclauss cclauss marked this pull request as ready for review February 15, 2023 17:26
@cclauss cclauss changed the title Draft: pre-commit: SwiftLint: Disable failing tests pre-commit: SwiftLint: Disable failing tests Feb 15, 2023
@cclauss
Copy link
Contributor Author

cclauss commented Feb 15, 2023

GitHub Actions can run pre-commit in 25 seconds if we remove SwiftLint.

SwiftLint --fix can run in 25 seconds on the macOS-12 GHA job.

Future pull requests can remove more items from disabled_rules in .swiftlint.yml.

@cclauss
Copy link
Contributor Author

cclauss commented Feb 15, 2023

Please let me know what changes should be made.

janndriessen
janndriessen previously approved these changes Feb 18, 2023
Copy link
Collaborator

@janndriessen janndriessen left a comment

Choose a reason for hiding this comment

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

LGTM now. Since I don't know much about the pre-commit configs, I'll let @JeneaVranceanu give the final approval.

@janndriessen janndriessen mentioned this pull request Feb 18, 2023
4 tasks
@cclauss
Copy link
Contributor Author

cclauss commented Feb 18, 2023

On --fix GitHub Actions will not write the fixed code into a commit (like pre-commit.ci would) so the fixes done in GitHub Actions are being lost in the ether. If swiftlint is confident that it can make a simple text correction (add a whitespace, etc.) then the error is probably not worth disabling.

- run: pip install pre-commit
- run: pre-commit --version
- run: pre-commit install
- run: pre-commit run --all-files
Copy link
Collaborator

Choose a reason for hiding this comment

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

@cclauss I am a little bit confused.
All this is good but now we'll have codespell running in macOS-tests.yml and in pre-commit.yml if we open a PR against develop branch. And when swiftlint will be enabled in pre-commit-config.yaml (and I think it should be enabled now with the update you made to disabled_rules) we will have both swiftlint and codespell running twice.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What was again the purpose of this workflow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Enable SwiftLint in GitHub Actions but disable the failing tests that cannot be auto-fixed so that we do not backslide on the tests that currently pass.

@JeneaVranceanu
Copy link
Collaborator

On --fix GitHub Actions will not write the fixed code into a commit (like pre-commit.ci would) so the fixes done in GitHub Actions are being lost in the ether. If swiftlint is confident that it can make a simple text correction (add a whitespace, etc.) then the error is probably not worth disabling.

I see only one really useful use case for the pre-commit.ci and its feature of fixing and pushing the results of swiftlint --fix back to the branch: if we will have contributions from other people that will not follow the code style requirements it can be fixed to some extent by the CI.

Comment on lines +12 to +46
- block_based_kvo
- closure_body_length
- computed_accessors_order
- cyclomatic_complexity
- duplicate_imports
- empty_enum_arguments
- empty_string
- file_length
- for_where
- force_cast
- force_try
- force_unwrapping
- function_body_length
- function_parameter_count
- identifier_name
- implicit_getter
- implicitly_unwrapped_optional
- indentation_width
- large_tuple
- legacy_objc_type
- line_length
- multiple_closures_with_trailing_closure
- nesting
- orphaned_doc_comment
- operator_whitespace
- return_arrow_whitespace
- shorthand_operator
- todo
- trailing_closure
- type_body_length
- type_name
- unneeded_break_in_switch
- unused_optional_binding
- vertical_parameter_alignment
- xctfail_message
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the effort!
I think it will be easier to fix issues one by one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll resume fixes as soon as this PR is merged but for now, there are a few questions.

@cclauss
Copy link
Contributor Author

cclauss commented Feb 18, 2023

Correct that pre-commit.ci’s key differentiator is that it can commit auto-fixes so that humans don’t have to.

@cclauss
Copy link
Contributor Author

cclauss commented Feb 21, 2023

What else is required on this pr?

@JeneaVranceanu
Copy link
Collaborator

What else is required on this pr?

Reviewing now. Will let you know soon.

@JeneaVranceanu
Copy link
Collaborator

@yaroslavyaroslav Please, be informed about the pros of using pre-commit CI: #781 (comment)

@JeneaVranceanu
Copy link
Collaborator

@cclauss Done with the review. Looks good.
Now waiting for CI to complete.

@cclauss
Copy link
Contributor Author

cclauss commented Feb 21, 2023

Nice. It will be good to have guardrails in place on those SwiftLint tests that already pass.

@JeneaVranceanu JeneaVranceanu merged commit 985210c into web3swift-team:develop Feb 21, 2023
@cclauss cclauss deleted the patch-1 branch February 21, 2023 17:27
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