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

re-enable customer center tests in main #4170

Closed
wants to merge 2 commits into from

Conversation

aboedo
Copy link
Member

@aboedo aboedo commented Aug 12, 2024

We weren't running tests for Customer Center in PRs, since the CUSTOMER_CENTER_ENABLED flag is disabled.

This could be dangerous, so this PR enables the flag in the absolutely dumbest way I could think of: just replace the instances where the flag is used with true, before running tests, i.e.:

// before
#if CUSTOMER_CENTER_ENABLED

// after
#if true

It's easy to extend to other test suites. It could also have been its own test suite but I felt like it wouldn't have added much, we would have ended up most tests twice for no real gain.

@aboedo aboedo added the test label Aug 12, 2024
@aboedo aboedo requested a review from a team August 12, 2024 15:15
@aboedo aboedo self-assigned this Aug 12, 2024
Comment on lines +490 to +499
Find.find(project_root) do |path|
# process only Swift files
next unless File.file?(path) && File.extname(path) == ".swift"

content = File.read(path)

updated_content = content.gsub('CUSTOMER_CENTER_ENABLED', 'true')

File.write(path, updated_content) if content != updated_content
end
Copy link
Member Author

Choose a reason for hiding this comment

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

would have been shorter as a find + sed, but this is much easier to read IMO

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I guess the fastlane commands to run tests are only run through CI normally, so this is probably ok... We could also make a sort of "block" so we restore it once tests finish, but I don't think it's worth it 👍

@aboedo
Copy link
Member Author

aboedo commented Aug 12, 2024

image confirmed that tests are in fact running for Customer Center

Copy link
Member

@JayShortway JayShortway left a comment

Choose a reason for hiding this comment

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

😚👌

Copy link
Contributor

@tonidero tonidero 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!

Comment on lines +490 to +499
Find.find(project_root) do |path|
# process only Swift files
next unless File.file?(path) && File.extname(path) == ".swift"

content = File.read(path)

updated_content = content.gsub('CUSTOMER_CENTER_ENABLED', 'true')

File.write(path, updated_content) if content != updated_content
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I guess the fastlane commands to run tests are only run through CI normally, so this is probably ok... We could also make a sort of "block" so we restore it once tests finish, but I don't think it's worth it 👍

@@ -472,6 +479,28 @@ platform :ios do
}
end

desc "Enable Customer Center"
lane :enable_customer_center do
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick but should we make this a private lane?

Suggested change
lane :enable_customer_center do
private_lane :enable_customer_center do

@aboedo
Copy link
Member Author

aboedo commented Aug 12, 2024

closing in favor of #4171

@aboedo aboedo closed this Aug 12, 2024
jamesrb1 added a commit that referenced this pull request Aug 12, 2024
Customer Center is currently `#ifdef`ed out via
`CUSTOMER_CENTER_ENABLED` while it is under development, but we want to
run its tests during development. This defines `CUSTOMER_CENTER_ENABLED`
for `OTHER_SWIFT_FLAGS` via the command line build arguments for test
lanes, which will override the project settings, so the tests are run.

This PR can be reverted when the customer centre is released.

‼️This PR is not needed if we go for the [source-processing
method](#4170) instead.
@aboedo aboedo deleted the andy/add_tests_for_customer_center_to_main branch August 14, 2024 14:23
nyeu pushed a commit that referenced this pull request Oct 2, 2024
Customer Center is currently `#ifdef`ed out via
`CUSTOMER_CENTER_ENABLED` while it is under development, but we want to
run its tests during development. This defines `CUSTOMER_CENTER_ENABLED`
for `OTHER_SWIFT_FLAGS` via the command line build arguments for test
lanes, which will override the project settings, so the tests are run.

This PR can be reverted when the customer centre is released.

‼️This PR is not needed if we go for the [source-processing
method](#4170) instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants