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

iOS: Add swiftlint as ios test #364

Merged
merged 15 commits into from
Jun 5, 2024
Merged

iOS: Add swiftlint as ios test #364

merged 15 commits into from
Jun 5, 2024

Conversation

nancywu1
Copy link
Contributor

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

Copy link

codecov bot commented May 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.70%. Comparing base (8c7089e) to head (a1bcda6).

Additional details and impacted files
@@           Coverage Diff            @@
##           bazel-6     #364   +/-   ##
========================================
  Coverage    91.70%   91.70%           
========================================
  Files          332      332           
  Lines        26714    26714           
  Branches      1935     1935           
========================================
  Hits         24499    24499           
  Misses        2202     2202           
  Partials        13       13           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ios/BUILD.bazel Outdated
"//plugins/types-provider/ios:PlayerUITypesProviderPluginTests"
"//plugins/types-provider/ios:PlayerUITypesProviderPluginTests",

"@SwiftLint//:swiftlint"
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this? did it end up doing something useful?

Comment on lines 60 to 87

native.sh_test(
name = name + "SwiftLint",
srcs = [":"+ name + "_Lint"],
visibility = ["//visibility:public"],
)

native.genrule(
name = name + "_Lint",
tools = [
"@SwiftLint//:swiftlint"
],
srcs = native.glob(["Sources/**/*.swift"]) + ["//:.swiftlint.yml"],
outs = ["output.sh"],
executable = True,
visibility = ["//visibility:public"],
cmd="""
echo `$(location @SwiftLint//:swiftlint) --config $(location //:.swiftlint.yml) $(SRCS) || true` > lint_results.txt
LINT=$$(cat lint_results.txt)

echo '#!/bin/bash' > $(location output.sh)
echo "echo '$$LINT'" > $(location output.sh)

LINESWITHERROR=$$(echo grep error lint_results.txt || true)
echo "exit $$(($$LINESWITHERROR) | wc -l)" >> $(location output.sh)
"""
)

Copy link
Contributor

Choose a reason for hiding this comment

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

can you move the lint definitions to the bottom of the macro?

The doc block has to be at the top of the function to meet the docstring format

tools = [
"@SwiftLint//:swiftlint"
],
srcs = native.glob(["Sources/**/*.swift"]) + ["//:.swiftlint.yml"],
Copy link
Contributor

Choose a reason for hiding this comment

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

if you move this further down the macro, you can use the same target to refer to sources that we use for the swift_library and for bundling the zip

Suggested change
srcs = native.glob(["Sources/**/*.swift"]) + ["//:.swiftlint.yml"],
srcs = [":" + name + "_Sources"] + ["//:.swiftlint.yml"],

BUILD.bazel Outdated
@@ -248,3 +248,6 @@ gazelle(
name = "update_build_files",
gazelle = ":gazelle_bin",
)

#SwiftLint
exports_files([".swiftlint.yml", "output.sh"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
exports_files([".swiftlint.yml", "output.sh"])
exports_files([".swiftlint.yml"])

@nancywu1 nancywu1 marked this pull request as ready for review June 5, 2024 13:58
@nancywu1 nancywu1 requested a review from adierkens as a code owner June 5, 2024 13:58
Copy link
Contributor

@hborawski hborawski left a comment

Choose a reason for hiding this comment

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

🚀

@nancywu1 nancywu1 enabled auto-merge (squash) June 5, 2024 17:48
@nancywu1 nancywu1 disabled auto-merge June 5, 2024 17:48
@nancywu1 nancywu1 merged commit 42d21b1 into bazel-6 Jun 5, 2024
8 of 10 checks passed
@nancywu1 nancywu1 deleted the add-swiftlint-dep branch June 5, 2024 17:49
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