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

Update bazel version to 3.0.0 and latest rules #45

Merged
merged 1 commit into from
Apr 22, 2020

Conversation

gyfelton
Copy link
Contributor

@gyfelton gyfelton commented Apr 16, 2020

  1. Update bazel to 3.0.0 and fixes a bug where we pass mutable values (dict/list) to depset for env var and launch arguments for tests. Instead we pass tuples to ensure correct data is passed in a safer way.
  2. Added tests on actual project side to ensure they will fail should the passing of the env var and launch arg not done correcetly.
  3. Fixed test case failure due to latest bazel_swift rule update due to adding of modules maps from non-swift code, which is sth we don't anticipate.

Copy link
Member

@segiddins segiddins left a comment

Choose a reason for hiding this comment

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

ERROR: /Users/runner/runners/2.169.0/work/rules_ios/rules_ios/tests/xcodeproj/BUILD.bazel:4:1: in //rules:xcodeproj.bzl%_xcodeproj_aspect aspect on _ios_internal_unit_test_bundle rule //tests/xcodeproj:Single-Application-UnitTests.__internal__.__test_bundle: 
Traceback (most recent call last):
	File "/Users/runner/runners/2.169.0/work/rules_ios/rules_ios/tests/xcodeproj/BUILD.bazel", line 4
		//rules:xcodeproj.bzl%_xcodeproj_aspect(...)
	File "/Users/runner/runners/2.169.0/work/rules_ios/rules_ios/rules/xcodeproj.bzl", line 58, in _xcodeproj_aspect_impl
		_TargetInfo(target = info, <1 more arguments>)
	File "/Users/runner/runners/2.169.0/work/rules_ios/rules_ios/rules/xcodeproj.bzl", line 58, in _TargetInfo
		depset([info], <1 more arguments>)

Looks like that will need to be changed to be immutable

rules/repositories.bzl Show resolved Hide resolved
README.md Show resolved Hide resolved
rules/repositories.bzl Outdated Show resolved Hide resolved
rules/repositories.bzl Show resolved Hide resolved
@gyfelton gyfelton force-pushed the elton/update_bazel_version branch from 6aa87c5 to 1fb34f8 Compare April 17, 2020 21:50
@gyfelton
Copy link
Contributor Author

@segiddins does it actually check if the generated xcodeproj works? I saw there is a check to see if bazel generates a different xcodeproj file, but it does not actuall test the project. I am at least adding some tests that will fail if I did not do the passing of test env correctly

README.md Outdated

