Skip to content
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

Add remote, parent & child configuration features #3058

Merged
merged 5 commits into from
Nov 22, 2020

Conversation

fredpi
Copy link
Collaborator

@fredpi fredpi commented Jan 28, 2020

This PR closes #1352 and #2729.

It's basically the same as #2824, but I squashed all commits to keep it more comprehensible.

Change Overview

  • Using multiple configurations is now documented extensively in the README
  • You can now specify child_config / parent_config configurations. This even works recursively, as long as there are no cycles and no ambiguities.
  • Nested configurations got a speed bump (via caching) and of course now ignore configs that were already used to build the primary config (using child_config / parent_config references)
  • You can pass multiple configurations via the command line that are interpreted as a hierarchy
  • You can specify a remote child_config / parent_config! This is just easy as dropping in a url that starts with http://or https:// where normally there would be the path to a local file. Remote configs get cached (in a manner that git doesn't see it). There are timeouts to loading remote configs, that can also be customized using remote_timeout / remote_timeout_if_cached
  • Rule Configurations now get merged properly (Previously, the rule configurations from the parent configuration were always used). This change results in the following behavior:
    • When a child config doesn't configure a rule, yet the parent config does, the parent config will be used
    • When a child config configures a rule, and the parent doesn't, the child config will be used
    • When a child config configures a rule, and the parent does, too, the child config will be used
  • Warnings about duplicate and invalid identifiers now appear as actual warnings in Xcode
  • Internally, the whole Configuration clutter has been cleaned up in a way that I hope everyone is happy with. I strongly felt like the current merging implementation that relied on a rules array and a rulesMode didn't express the very foundation of what a configuration is: A mode that is applied to an array of all available rules with configurations, resulting in an array of rules that should be linted. To express this very relation, I created the new RulesWrapper type. While offering a resultingRules variable that is lazily computed, it still retains what caused these rules and therefore eases understanding of the merging algorithm.

Sidenote: Fixed Warnings in Moya

SwiftLintBot will probably complain that, with this new implementation, 3 warnings in Moya are now fixed. In fact, previously those have been false positives, as in the nested .swiftlint.yml covering these files there's the following configuration for the file_length rule:

file_length:
  warning: 1000

As the parent rule configuration was used for merging and there was no smart mechanism to decide which configuration to choose, the configuration originating from the nested configuration was ignored. With this PR, that's now fixed.

@SwiftLintBot
Copy link

SwiftLintBot commented Jan 28, 2020

1 Warning
⚠️ Big PR
12 Messages
📖 Linting Aerial with this PR took 1.97s vs 1.94s on master (1% slower)
📖 Linting Alamofire with this PR took 2.85s vs 2.83s on master (0% slower)
📖 Linting Firefox with this PR took 9.42s vs 9.42s on master (0% slower)
📖 Linting Kickstarter with this PR took 15.64s vs 15.69s on master (0% faster)
📖 Linting Moya with this PR took 1.46s vs 1.41s on master (3% slower)
📖 Linting Nimble with this PR took 1.34s vs 1.35s on master (0% faster)
📖 Linting Quick with this PR took 0.59s vs 0.63s on master (6% faster)
📖 Linting Realm with this PR took 4.41s vs 4.39s on master (0% slower)
📖 Linting SourceKitten with this PR took 1.08s vs 1.06s on master (1% slower)
📖 Linting Sourcery with this PR took 7.25s vs 7.33s on master (1% faster)
📖 Linting Swift with this PR took 11.31s vs 11.32s on master (0% faster)
📖 Linting WordPress with this PR took 17.54s vs 17.58s on master (0% faster)

Generated by 🚫 Danger

@fredpi
Copy link
Collaborator Author

fredpi commented Jan 28, 2020

