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

Fix cache directory resolution when using remote config file #3231

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Jun 10, 2020

I'm spiking using a centralized SwiftLint configuration across the Automattic's Swift repositories, as we have quite a few.

I used #3058 but it wasn't working. After a bit of digging around, I discovered the issue had to do with how the cache directory path was build, or to be precise resolved as an absolute path.

You can see the SwiftLint build failing here (although the message is a bit misleading) and succeeding here, with the only change being that the former uses #3058 as the source for SwiftLint and the latter this PR.

I would have liked to add tests for this fix, but the only way I could see would have been to add an abstraction on FileManager in order to provide a test double for it in the test. That seemed like a lot of work as well as a substantial change in the design of this code, which is not on master yet. I opted for simply fixing the production code, instead. If you can think of a quick way to add tests which would fit in the context of this PR, I'd love to make that happen.

Thank you for working on this @fredpi. It's super useful, I really love this feature.

mokagio added 2 commits June 10, 2020 16:33
In the previous version, the absolute path resolution was called on a
fragment of the path, resulting in SwiftLint creating the cache in a
different path from the one used to search for the cache.
This should help prevent future issues building the path.
@SwiftLintBot
Copy link

1 Warning
⚠️ Please include a CHANGELOG entry to credit yourself!
You can find it at CHANGELOG.md.
12 Messages
📖 Linting Aerial with this PR took 1.45s vs 1.44s on master (0% slower)
📖 Linting Alamofire with this PR took 2.64s vs 2.62s on master (0% slower)
📖 Linting Firefox with this PR took 8.67s vs 8.67s on master (0% slower)
📖 Linting Kickstarter with this PR took 14.33s vs 14.51s on master (1% faster)
📖 Linting Moya with this PR took 1.24s vs 1.32s on master (6% faster)
📖 Linting Nimble with this PR took 1.27s vs 1.34s on master (5% faster)
📖 Linting Quick with this PR took 0.6s vs 0.63s on master (4% faster)
📖 Linting Realm with this PR took 2.58s vs 2.6s on master (0% faster)
📖 Linting SourceKitten with this PR took 1.02s vs 1.04s on master (1% faster)
📖 Linting Sourcery with this PR took 6.6s vs 6.76s on master (2% faster)
📖 Linting Swift with this PR took 12.58s vs 12.71s on master (1% faster)
📖 Linting WordPress with this PR took 15.69s vs 16.01s on master (1% faster)

Here's an example of your CHANGELOG entry:

* Fix cache directory resolution when using remote config file.  
  [mokagio](https://github.com/mokagio)
  [#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by 🚫 Danger

@fredpi
Copy link
Collaborator

fredpi commented Jun 10, 2020

@mokagio Thanks for trying out the PR and fixing this! 🚀

Apart from the little restructuring you did, the only change seems to be the removal of / before building the path. I'm just wondering why it didn't fail when I tested it – maybe because the path was already there from a previous version? 🤔

Thanks again for fixing it – looks good to me and I'm going to merge it into my branch. If you want, you can create another PR, adding your name to the changelog section in my branch. 👍

@fredpi fredpi merged commit d2f4f94 into realm:feature/remote-child-parent-configs Jun 10, 2020
@mokagio
Copy link
Contributor Author

mokagio commented Jun 11, 2020

Thank you for the quick review 🙌

maybe because the path was already there from a previous version? 🤔

I'd say that's likely. I experienced different error messages depending on whether the .swiftlint folder was there or not.

mokagio added a commit to wordpress-mobile/WordPress-iOS-Shared that referenced this pull request Jun 11, 2020
Now that my PR has been merged into it
realm/SwiftLint#3231
mokagio added a commit to wordpress-mobile/WordPress-iOS-Shared that referenced this pull request Jun 11, 2020
Now that my PR has been merged into it
realm/SwiftLint#3231
mokagio added a commit to wordpress-mobile/WordPress-iOS-Shared that referenced this pull request Nov 19, 2020
Now that my PR has been merged into it
realm/SwiftLint#3231
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.

3 participants