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

Publish React Native Bridge to Bintray from CI #3230

Merged
merged 33 commits into from
Mar 26, 2021

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Mar 8, 2021


This PR adds CI jobs to build and publish the AAR for the react-native-bridge package (which lives in Gutenberg).

I originally planned to open this against the gutenberg-composite-build project WIP branch, but given this doesn't change anything in the codebase itself other than the Gutenberg submodule hash, I think develop is appropriate.

To test:

  1. Verify that CI builds
  2. Head over to Test - Use RN Gutenberg bridge built from the gutenberg-mobile CI WordPress-Android#14215 which uses the binary published from here and:
  • Verify it builds in CI
  • Verify you can run the app and use the editor locally, making sure the localGutenbergMobile path in your local-builds.gradle is commented out, otherwise it'll kick off a composite build, which won't use the binary.

PR submission checklist:

  • I have considered adding unit tests where possible. (N.A.)
  • I have considered if this change warrants user-facing release notes more info and have added them to RELEASE-NOTES.txt if necessary. (N.A.)

mokagio and others added 11 commits March 3, 2021 16:31
This is a key step in allowing the Android app to build without the
overhead of the `gutenberg-mobile` submodule.

Currently, there is a manual step to unlock the process if the Android
tests passed. That's because of how long it takes for the build step to
run: ~15 minutes.

Eventually, it would be great to have some intelligence in the PR to be
able to determine whether it should start a build for the Android
bridge.
@mokagio mokagio changed the title Point Gutenberg to the RN composite build support branch Publish React Native Bridge to Bintray from CI Mar 9, 2021
mokagio added a commit to wordpress-mobile/WordPress-Android that referenced this pull request Mar 9, 2021
mokagio added a commit to wordpress-mobile/WordPress-Android that referenced this pull request Mar 9, 2021
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Mar 9, 2021

Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job!

Comment on lines 288 to 289
# The build process for the react-navite-bridge requires the App.js
# bundle and also access to the node_modules folder.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I a link to the line of code that requires node_modules diff on GitHub once the PR for that is merged?

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
# The build process for the react-navite-bridge requires the App.js
# bundle and also access to the node_modules folder.
# The build process for the react-native-bridge requires the App.js and the node_modules folder.

We technically don't need the node_modules once the bundle is created. However, without it configuration gets a bit messy. I don't think it's worth adding a link here and I am hoping we can work towards not needing the node_modules folder.

.circleci/config.yml Outdated Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
@mokagio
Copy link
Contributor Author

mokagio commented Mar 9, 2021

I'm not sure where all those package-lock.json changes came from... I checked out a new branch from develop, pointed Gutenberg to the same hash as here, deleted the node_modules folder, and run npm install and nothing changed in the file 🤔

steps:
- checkout
- checkout-submodules
- npm-install
Copy link
Contributor

Choose a reason for hiding this comment

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

The name is misleading :-) This actually runs npm ci as expected 👍

.gitmodules Outdated
@@ -1,6 +1,6 @@
[submodule "gutenberg"]
path = gutenberg
url = ../../WordPress/gutenberg.git
url = [email protected]:oguzkocer/gutenberg.git
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure this is intentional to test this PR, but I'm leaving this comment just to make sure this is not something which fell between the cracks :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct & great idea!

mokagio added a commit to wordpress-mobile/WordPress-Android that referenced this pull request Mar 17, 2021
Copy link
Contributor Author

@mokagio mokagio left a comment

Choose a reason for hiding this comment

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

@mchowning @cameronvoell @ceyhun @loremattei here's an updated version of the workflow that incorporates the versioning workflow discussed internally and most of your suggestions.

Can I ask you to have another look?

I updated the test PR on WordPress Android to use the binary from the latest CI build, if you want to verify it builds and works.

Comment on lines +274 to +281
# This is a partial duplication of the logic to compute the version
# to use for the AAR from below. It's useful to have it here
# because there are conditions under which we shouldn't run the job
# that can't be captured in a CircleCI filter.
#
# Exiting here saves a non-trivial amount of CI time because of how
# heavy the repo is to checkout (it takes at least 1 minute) and
# how time consuming running `npm ci` is.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per comment, I tried having this in a dedicated script, but the repo checkout takes at least 1 minute.

On the other hand, the builds that would actually exit from here are a small % of the total builds running on this repo 🤔 Maybe by taking that into consideration the cost in CI has less weight than the duplication cost here?

Keen to hear your thoughts. It's a straightforward change to make, but it might be best to make it in a followup PR, just so we can get this moving along.

Comment on lines +298 to +303
- run:
# Setting up Android before fetching the Node dependencies because
# this step is faster, so if it fails we'll learn about it sooner and
# avoid wasting cycles.
name: Setup Android Tooling
command: .circleci/setup-android-on-ubuntu.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ceyhun suggested looking into spinning up a Docker container to avoid this manual setup.