@jpsim I added the missing tests (didn't come up with a proper idea how to test remote configs though), so this is now finally ready for review 🎉

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch 2 times, most recently from 0f4ef95 to 3dbff86 Compare January 30, 2020 09:39
@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from 3dbff86 to 97b61d7 Compare February 11, 2020 15:17
@fredpi
Copy link
Collaborator Author

fredpi commented Feb 11, 2020

I just rebased to fix merge conflicts

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from 97b61d7 to e92efda Compare February 14, 2020 22:16
@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from e92efda to 0f38492 Compare March 13, 2020 14:56
@fredpi
Copy link
Collaborator Author

fredpi commented Mar 13, 2020

I just rebased to fix conflicts.

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch 2 times, most recently from e141d25 to 12e1795 Compare April 7, 2020 20:12
@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from 12e1795 to 707ccf3 Compare April 15, 2020 05:37
@fredpi
Copy link
Collaborator Author

fredpi commented Apr 15, 2020

I just rebased to fix conflicts.

@mokagio
Copy link
Contributor

mokagio commented Jun 12, 2020

Is there anything I can do to help this get merged and shipped?

@fredpi
Copy link
Collaborator Author

fredpi commented Jun 17, 2020

@mokagio Thanks for asking and offering your help! 👍

From my side, this PR is ready and only needs a review. But as it changes a lot of things quite significantly, such a review

  • will take time
  • should preferably be done by someone with in-depth-knowledge about this project (like @jpsim or @marcelofabri)

But as this is a big PR and especially with the current situation, nobody can blame them for not having reviewed this yet or expect them to review this right now.

So, what you can do, is what you already did: Test this PR in real projects (and post your results in this thread), so that we can find bugs or other issues that may still exist. That's really helpful and gives confidence that this PR actually works in real environments! 🚀

Also, if you have the time, you may also do a review! I just think that @jpsim or @marcelofabri or another experienced SwiftLint contributor should approve this PR, but that doesn't say that other opinions aren't valuable!

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from d95c3ac to 9eaafc7 Compare June 27, 2020 10:07
@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from 9eaafc7 to de94775 Compare August 9, 2020 09:34
@fredpi
Copy link
Collaborator Author

fredpi commented Aug 9, 2020

I just rebased to fix merge conflicts.

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from de94775 to e51a40b Compare August 11, 2020 21:00
@codecov-commenter
Copy link

codecov-commenter commented Aug 11, 2020

Codecov Report

Merging #3058 into master will decrease coverage by 0.37%.
The diff coverage is 74.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3058      +/-   ##
==========================================
- Coverage   90.58%   90.21%   -0.38%     
==========================================
  Files         416      423       +7     
  Lines       20406    21033     +627     
==========================================
+ Hits        18484    18974     +490     
- Misses       1922     2059     +137     
Impacted Files Coverage Δ
...rk/Extensions/Configuration+IndentationStyle.swift 100.00% <ø> (ø)
...urce/SwiftLintFramework/Helpers/Reachability.swift 0.00% <0.00%> (ø)
Source/swiftlint/Commands/AnalyzeCommand.swift 0.00% <0.00%> (ø)
Source/swiftlint/Commands/AutoCorrectCommand.swift 0.00% <0.00%> (ø)
Source/swiftlint/Commands/LintCommand.swift 0.00% <0.00%> (ø)
Source/swiftlint/Commands/RulesCommand.swift 0.00% <0.00%> (ø)
...iftlint/Extensions/Configuration+CommandLine.swift 0.00% <0.00%> (ø)
Source/swiftlint/Helpers/CommonOptions.swift 0.00% <ø> (ø)
...ource/swiftlint/Helpers/LintOrAnalyzeCommand.swift 0.00% <0.00%> (ø)
Tests/SwiftLintFrameworkTests/RuleTests.swift 82.66% <ø> (ø)
... and 57 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9ce579...6a19709. Read the comment docs.

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from e51a40b to 6a19709 Compare September 13, 2020 14:32
@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from 6a19709 to 92efddf Compare October 7, 2020 16:39
@fredpi fredpi requested a review from jpsim October 7, 2020 16:40
@codecov-io
Copy link

codecov-io commented Oct 7, 2020

Codecov Report

Merging #3058 into master will decrease coverage by 0.31%.
The diff coverage is 74.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3058      +/-   ##
==========================================
- Coverage   90.48%   90.17%   -0.32%     
==========================================
  Files         417      424       +7     
  Lines       20508    21135     +627     
==========================================
+ Hits        18557    19058     +501     
- Misses       1951     2077     +126     
Impacted Files Coverage Δ
...rk/Extensions/Configuration+IndentationStyle.swift 100.00% <ø> (ø)
...urce/SwiftLintFramework/Helpers/Reachability.swift 0.00% <0.00%> (ø)
Source/swiftlint/Commands/AnalyzeCommand.swift 0.00% <0.00%> (ø)
Source/swiftlint/Commands/AutoCorrectCommand.swift 0.00% <0.00%> (ø)
Source/swiftlint/Commands/LintCommand.swift 0.00% <0.00%> (ø)
Source/swiftlint/Commands/RulesCommand.swift 0.00% <0.00%> (ø)
...iftlint/Extensions/Configuration+CommandLine.swift 0.00% <0.00%> (ø)
Source/swiftlint/Helpers/CommonOptions.swift 0.00% <ø> (ø)
...ource/swiftlint/Helpers/LintOrAnalyzeCommand.swift 0.00% <0.00%> (ø)
Tests/SwiftLintFrameworkTests/RuleTests.swift 82.66% <ø> (ø)
... and 60 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da408b5...92efddf. Read the comment docs.

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch 2 times, most recently from 00f4a59 to 8a7018d Compare November 9, 2020 23:08
@fredpi
Copy link
Collaborator Author

fredpi commented Nov 9, 2020

Quick update: I finished the rebase and implemented the review feedback, but noticed that I still have to take a closer look on the rootPath / configurationPath semantics again. I hope to find some time for this within the next days.

@fredpi fredpi mentioned this pull request Nov 10, 2020
2 tasks
@sethfri
Copy link
Contributor

sethfri commented Nov 11, 2020

@fredpi This is incredible! I'd love to look this over and give feedback if you'd like once you're done finishing up what you mentioned in your last comment.

That said, this has been outstanding for a long time, so I don't blame you if you just want to get it merged

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from 8a7018d to 39e8d84 Compare November 14, 2020 19:51
@fredpi
Copy link
Collaborator Author

fredpi commented Nov 15, 2020

@sethfri While I didn't test everything myself yet, I don't see any major issues anymore, so I'd love it if you would try out the PR and report any issues you see! 👍 Also, it would be great if you could have a look at the new behavior specification for multiple configurations in the README and tell me whether you agree with these specifications.

Of course, before this will get merged, I will also test everything myself again.

@fredpi
Copy link
Collaborator Author

fredpi commented Nov 15, 2020

@mokagio It would be great if you could also report whether this PR is still working for you ;)

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from abc9a61 to ed50938 Compare November 16, 2020 21:42
mokagio added a commit to wordpress-mobile/WordPress-iOS-Shared that referenced this pull request Nov 19, 2020
@mokagio
Copy link
Contributor

mokagio commented Nov 19, 2020

@fredpi hey there! You're awesome for relentlessly working on this ❤️

I updated our experiment repo to use ed50938bb955f224bf9146eb0b89e1368e4aca67. It builds and runs fine, both locally and on CI. 👍

The only thing I noticed is that it's not respecting the excluded setting 🤔 .

As you can see in this CI build we're getting violation warnings from files in the Pods/ folder, but that's [excluded in the remote config being used].(https://github.com/Automattic/swiftlint-config/blob/59fc2405960928f7fddb6a5e0fb77b6ce8d6f9c5/.swiftlint.yml#L2-L3)

Screenshot included because as I discovered GitHub Actions doesn't retain the logs indefinitely (for free repos, at least). The first couple of lines are from a file in Pods/ and unexpected, the last from one of the sources in the project and expected.

image

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from 3e8317b to a37d448 Compare November 20, 2020 00:11
@fredpi
Copy link
Collaborator Author

fredpi commented Nov 20, 2020

@mokagio Thanks for the feedback! 😃

I could reconstruct and understand the bug with the excluded paths being ignored (+ write a test for it). With the latest commit (a37d4487f071463b619a6ff7367edcb50daeb5ca) the bug should be fixed now. Would it be possible for you to test the latest version again and confirm whether the issue is now gone?

mokagio added a commit to wordpress-mobile/WordPress-iOS-Shared that referenced this pull request Nov 20, 2020
@mokagio
Copy link
Contributor

mokagio commented Nov 20, 2020

@fredpi thank you for your quick work! I updated to a37d4487f071463b619a6ff7367edcb50daeb5ca and it all looks good no. See this CI run.

👍 🙌 👏

@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from 4d094b8 to 3d20e27 Compare November 20, 2020 21:49
@fredpi fredpi force-pushed the feature/remote-child-parent-configs branch from 3d20e27 to 4c5a3f0 Compare November 20, 2020 22:09
@fredpi
Copy link
Collaborator Author

fredpi commented Nov 21, 2020

I have added some more tests, tested the PR myself again and feel quite confident now that everything is working properly. So, if no new concerns get raised until then, I'm going to merge this on Sunday.

@sethfri If you still want to take a look at this and don't have the time to do it until Sunday, please tell me – I would then delay the merging.

@fredpi fredpi merged commit b8f5b6a into master Nov 22, 2020
@fredpi fredpi deleted the feature/remote-child-parent-configs branch November 22, 2020 09:56
norio-nomura added a commit that referenced this pull request Dec 4, 2020
Provides:
- a runtime environment on ubuntu that does not include the Swift toolchain.
- supportintg `docker build https://github.com/realm/SwiftLint.git`
- add `libcurl4-openssl-dev` as build time dependency that introduced by #3058
@norio-nomura norio-nomura mentioned this pull request Dec 4, 2020
@mokagio
Copy link
Contributor

mokagio commented Dec 7, 2020

I'm so happy this is in! ❤️

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.

Enhancement: Allow inclusion of multiple configuration files
7 participants