nodejs-mobile / nodejs-mobile

Full-fledged Node.js on Android and iOS
https://nodejs-mobile.github.io
Other
458 stars 44 forks source link

Adds CI builds based on Github Actions #60

Open tritao opened 6 months ago

tritao commented 6 months ago

As the title says, this adds CI actions which hopefully should hopefully make continuous testing and PR / release management a lot more manageable.

I've tried to keep things simple and re-use as much of the existing scripts as possible.

The main idea is we launch multiple jobs based on a build matrix for all the necessary configurations. We need to do it this way for disk space and CI runtime reasons.

I still need to put a bit more work into this, the current build scripts for iOS expect to have the builds for multiple architectures locally to build the final unified framework. For this to work with this CI build matrix architecture, we will need to launch a special job once all the initial macOS jobs end, to gather the intermediate artifacts and issue the final framework unification build.

This should be pretty doable (I've done a similar kind of system before to gather per-architecture builds to build a final package).

staltz commented 6 months ago

Hey @tritao can you limit your PR to have only the CI changes? Not the extra compilation changes made to Android configuration and iOS framework preparation.

tritao commented 6 months ago

Hey @tritao can you limit your PR to have only the CI changes? Not the extra compilation changes made to Android configuration and iOS framework preparation.

The changes to iOS framework preparation are vital for the CI builds to work. The Android ones are necessary for things to build with Android NDK r26b, but those can be taken out for now if we use earlier NDKs available by default on Actions.

The changes to iOS framework preparation script are backwards compatible, that is, if you invoke the script without any arguments, then you get the same behavior as before. I added a new single argument where you can choose which step of the script you want to take, since it's not possible to do a complete in-sequence build on CI, so we build each architecture on a separate build step. Which is how the Android build script works too.

I made an initial commit which only refactors the existing code, with no functional changes: https://github.com/nodejs-mobile/nodejs-mobile/pull/60/commits/ded63e4c41dc341b1632f63066b98accf6e922bf

Then the main CI commit adds arguments to it, and fixes an issue in the framework building step (the Xcode project), which was trying to link to x64-only libraries in ARM64 builds, and vice-versa, which is the only effective change in behavior:

  # Remove libraries that do not exist for this target
  cp $XCODE_PROJECT_PATH $XCODE_PROJECT_PATH.bak
  for output_file in "${outputs_x64_only[@]}"; do
    grep -vF "$output_file" $XCODE_PROJECT_PATH > temp && mv temp $XCODE_PROJECT_PATH
  done

You can see my progress on the builds here btw: https://github.com/tritao/nodejs-mobile/actions/runs/6678570009

There is only an issue with the unified iOS framework building step I added later: https://github.com/tritao/nodejs-mobile/actions/runs/6679592817/job/18152999075

Just need to fix this one and this should be ready to go.