I definitely want to look into it but opted for this approach which I already know works for this first version (which has already been dragging along for a while 😞 )

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @mokagio 🙇 This already looks awesome and we can surely improve it later once we have it in place and working first 👍

# isn't a PR open for it yet.
echo "Running on a feature branch with no open PR."
echo "The checks previous to this step should not have let this happen."
exit 1
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 decided to fail the build here because if this happen there's something wrong in the setup and we should know about it sooner rather than later.

filters:
branches:
# Don't run on trunk, otherwise, run on every other branch
ignore: trunk
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 reason I set this to not run on trunk is that from my understanding of our workflows discussions, we never need to access a build from that branch.

Copy link
Contributor

@mchowning mchowning Mar 17, 2021

Choose a reason for hiding this comment

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

I believe that all of our release tags are made on trunk. I may just not be understanding how this CI job is used.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @mchowning!

Every time a tag is pushed, this workflow will run and upload an AAR with the version being the tag name. See this build for an example: it started from GitHub receiving the tag mokagio-test-20210317-173215 and uploaded a binary to Bintray with version mokagio-test-20210317-173215.

Do you ever need to reference in WordPress Android a commit from gutenbreg-mobile's trunk that has not a matching tag? If that's the case, I can easily make builds on trunk behave like builds on develop: publish a trunk-< commit SHA1 > version to Bintray.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you ever need to reference in WordPress Android a commit from gutenbreg-mobile's trunk that has not a matching tag?

I don't think so. As long as all the tags get pushed we should be fine. 👍

# We end up here on the first push of a new branch, when there
# isn't a PR open for it yet.
echo "Build initiated from a feature branch with no pull request: aborting."
circleci-agent step halt
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This build is an example of this scenario

image

Unfortunately, CircleCI doesn't treat halts differently and the UI might be misleading as it looks like the build passed.

Comment on lines +408 to +410
tags:
# Run for every tag
only: /.*/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's an example of build from a tag: mokagio-test-20210317-173215.

@mokagio mokagio requested review from ceyhun and loremattei March 17, 2021 08:53
@mokagio
Copy link
Contributor Author

mokagio commented Mar 26, 2021

@cameronvoell @mchowning @oguzkocer the tests still fail, even after syncing with develop and the latest WordPress/gutenberg#29488, which is synced with Gutenberg's trunk.

This is the failure on both steps:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:testDebugUnitTest'.
> Could not resolve all task dependencies for configuration ':app:debugUnitTestRuntimeClasspath'.
   > Could not find org.wordpress-mobile:hermes-debug-mirror:0.61.5.
     Searched in the following locations:
       - file:/home/circleci/.m2/repository/org/wordpress-mobile/hermes-debug-mirror/0.61.5/hermes-debug-mirror-0.61.5.pom
       - file:/home/circleci/project/gutenberg/node_modules/react-native/android/org/wordpress-mobile/hermes-debug-mirror/0.61.5/hermes-debug-mirror-0.61.5.pom
       - https://dl.google.com/dl/android/maven2/org/wordpress-mobile/hermes-debug-mirror/0.61.5/hermes-debug-mirror-0.61.5.pom
       - https://jcenter.bintray.com/org/wordpress-mobile/hermes-debug-mirror/0.61.5/hermes-debug-mirror-0.61.5.pom
       - https://jitpack.io/org/wordpress-mobile/hermes-debug-mirror/0.61.5/hermes-debug-mirror-0.61.5.pom
     Required by:
         project :app > project :android:react-native-bridge
diff of the error output between the two steps to show it's the same
4,5c4,5
< Could not determine the dependencies of task ':app:testDebugUnitTest'.
< > Could not resolve all task dependencies for configuration ':app:debugUnitTestRuntimeClasspath'.
---
> Could not determine the dependencies of task ':app:processDebugResources'.
> > Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.

🤔

I bet the issue has to do with this project not having the S3 repository where our mirror lives. Let's see if I can do something about it...

@mokagio
Copy link
Contributor Author

mokagio commented Mar 26, 2021

All green in CI 🎉 Thanks @oguzkocer for the help.

I'm going to turn this "Ready for review" even though the "Before merging this PR, we need to merge WordPress/gutenberg#29488 into Gutenberg's trunk and update the submodule has here" hasn't been checked yet.

@mchowning @cameronvoell let me know if you think we should merge before or after the Gutenberg counterpart lands into Gutenberg's trunk. I'm writing this in my Friday EOD, so feel free to take the PR over and merge it if you want, without waiting for me.

@mokagio mokagio marked this pull request as ready for review March 26, 2021 05:50
Copy link
Contributor

@mchowning mchowning left a comment

Choose a reason for hiding this comment

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

@mchowning mchowning enabled auto-merge March 26, 2021 21:41
@mchowning mchowning merged commit 2d631f6 into develop Mar 26, 2021
@mchowning mchowning deleted the mokagio/publish-to-bintray-with-script branch March 26, 2021 22:15
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.

5 participants