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 a hack to patch cocoapods #78

Merged
merged 8 commits into from
Nov 29, 2023
Merged

Add a hack to patch cocoapods #78

merged 8 commits into from
Nov 29, 2023

Conversation

crazytonyli
Copy link
Contributor

This hack unblocks us from releasing libraries from CI. Hopefully CocoaPods can fix the issue properly and we can remove this hack soon.

This change is tested in this build.


  • I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary.

This hack unblocks us from releasing libraries from CI. Hopefully
CocoaPods can fix the issue properly and we can remove this hack soon.
@crazytonyli crazytonyli requested a review from a team November 28, 2023 22:51
bin/publish_pod Outdated
@@ -10,6 +10,9 @@ if [ -n "$BUILDKITE_TAG" ] && [ "$BUILDKITE_TAG" != "$POD_VERSION" ]; then
exit 1
fi

echo "⚠️ Remove the patch-cocoapods step once this issue is fixed: https://github.com/CocoaPods/CocoaPods/issues/12033"
patch-cocoapods
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we shouldn't instead let the caller projects call patch-cocoapods before they call validate_pod and publish_pod in their own .buildkite/commands/*.sh scripts.

The reason I suggest separating those is because the patch depends on the version of CocoaPods being installed. If/when CocoaPods releases a new version with this issue fixed, some projects will adopt the new version quickly while others might take more time.

At least by letting the caller script decide, it will be easier once the new CP version arrives to just update CP in the project's Gemfile.lock then stop calling patch-cocoapods on the buildkite scripts in the same PR updating CP, rather than having to release a new version of a8c-ci-toolkit that will remove that patch's call… but then only work with projects that updated CocoaPods.

If we strongly couple the version of a8c-ci-toolkit with the version of CocoaPods used, if some projects want to update CocoaPods but are not ready to update a8c-ci-toolkit (eg say there was a major version of the toolkit since for unrelated changes, and the project isn't ready to adopt those yet) they'd be stuck.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main reason for putting this script here is: install_gems overwrites the local gems, so patch-cocoapods needs to run straight after install_gems. Also, it'd be nice to avoid copying scripts among libraries repos.

But I agree with you it's not ideally that this script may break pipelines.

Initially I tried to add an optional plugin configuration to the plugin, patch-cocoapods: true, but I can't get the environment variable BUILDKITE_PLUGIN_A8C_CI_TOOLKIT_PATCH_COCOAPODS to work: it doesn't exist even though the new option is set in pipeline.

What do you think adding a new option to the existing shell script, like validate_podspec --patch_cocoapods?

Copy link
Contributor

Choose a reason for hiding this comment

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

The main reason for putting this script here is: install_gems overwrites the local gems, so patch-cocoapods needs to run straight after install_gems. Also, it'd be nice to avoid copying scripts among libraries repos.

Ah. Damn.

Initially I tried to add an optional plugin configuration to the plugin, patch-cocoapods: true, but I can't get the environment variable BUILDKITE_PLUGIN_A8C_CI_TOOLKIT_PATCH_COCOAPODS to work: it doesn't exist even though the new option is set in pipeline.

Just checking: did you declare the additional plugin config parameter in plugin.yml here (then pointed to the commit that added it in your WPKiOS pipeline) when you attempted that?

iinm, the plugin has additionalProperties: false in its plugin.yml config, so all additional properties have to be declared explicitly in plugin.yml for them to be exposed as env var and then accessible within the plugin.

That being said…

What do you think adding a new option to the existing shell script, like validate_podspec --patch_cocoapods?

I actually think that's probably a better approach 👍 so that the option is tied to the commands that need it instead of to the whole plugin (especially wouldn't make sense to expose that option to app / non-pod repos, which use the a8c-ci-toolkit plugin… but never call validate_pod nor publish_pod in their context)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

did you declare the additional plugin config parameter in plugin.yml

Yes, I did. I tried naming it as patch-cocoapods, patch_cocoapods. I tried declaring it as string, boolean. None worked...


I have implemented the new --patch_cocoapods argument in the new commits. And this test job passed.

Comment on lines 46 to 47
echo "$patch_content" | patch --reverse --force --directory "$cocoapods_gem_path" --strip 0
echo "$patch_content" | patch --forward --force --directory "$cocoapods_gem_path" --strip 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Funny how one line has the ; but not the other 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙈 It's an copy-paste error. Removed in 6e15474

@crazytonyli crazytonyli enabled auto-merge (squash) November 29, 2023 21:15
@crazytonyli crazytonyli disabled auto-merge November 29, 2023 21:15
@crazytonyli crazytonyli enabled auto-merge (squash) November 29, 2023 21:17
@crazytonyli
Copy link
Contributor Author

I will publish a 3.0.1 release after this PR is merged.

@crazytonyli crazytonyli merged commit e2fecd5 into trunk Nov 29, 2023
4 checks passed
@crazytonyli crazytonyli deleted the hack-to-patch-cocoapods branch November 29, 2023 21:20
crazytonyli added a commit to wordpress-mobile/WordPressKit-iOS that referenced this pull request Nov 29, 2023
This will unblock us from testing and release pod from CI. See [this PR][PR] for details.

[PR]: Automattic/a8c-ci-toolkit-buildkite-plugin#78
crazytonyli added a commit to wordpress-mobile/WordPressAuthenticator-iOS that referenced this pull request Nov 29, 2023
This will unblock us from testing and release pod from CI. See [this PR][PR] for details.

[PR]: Automattic/a8c-ci-toolkit-buildkite-plugin#78
crazytonyli added a commit to wordpress-mobile/WordPressAuthenticator-iOS that referenced this pull request Nov 29, 2023
This will unblock us from testing and release pod from CI. See [this PR][PR] for details.

[PR]: Automattic/a8c-ci-toolkit-buildkite-plugin#78
mokagio added a commit to Automattic/Automattic-Tracks-iOS that referenced this pull request Dec 14, 2023
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