[Click here](https://github.com/ob/rules_ios/tree/master/doc)
for the documentation.
Bazel version required by tThese rules is [here](https://github.com/ob/rules_ios/blob/master/.bazelversion)
Copy link
Member

Choose a reason for hiding this comment

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

typo


## Reference documentation

[Click here](https://github.com/ob/rules_ios/tree/master/doc)

This comment was marked as resolved.

This comment was marked as resolved.

@@ -155,6 +155,12 @@ def _apple_framework_packaging_impl(ctx):

# collect modulemaps
for modulemap in dep[apple_common.Objc].direct_module_maps:
# rule_swift changed how non swift generates module map in this commit
Copy link
Member

Choose a reason for hiding this comment

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

thanks for the comment here!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused about the original implementation here, as well as the change. If we assign modulemap_in to the modulemap on every iteration, aren't we just assigning modulemap_in with the last value in the array direct_module_maps ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have the same question actually! @segiddins

@@ -17,6 +17,7 @@
48A8F4B41EF706F8BEEC7ACB /* Single-Application-UnitTests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = "Single-Application-UnitTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
5FF81A9585DBB110EBD9CAC0 /* test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = test.swift; path = test.swift; sourceTree = "<group>"; };
8DBB99CE021DEB0B97F196EA /* common.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = common.pch; path = ../../rules/library/common.pch; sourceTree = "<group>"; };
BDFE1D6BB539968405F979CA /* Single_Application_UnitTests-Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Single_Application_UnitTests-Swift.h"; path = "Single_Application_UnitTests-Swift.h"; sourceTree = "<group>"; };
Copy link
Member

Choose a reason for hiding this comment

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

cc @amberdixon on this getting added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this expected?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't know why this is getting added, but I'm seeing this in my PRs too. The underlying reason is that the Swift.h file is being treated as a source file (i.e. running File.is_source on it returns true), even though the file is actually being generated by one of the rules in rules_swift. Perhaps we can leave it here and make a note to remove it later, after figuring out why it's being added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have expectation that no file change should happen to project file?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, because there is a check in CI for git diff --nocheck ... so if the xcodeproj rule generates a project that is different from the one checked in already, then the CI job will fail.

I'm not sure why the -Swift.h file is showing up in the bazel target's sources as an actual source (because it's really a generated file.) Because it appears to be an actual source, the xcodeproj rule adds this file to the generated xcodeproject.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will deal with this in future: #49

@gyfelton gyfelton changed the title Update bazel version and rules Update bazel version to 3.0.0 and latest rules Apr 17, 2020
@gyfelton
Copy link
Contributor Author

@segiddins While u continue to review, I am going to test this with our app repo and inform u on what works and what does not

Copy link
Member

@segiddins segiddins left a comment

Choose a reason for hiding this comment

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

Looks good to me, other than the -Swift.h file getting added, curious what @amberdixon has to say about that

@@ -17,6 +17,7 @@
48A8F4B41EF706F8BEEC7ACB /* Single-Application-UnitTests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = "Single-Application-UnitTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
5FF81A9585DBB110EBD9CAC0 /* test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = test.swift; path = test.swift; sourceTree = "<group>"; };
8DBB99CE021DEB0B97F196EA /* common.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = common.pch; path = ../../rules/library/common.pch; sourceTree = "<group>"; };
BDFE1D6BB539968405F979CA /* Single_Application_UnitTests-Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Single_Application_UnitTests-Swift.h"; path = "Single_Application_UnitTests-Swift.h"; sourceTree = "<group>"; };
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't know why this is getting added, but I'm seeing this in my PRs too. The underlying reason is that the Swift.h file is being treated as a source file (i.e. running File.is_source on it returns true), even though the file is actually being generated by one of the rules in rules_swift. Perhaps we can leave it here and make a note to remove it later, after figuring out why it's being added.

@@ -4,5 +4,12 @@ class SwiftTests : XCTestCase {
func testPasses() {
XCTAssertTrue(true)
}
func testTestEnvArgsMatches() {
XCTAssertEqual(ProcessInfo.processInfo.environment["test_envvar_key1"], "test_envvar_value1")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is fine to add here, but FYI, we aren't actually running these tests in CI.

I will probably run these tests as part of CI in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am actually considering to try to add this into CI in this PR (otherwise my change has no effect)

@@ -155,6 +155,12 @@ def _apple_framework_packaging_impl(ctx):

# collect modulemaps
for modulemap in dep[apple_common.Objc].direct_module_maps:
# rule_swift changed how non swift generates module map in this commit
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused about the original implementation here, as well as the change. If we assign modulemap_in to the modulemap on every iteration, aren't we just assigning modulemap_in with the last value in the array direct_module_maps ?

@gyfelton
Copy link
Contributor Author

@amberdixon added the CI job in the workflow, can take a look?


cd $(dirname $0)

xcodebuild -project Single-Application-Project.xcodeproj -quiet -scheme Single-Application-UnitTests test
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 putting these in! LGTM

@gyfelton
Copy link
Contributor Author

waiting for Sam's PR to merge so that I don't add the -Swift.h generated file

@gyfelton gyfelton force-pushed the elton/update_bazel_version branch from ea7a3a5 to ced37b6 Compare April 21, 2020 22:11
Update rules_apple and rules_swift to latest commit on their respective repo

Added a stage to run unit tests inside the sample app application
@gyfelton gyfelton force-pushed the elton/update_bazel_version branch from ced37b6 to 3c972d6 Compare April 21, 2020 22:14
@gyfelton gyfelton merged commit 73a4a1f into bazel-ios:master Apr 22, 2020
@gyfelton gyfelton deleted the elton/update_bazel_version branch April 22, 2020 14:43
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