Does anyone have any experience setting up GitHub ...
# kotlin-native
r
Does anyone have any experience setting up GitHub Actions for Kotlin native to support building the different Konan targets from https://kotlinlang.org/docs/native-target-support.html? So far, I have
linuxX64
,
macosX64
, and
mingwX64
figured out, and have a
konan-target
and associated
os
matrix parameter for those. Note: I just need the GitHub Action script settings, I know how to pass that to the build script.
b
r
That's interesting, thanks! I'm building my own template for my projects at https://github.com/rhdunn/kotlin-multilpatform-template, and in that I'm doing things slightly differently to the way you are doing. From the GitHub Actions, I cannot see how you are getting things like: 1.
macosArm64
-- how are you specifying the Apple Silicon OS so that the
HostManager.host
property gets set to
KonanTarget.MACOS_ARM64
? 2. Is there anything needed to install to get the Apple simulator (
iosSimulatorArm64
and
iosX64
) working? 3.
linuxArm64
-- how are you specifying a Linux Arm64 (aarch64) OS to build this target? (NOTE: It looks like this variant isn't calculated by the
HostManager.host
property in
kotlin-native-utils
.) 4. How are you configuring/building for the Apple watchOS and tvOS targets in Tier 2 and 3? 5. How are you configuring the Android NDK for the android native targets in Tier 3?
b
Android ndk is preinstalled on gh runners For any native setup prerequisites (like simulator) there's scripts/install.sh that gets ran before gradle. The rest was not a thing at the time I've written that template.
Oh, there's a mapping between host os and targets that should be built in build-conventions
r
Thanks!
m
But be aware that there are currently no ARM based GitHub hosted runners. That’s the reason why I currently can’t build and package my app for macosArm64.
c
You will need to setup private runner. It can be a VM on AWS EC2 Graviton using https://docs.github.com/en/actions/hosting-your-own-runners
m
Yes, that’s why I explicitly said “GitHub hosted”. Of course I can set up “self hosted” runners (and they do already support other architectures than Intel) but that was just too much work, especially as I am currently looking into an alternative (Conveyor) where you can build for all platforms from your own (any) machine. Let’s see how that works out 🙂.
r
note that you can cross-compile a lot of targets (though not everything). eg you can build a
linuxArm64()
target from a X64 linux host, and you can build
macosArm64()
and most linux targets from a macos host. You just won't be able to run tests for targets that are cross-compiled.
l
CodeMagic supports M1 mac (and m2 now), but not sure if it's still just for paying accounts. It's not self hosted, and pretty easy to set up.
r
As a follow up to this, I decided to test all of these out. My observations are: 1. the builds all worked out of the box with no additional configuration -- just make sure they are run on the correct OS (ubuntu-latest, macos-latest, or windows-latest); 2. some of the targets do not support running tests -- I addressed this by setting a
run-tests
option in the build matrix, and used an
if: ${{ matrix.run-tests }}
on the step that was running
gradle nativeTest
; 3. some of the targets (android, wasm, some linux targets) were not supported by a dependency -- for those, I've just removed those targets from the GitHub Actions.