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 lint command #1043

Merged
merged 10 commits into from
Mar 3, 2020
Merged

Add lint command #1043

merged 10 commits into from
Mar 3, 2020

Conversation

pepicrft
Copy link
Contributor

@pepicrft pepicrft commented Mar 2, 2020

Short description 📝

This PR adds a new command, tuist lint, that teams can run to validate on CI whether the project has a valid configuration.

Solution 📦

I took part of the logic from the generator (graph loading + listing), and extracted it into an independent command. That way teams can lint the project without having to generate it.

Tasks ✅

  • Implement LintCommand.
  • Create TuistGeneratorTesting and extract some mocks into it.
  • Implement LintCommandTests (unit tests)
  • Add acceptance tests.
  • Update documentation.

@pepicrft pepicrft requested a review from a team March 2, 2020 09:00
@pepicrft pepicrft self-assigned this Mar 2, 2020
@ghost ghost requested review from kwridan and marciniwanicki and removed request for a team March 2, 2020 09:00
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2020

@pepibumur your pull request is missing a changelog!

@codecov
Copy link

codecov bot commented Mar 2, 2020

Codecov Report

Merging #1043 into master will decrease coverage by 0.15%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1043      +/-   ##
==========================================
- Coverage   79.00%   78.84%   -0.16%     
==========================================
  Files         237      238       +1     
  Lines       11259    11346      +87     
==========================================
+ Hits         8895     8946      +51     
- Misses       2364     2400      +36     
Impacted Files Coverage Δ
Sources/TuistKit/Commands/LintCommand.swift 66.21% <0.00%> (ø)

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 9803ab6...ceabd74. Read the comment docs.

Copy link
Collaborator

@kwridan kwridan left a comment

Choose a reason for hiding this comment

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

👍

This aligns well with #1007 to allow leveraging different pieces of the generator without generation. Will rebase onto this branch when it lands.

Happy path:

$ tuist lint
Loading the dependency graph
Loading project at /path/to/tuist/fixtures/ios_app_with_static_frameworks
Running linters
Linting the environment
Linting the loaded dependency graph
Success: No linting issues found

Introduced an issue (duplicate static linking) and it flagged it as before:

$ tuist lint
Loading the dependency graph
Loading project at /path/to/tuist/fixtures/ios_app_with_static_frameworks
Running linters
Linting the environment
Linting the loaded dependency graph
Warning: - Target "B" has been linked against ["App", "D"], it is a static product so may introduce unwanted side effects.

public required convenience init(parser: ArgumentParser) {
let manifestLoader = ManifestLoader()
let generatorModelLoader = GeneratorModelLoader(manifestLoader: manifestLoader,
manifestLinter: AnyManifestLinter())
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't it worth also linting manifests here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact, the first implementation used the manifest linter. However, if that validation fails it'd exit immediately and not run the other linters. Since the manifest linter just runs one validation, and I doubt we'll add more there. I think it's safe to leave it out. If we see we end up adding more validations there, we might consider changing the logic here.

@pepicrft pepicrft merged commit dc27574 into master Mar 3, 2020
@pepicrft pepicrft deleted the lint branch March 3, 2020 07:23
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.

2 participants