Skip to content

GHA: Enable Sync Tests #522

GHA: Enable Sync Tests

GHA: Enable Sync Tests #522

Workflow file for this run

name: PR Build
on:
pull_request:
paths-ignore:
- '**.md'
env:
REALM_DISABLE_ANALYTICS: true
CMAKE_C_COMPILER: /usr/local/opt/ccache/libexec/clang
CMAKE_CXX_COMPILER: /usr/local/opt/ccache/libexec/clang++
RELEASE_BRANCHES: "[ 'master', 'releases', 'feature/github-actions' ]"
REALM_QA_URL: https://realm-qa.mongodb.com
ATLAS_QA_URL: https://cloud-qa.mongodb.com
jobs:
static-analysis:
uses: ./.github/workflows/include-static-analysis.yml
deploy-baas:
name: Deploy BAAS Cluster
uses: ./.github/workflows/include-deploy-baas.yml
with:
BaseUrl: https://realm-qa.mongodb.com
AtlasBaseUrl: https://cloud-qa.mongodb.com
secrets:
AtlasProjectId: ${{ secrets.ATLAS_QA_PROJECT_ID }}
AtlasPublicKey: ${{ secrets.ATLAS_QA_PUBLIC_API_KEY }}
AtlasPrivateKey: ${{ secrets.ATLAS_QA_PRIVATE_API_KEY }}
check-cache:
uses: ./.github/workflows/include-check-cache.yml
# TODO The actual build takes 45 seconds. Is there a reason we do this? Is it because swig doesn't work on Windows?
build-jni-swig-stub:
runs-on: ubuntu-latest
needs: check-cache
if: needs.check-cache.outputs.jni-swig-stub-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
- name: Load build cache
uses: actions/cache@v3
with:
path: ./packages/jni-swig-stub/build/generated/sources/jni
key: jni-swig-stubs-${{ needs.check-cache.outputs.packages-sha }}
# Manually install SWIG 4.1.0 as only 4.0.2 is pre-installed
# 4.1.0 is not available in apt-get, so use brew instead
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#ubuntu-22041-lts
# It seems to be required to manually add brew dirs to the PATH. This does not happen automatically.
- name: Install SWIG
run: |
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile
echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile
brew install swig
echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH
- name: Build JNI Stub
working-directory: ./packages
run: ./gradlew :jni-swig-stub:assemble -PignoreNativeLibs=true
# TODO Do we need to cache something or just built it every time?
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: jni-stub-${{ needs.check-cache.outputs.version-label }}
path: ./packages/jni-swig-stub/build/generated/sources/jni/*
retention-days: 1
build-jvm-linux-native-lib:
runs-on: ubuntu-latest
needs: [check-cache, build-jni-swig-stub]
if: always() &&
(needs.build-jni-swig-stub.result == 'success' || needs.build-jni-swig-stub.result == 'skipped') &&
needs.check-cache.outputs.jni-linux-lib-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Setup build cache
uses: actions/cache@v3
with:
path: ./packages/cinterop/src/jvmMain/linux-build-dir
key: jni-linux-lib-${{ needs.check-cache.outputs.packages-sha }}
- name: Restore JNI Swig Stubs
uses: actions/download-artifact@v3
with:
name: jni-stub-${{ needs.check-cache.outputs.version-label }}
path: ./packages/jni-swig-stub/build/generated/sources/jni
- name: Build Docker image
uses: docker/build-push-action@v3
with:
tags: jvm-native-lib-linux:latest
file: ./packages/cinterop/src/jvmMain/generic.Dockerfile
push: false
- name: Build native lib
uses: addnab/docker-run-action@v3
with:
image: jvm-native-lib-linux:latest
shell: bash
options: -v ${{ github.workspace }}:/work
run: |
cd /work/packages/cinterop/src/jvmMain/
rm -rf linux-build-dir
mkdir linux-build-dir
cd linux-build-dir
cmake ../../jvm
make -j8
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: jni-linux-lib-${{ needs.check-cache.outputs.version-label }}
path: ./packages/cinterop/src/jvmMain/linux-build-dir/librealmc.so
retention-days: 1
# TODO Is the `if` check enough? Should we also compare the swig stub?
build-jvm-windows-native-lib:
runs-on: windows-latest
needs: [check-cache, build-jni-swig-stub]
if: always() &&
(needs.build-jni-swig-stub.result == 'success' || needs.build-jni-swig-stub.result == 'skipped') &&
needs.check-cache.outputs.jni-windows-lib-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# TODO See https://github.com/microsoft/vcpkg/issues/25349 which might describe the error here https://github.com/realm/realm-kotlin/runs/8099890473?check_suite_focus=true
# -- Building for: Visual Studio 17 2022
# -- Running vcpkg install
# Error: while checking out port openssl with git tree 7e4d802e3bde4154c227c0dd1da75c719be9f07a
# Error: Failed to tar port directory
# error: tar failed with exit code: (128).
# fatal: not a tree object: 7e4d802e3bde4154c227c0dd1da75c719be9f07a
# TODO Implement better work-around here: https://mongodb.slack.com/archives/C017MBM0A30/p1661889411467029?thread_ts=1661888738.117769&cid=C017MBM0A30
fetch-depth: 0
submodules: "recursive"
- name: Setup build cache
uses: actions/cache@v3
with:
path: ./packages/cinterop/src/jvmMain/windows-build-dir
key: jni-windows-lib-${{ needs.check-cache.outputs.packages-sha }}
enableCrossOsArchive: true
- name: Restore JNI Swig Stubs
uses: actions/download-artifact@v3
with:
name: jni-stub-${{ needs.check-cache.outputs.version-label }}
path: ${{ github.workspace }}/packages/jni-swig-stub/build/generated/sources/jni
- name: Build native lib
shell: powershell
working-directory: packages
run: |
cd cinterop\src\jvmMain
Remove-Item -Path windows-build-dir -Force -Recurse -ErrorAction Ignore
mkdir windows-build-dir
cd windows-build-dir
cmake `
..\..\jvm `
-DCMAKE_GENERATOR_PLATFORM=x64 `
-DCMAKE_BUILD_TYPE=Release `
-DREALM_ENABLE_SYNC=ON `
-DREALM_NO_TESTS=1 `
-DVCPKG_TARGET_TRIPLET=x64-windows-static
cmake --build . --config Release
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: jni-windows-lib-${{ needs.check-cache.outputs.version-label }}
path: ./packages/cinterop/src/jvmMain/windows-build-dir/Release/realmc.dll
retention-days: 1
# TODO If building jvm lib for windows fails, this step just skips instead of failing the entire build, why?
build-jvm-packages:
runs-on: macos-latest
needs: [check-cache, build-jvm-linux-native-lib, build-jvm-windows-native-lib]
if: always() &&
(needs.build-jvm-linux-native-lib.result == 'success' || needs.build-jvm-linux-native-lib.result == 'skipped') &&
(needs.build-jvm-windows-native-lib.result == 'success' || needs.build-jvm-windows-native-lib.result == 'skipped') &&
needs.check-cache.outputs.packages-jvm-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
# TODO I'm not sure this catches changes to our Config.kt, what is the impact?
# https://github.com/actions/setup-java#caching-packages-dependencies
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
# TODO Default behavior is only caching from main/master. Unclear what the best caching strategy is for us.
# TODO What is the rules and limits for caching on Github -> 10 GB limit, automatic evicition
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
# TODO This cmake version is not being used by the Android builds. Figure out why.
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.25.2'
# TODO This Ninja version is not being used by the Android builds. Figure out why.
- name: Setup ninja
uses: cmelchior/setup-ninja@master
with:
version: '1.11.0'
# TODO This might not work on Windows: https://github.com/hendrikmuhs/ccache-action#notes-on-windows-support
- name: Install ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
max-size: '2.0G'
- name: Prepend ccache executables to the PATH
run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
# TODO See https://github.com/hendrikmuhs/ccache-action/issues/94
- name: Configure ccache
run: |
ccache --set-config="compiler_check=content"
ccache --show-config
echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang
echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++
# TODO This matches 23.2.8568313, but what happens if we a define specific ndk version in our build?
- name: Setup NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r23c
- name: Debug environment
run: |
env
type cmake
cmake --version
type ninja
ninja --version
# TODO Figure out naming schema and retention policy
# We cannot use artifacts as they cannot be shared between workflows, so use cache instead.
- name: Setup build cache
uses: actions/cache@v3
with:
path: ./packages/build/m2-buildrepo
key: packages-m2-jvm-sync-${{ needs.check-cache.outputs.packages-sha }}
- name: Restore Linux JNI lib
uses: actions/download-artifact@v3
with:
name: jni-linux-lib-${{ needs.check-cache.outputs.version-label }}
path: ./packages/cinterop/src/jvmMain/linux-build-dir
- name: Restore Windows JNI lib
uses: actions/download-artifact@v3
with:
name: jni-windows-lib-${{ needs.check-cache.outputs.version-label }}
path: ./packages/cinterop/src/jvmMain/windows-build-dir/Release
- name: Build packages
working-directory: packages
run: ./gradlew publishCIPackages -Prealm.kotlin.targets=jvm -PcopyJvmABIs=true
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packages-jvm-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo/**/*
retention-days: 1
build-android-packages:
runs-on: ubuntu-latest
needs: check-cache
if: |
needs.check-cache.outputs.packages-android-cache-hit != 'true' ||
needs.check-cache.outputs.needs.check-cache.outputs.android-test-base-apk-cache-hit != 'true' ||
needs.check-cache.outputs.needs.check-cache.outputs.android-test-sync-apk-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
# TODO I'm not sure this catches changes to our Config.kt, what is the impact?
# https://github.com/actions/setup-java#caching-packages-dependencies
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
# TODO Default behavior is only caching from main/master. Unclear what the best caching strategy is for us.
# TODO What is the rules and limits for caching on Github -> 10 GB limit, automatic evicition
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
# Manually install SWIG 4.1.0 as only 4.0.2 is pre-installed
# 4.1.0 is not available in apt-get, so use brew instead
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#ubuntu-22041-lts
# It seems to be required to manually add brew dirs to the PATH. This does not happen automatically.
- name: Install SWIG
run: |
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile
echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile
brew install swig
echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH
# TODO This cmake version is not being used by the Android builds. Figure out why.
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.25.2'
# TODO This Ninja version is not being used by the Android builds. Figure out why.
- name: Setup ninja
uses: cmelchior/setup-ninja@master
with:
version: '1.11.0'
# TODO This might not work on Windows: https://github.com/hendrikmuhs/ccache-action#notes-on-windows-support
- name: Install ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
max-size: '2.0G'
- name: Prepend ccache executables to the PATH
run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
# TODO See https://github.com/hendrikmuhs/ccache-action/issues/94
- name: Configure ccache
run: |
ccache --set-config="compiler_check=content"
ccache --show-config
echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang
echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++
# TODO This matches 23.2.8568313, but what happens if we a define specific ndk version in our build?
- name: Setup NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r23c
- name: Debug environment
run: |
env
type cmake
cmake --version
type ninja
ninja --version
- name: Build Android Base Test Apk
working-directory: packages
run: ./gradlew :test-base:assembleAndroidTest -PignoreNativeLibs=true
- name: Build Android Sync Test Apk
working-directory: packages
run: |
./gradlew :test-sync:assembleAndroidTest -PignoreNativeLibs=true \
-PsyncTestUrl=https://realm-qa.mongodb.com \
-PsyncTestAppNamePrefix=and-devfarm-${{ needs.deploy-baas.outputs.runId }} \
-PsyncTestLoginPublicApiKey=${{ secrets.ATLAS_QA_PUBLIC_API_KEY }} \
-PsyncTestLoginPrivateApiKey=${{ secrets.ATLAS_QA_PRIVATE_API_KEY }} \
-PsyncTestClusterName=${{ needs.deploy-baas.outputs.clusterName }}
- name: Build packages
working-directory: packages
run: ./gradlew publishCIPackages -Prealm.kotlin.targets=android -PignoreNativeLibs=true
# TODO Figure out naming schema and retention policy
# We cannot use artifacts as they cannot be shared between workflows, so use cache instead.
- name: Store build cache
uses: actions/cache@v3
with:
path: ./packages/build/m2-buildrepo
key: packages-m2-android-sync-${{ needs.check-cache.outputs.packages-sha }}
- name: Store build cache for Android Test APK
uses: actions/cache@v3
with:
path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk
key: android-base-test-apk-key-${{ needs.check-cache.outputs.packages-sha }}
# TODO Must match naming found in include-check-cache.yml
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packages-android-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo/**/*
retention-days: 1
- name: Upload Android Base Test APK
uses: actions/upload-artifact@v3
with:
name: android-base-test-apk-${{ needs.check-cache.outputs.version-label }}
path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk
retention-days: 1
- name: Upload Android Sync Test APK
uses: actions/upload-artifact@v3
with:
name: android-sync-test-apk-${{ needs.check-cache.outputs.version-label }}
path: ./packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk
retention-days: 1
# TODO: ccache is not being used by this build for some reason
build-macos-x64-packages:
runs-on: macos-latest
needs: check-cache
# needs: static-analysis
if: needs.check-cache.outputs.packages-macos-x64-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
# TODO I'm not sure this catches changes to our Config.kt, what is the impact?
# https://github.com/actions/setup-java#caching-packages-dependencies
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
# TODO Default behavior is only caching from main/master. Unclear what the best caching strategy is for us.
# TODO What is the rules and limits for caching on Github -> 10 GB limit, automatic evicition
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
# TODO This cmake version is not being used by the Android builds. Figure out why.
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.25.2'
# TODO This Ninja version is not being used by the Android builds. Figure out why.
- name: Setup ninja
uses: cmelchior/setup-ninja@master
with:
version: '1.11.0'
# TODO This might not work on Windows: https://github.com/hendrikmuhs/ccache-action#notes-on-windows-support
- name: Install ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
max-size: '2.0G'
- name: Prepend ccache executables to the PATH
run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
# TODO See https://github.com/hendrikmuhs/ccache-action/issues/94
- name: Configure ccache
run: |
ccache --set-config="compiler_check=content"
ccache --show-config
echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang
echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++
- name: Debug environment
run: |
env
type cmake
cmake --version
type ninja
ninja --version
- name: Build packages
working-directory: packages
run: ./gradlew publishCIPackages -Prealm.kotlin.targets=macosX64 -PignoreNativeLibs=true
# TODO Figure out naming schema and retention policy
# We cannot use artifacts as they cannot be shared between workflows, so use cache instead.
- name: Store build cache
uses: actions/cache@v3
with:
path: ./packages/build/m2-buildrepo
key: packages-m2-macos-x64-sync-${{ needs.check-cache.outputs.packages-sha }}
# TODO Must match naming found in include-check-cache.yml
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packages-macos-x64-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo/**/*
retention-days: 1
# TODO: ccache is not being used by this build for some reason
build-macos-arm64-packages:
runs-on: macos-latest
needs: check-cache
# needs: static-analysis
if: needs.check-cache.outputs.packages-macos-arm64-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
# TODO I'm not sure this catches changes to our Config.kt, what is the impact?
# https://github.com/actions/setup-java#caching-packages-dependencies
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
# TODO Default behavior is only caching from main/master. Unclear what the best caching strategy is for us.
# TODO What is the rules and limits for caching on Github -> 10 GB limit, automatic evicition
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
# TODO This cmake version is not being used by the Android builds. Figure out why.
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.25.2'
# TODO This Ninja version is not being used by the Android builds. Figure out why.
- name: Setup ninja
uses: cmelchior/setup-ninja@master
with:
version: '1.11.0'
# TODO This might not work on Windows: https://github.com/hendrikmuhs/ccache-action#notes-on-windows-support
- name: Install ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
max-size: '2.0G'
- name: Prepend ccache executables to the PATH
run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
# TODO See https://github.com/hendrikmuhs/ccache-action/issues/94
- name: Configure ccache
run: |
ccache --set-config="compiler_check=content"
ccache --show-config
echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang
echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++
- name: Build packages
working-directory: packages
run: ./gradlew publishCIPackages -Prealm.kotlin.targets=macosArm64 -PignoreNativeLibs=true
# TODO Figure out naming schema and retention policy
# We cannot use artifacts as they cannot be shared between workflows, so use cache instead.
- name: Store build cache
uses: actions/cache@v3
with:
path: ./packages/build/m2-buildrepo
key: packages-m2-macos-arm64-sync-${{ needs.check-cache.outputs.packages-sha }}
# TODO Must match naming found in include-check-cache.yml
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packages-macos-arm64-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo/**/*
retention-days: 1
# TODO: ccache is not being used by this build for some reason
build-ios-x64-packages:
runs-on: macos-latest
needs: check-cache
# needs: static-analysis
if: needs.check-cache.outputs.packages-ios-x64-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
# TODO I'm not sure this catches changes to our Config.kt, what is the impact?
# https://github.com/actions/setup-java#caching-packages-dependencies
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
# TODO Default behavior is only caching from main/master. Unclear what the best caching strategy is for us.
# TODO What is the rules and limits for caching on Github -> 10 GB limit, automatic evicition
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
# TODO This cmake version is not being used by the Android builds. Figure out why.
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.25.2'
# TODO This Ninja version is not being used by the Android builds. Figure out why.
- name: Setup ninja
uses: cmelchior/setup-ninja@master
with:
version: '1.11.0'
# TODO This might not work on Windows: https://github.com/hendrikmuhs/ccache-action#notes-on-windows-support
- name: Install ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
max-size: '2.0G'
- name: Prepend ccache executables to the PATH
run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
# TODO See https://github.com/hendrikmuhs/ccache-action/issues/94
- name: Configure ccache
run: |
ccache --set-config="compiler_check=content"
ccache --show-config
echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang
echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++
- name: Build packages
working-directory: packages
run: ./gradlew publishCIPackages -Prealm.kotlin.targets=iosX64 -PignoreNativeLibs=true
# TODO Figure out naming schema and retention policy
# We cannot use artifacts as they cannot be shared between workflows, so use cache instead.
- name: Store build cache
uses: actions/cache@v3
with:
path: ./packages/build/m2-buildrepo
key: packages-m2-ios-x64-sync-${{ needs.check-cache.outputs.packages-sha }}
# TODO Must match naming found in include-check-cache.yml
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packages-ios-x64-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo/**/*
retention-days: 1
# TODO: ccache is not being used by this build for some reason
build-ios-arm64-packages:
runs-on: macos-latest
needs: check-cache
# needs: static-analysis
if: needs.check-cache.outputs.packages-ios-arm64-cache-hit != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
# TODO I'm not sure this catches changes to our Config.kt, what is the impact?
# https://github.com/actions/setup-java#caching-packages-dependencies
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
# TODO Default behavior is only caching from main/master. Unclear what the best caching strategy is for us.
# TODO What is the rules and limits for caching on Github -> 10 GB limit, automatic evicition
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
# TODO This cmake version is not being used by the Android builds. Figure out why.
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.25.2'
# TODO This Ninja version is not being used by the Android builds. Figure out why.
- name: Setup ninja
uses: cmelchior/setup-ninja@master
with:
version: '1.11.0'
# TODO This might not work on Windows: https://github.com/hendrikmuhs/ccache-action#notes-on-windows-support
- name: Install ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
max-size: '2.0G'
- name: Prepend ccache executables to the PATH
run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
# TODO See https://github.com/hendrikmuhs/ccache-action/issues/94
- name: Configure ccache
run: |
ccache --set-config="compiler_check=content"
ccache --show-config
echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang
echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++
- name: Build packages
working-directory: packages
run: ./gradlew publishCIPackages -Prealm.kotlin.targets=iosArm64 -PignoreNativeLibs=true
# TODO Figure out naming schema and retention policy
# We cannot use artifacts as they cannot be shared between workflows, so use cache instead.
- name: Store build cache
uses: actions/cache@v3
with:
path: ./packages/build/m2-buildrepo
key: packages-m2-ios-arm64-sync-${{ needs.check-cache.outputs.packages-sha }}
# TODO Must match naming found in include-check-cache.yml
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packages-ios-arm64-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo/**/*
retention-days: 1
# TODO Compare speed between emulator and Device Farm
# TODO We should be able to move this into a reusable work-flow
test-android-packages-emulator:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
type: [base, sync]
include:
- type: base
test-title: Unit Test Results - Android Base (Emulator)
- type: sync
test-title: Unit Test Results - Android Sync (Emulator)
runs-on: macos-latest
needs: [check-cache, deploy-baas, build-android-packages, build-jvm-packages]
if: |
always() &&
(needs.build-android-packages.result == 'success' || needs.build-android-packages.result == 'skipped') &&
(needs.build-jvm-packages.result == 'success' || needs.build-jvm-packages.result == 'skipped') &&
(needs.deploy-baas.result == 'success')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
- name: Restore m2-buildrepo (Android)
uses: actions/download-artifact@v3
with:
name: packages-android-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Restore m2-buildrepo (JVM)
uses: actions/download-artifact@v3
with:
name: packages-jvm-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
# TODO Can we read api level from Config.kt
# TODO This action does not support using `\` to split multiline scripts.
- name: Run Integration Tests
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 31
target: default # Only `google_apis` are available on 33, which has issues creating temporary folders
arch: x86_64
profile: Nexus 6
disk-size: 4096M
ram-size: 2048M
heap-size: 1024M
script: |
adb logcat -c
adb logcat > logcat.txt &
cd packages && ./gradlew :test-${{ matrix.type }}:connectedCheck -PincludeSdkModules=false -PsyncTestUrl=https://realm-qa.mongodb.com -PsyncTestAppNamePrefix=jvm-andemu-${{ needs.deploy-baas.outputs.runId }} -PsyncTestLoginPublicApiKey=${{ secrets.ATLAS_QA_PUBLIC_API_KEY }} -PsyncTestLoginPrivateApiKey=${{ secrets.ATLAS_QA_PRIVATE_API_KEY }} -PsyncTestClusterName=${{ needs.deploy-baas.outputs.clusterName }} -info --stacktrace --no-daemon
- name: Archive LogCat data
uses: actions/upload-artifact@v3
if: always() || failure()
with:
name: logcat-${{ matrix.type }}-emulator.txt
path: logcat.txt
retention-days: 1
- name: Publish Unit Test Results
uses: dorny/test-reporter@v1
if: always() || failure()
with:
name: ${{ matrix.test-title }}
path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml
reporter: java-junit
list-suites: failed
list-tests: failed
fail-on-error: true
# TODO Enable Sync tests here as well
test-android-packages-device-farm:
name: AWS Device Farm
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
type: [sync] # [base, sync]
include:
- type: base
appId: io.realm.testapp
- type: sync
appId: io.realm.sync.testapp
runs-on: ubuntu-latest
needs: [ check-cache, deploy-baas, build-android-packages, build-jvm-packages ]
if: |
always() &&
(needs.build-android-packages.result == 'success' || needs.build-android-packages.result == 'skipped') &&
(needs.build-jvm-packages.result == 'success' || needs.build-jvm-packages.result == 'skipped') &&
(needs.deploy-baas.result == 'success')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Restore Android Test APK
uses: actions/download-artifact@v3
with:
name: android-${{ matrix.type }}-test-apk-${{ needs.check-cache.outputs.version-label }}
path: ./packages/test-${{ matrix.type }}/build/outputs/apk/androidTest/debug
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Run the tests
uses: ./.github/actions/run-android-device-farm-test
id: run_android_tests
with:
apk-path: ${{ github.workspace }}/packages/test-${{ matrix.type }}/build/outputs/apk/androidTest/debug/test-${{ matrix.type }}-debug-androidTest.apk
app-id: ${{ matrix.appId }}
project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }}
device-pool-arn: ${{ secrets.DEVICEFARM_POOL_ARN }}
test-macos-packages:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [macos-latest] # , macos-arm]
type: [base, sync]
include:
- os: macos-latest
type: base
os-id: macos
package-prefix: macos-x64
test-title: Unit Test Results - MacOS x64 Base
- os: macos-latest
type: sync
os-id: macos
package-prefix: macos-x64
test-title: Unit Test Results - MacOS x64 Sync
# - os: macos-arm
# package-prefix: macos-arm64
# test-title: Results - MacOS arm64 Base
runs-on: ${{ matrix.os }}
# TODO Do we need to wait for all matrix builds?
# Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it.
needs: [check-cache, deploy-baas, build-macos-x64-packages] #, build-macos-arm64-packages]
if: |
always() &&
(needs.build-macos-x64-packages.result == 'success' || needs.build-macos-x64-packages.result == 'skipped') &&
(needs.deploy-baas.result == 'success')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
- name: Restore m2-buildrepo
uses: actions/download-artifact@v3
with:
name: packages-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Run tests
working-directory: packages
run: >
./gradlew :test-${{ matrix.type }}:macosTest
-PincludeSdkModules=false
-PsyncTestUrl=https://realm-qa.mongodb.com
-PsyncTestAppNamePrefix=jvm-${{ matrix.os-id }}-${{ needs.deploy-baas.outputs.runId }}
-PsyncTestLoginPublicApiKey=${{ secrets.ATLAS_QA_PUBLIC_API_KEY }}
-PsyncTestLoginPrivateApiKey=${{ secrets.ATLAS_QA_PRIVATE_API_KEY }}
-PsyncTestClusterName=${{ needs.deploy-baas.outputs.clusterName }}
-info --stacktrace --no-daemon
- name: Publish Unit Test Results
uses: dorny/test-reporter@v1
if: always() || failure()
with:
name: ${{ matrix.test-title }}
path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml
reporter: java-junit
list-suites: failed
list-tests: failed
fail-on-error: true
test-ios-packages:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [macos-latest] # , macos-arm]
type: [base, sync]
include:
- os: macos-latest
type: base
package-prefix: x64
test-title: Unit Test Results - iOS x64 Base
test-task: iosTest
- os: macos-latest
type: sync
package-prefix: x64
test-title: Unit Test Results - iOS x64 Sync
test-task: runCloudIosTests
# - os: macos-arm
# package-prefix: macos-arm64
# test-title: Results - MacOS arm64 Base
runs-on: ${{ matrix.os }}
# TODO Do we need to wait for all matrix builds?
# Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it.
needs: [check-cache, deploy-baas, build-macos-x64-packages, build-ios-x64-packages] # , build-ios-arm64-packages]
if: |
always() &&
(needs.build-ios-x64-packages.result == 'success' || needs.build-ios-x64-packages.result == 'skipped') &&
(needs.deploy-baas.result == 'success')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
- name: Restore m2-buildrepo (mac)
uses: actions/download-artifact@v3
with:
name: packages-macos-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Restore m2-buildrepo (ios)
uses: actions/download-artifact@v3
with:
name: packages-ios-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
# App names are limited to 32 characters, so the appNamePrefix should not exceed 22 characters.
- name: Run tests
working-directory: packages
run: >
./gradlew :test-${{ matrix.type }}:${{ matrix.test-task }}
-PincludeSdkModules=false
-PsyncTestUrl=https://realm-qa.mongodb.com
-PsyncTestAppNamePrefix=jvm-ios-${{ needs.deploy-baas.outputs.runId }}
-PsyncTestLoginPublicApiKey=${{ secrets.ATLAS_QA_PUBLIC_API_KEY }}
-PsyncTestLoginPrivateApiKey=${{ secrets.ATLAS_QA_PRIVATE_API_KEY }}
-PsyncTestClusterName=${{ needs.deploy-baas.outputs.clusterName }}
-info --stacktrace --no-daemon
# IOS Sync Tests currently don't create XML test output, so look in the build log for failures instead.
# This is expected to be fixed in Kotlin 1.9.0.
# - name: Publish Unit Test Results
# uses: dorny/test-reporter@v1
# if: always() || failure()
# with:
# name: ${{ matrix.test-title }}
# path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml
# reporter: java-junit
# list-suites: failed
# list-tests: failed
# fail-on-error: true
# TODO Investigate why these tests seem to hang for the `run tests` step with no log output. Could it be related to the test failing, but not being picked up?
test-jvm-packages:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest] # TODO Should we also test om MacOS arm64?
type: [base, sync]
include:
- os: macos-latest
os-id: mac
type: base
test-title: Unit Test Results - Base JVM MacOS x64
- os: ubuntu-latest
os-id: ubu
type: base
test-title: Unit Test Results - Base JVM Linux
- os: windows-latest
os-id: win
type: base
test-title: Unit Test Results - Base JVM Windows
- os: macos-latest
os-id: mac
type: sync
test-title: Unit Test Results - Sync JVM MacOS x64
- os: ubuntu-latest
os-id: ubu
type: sync
test-title: Unit Test Results - Sync JVM Linux
- os: windows-latest
os-id: win
type: sync
test-title: Unit Test Results - Sync JVM Windows
runs-on: ${{ matrix.os }}
needs: [check-cache, build-jvm-packages, deploy-baas]
if: |
always() &&
(needs.build-jvm-packages.result == 'success' || needs.build-jvm-packages.result == 'skipped') &&
(needs.deploy-baas.result == 'success')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
- name: Restore m2-buildrepo
uses: actions/download-artifact@v3
with:
name: packages-jvm-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
# App names are limited to 32 characters, so the appNamePrefix should not exceed 22 characters.
- name: Run tests
working-directory: packages
run: >
./gradlew :test-${{ matrix.type }}:jvmTest
-PincludeSdkModules=false
-PsyncTestUrl=https://realm-qa.mongodb.com
-PsyncTestAppNamePrefix=jvm-${{ matrix.os-id }}-${{ needs.deploy-baas.outputs.runId }}
-PsyncTestLoginPublicApiKey=${{ secrets.ATLAS_QA_PUBLIC_API_KEY }}
-PsyncTestLoginPrivateApiKey=${{ secrets.ATLAS_QA_PRIVATE_API_KEY }}
-PsyncTestClusterName=${{ needs.deploy-baas.outputs.clusterName }}
-info --stacktrace --no-daemon
- name: Publish Unit Test Results
uses: dorny/test-reporter@v1
if: always() || failure()
with:
name: ${{ matrix.test-title }}
path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml
reporter: java-junit
list-suites: failed
list-tests: failed
fail-on-error: true
package-all-artifacts:
runs-on: ubuntu-latest
needs: [check-cache, build-jvm-packages, build-android-packages, build-macos-x64-packages, build-macos-arm64-packages, build-ios-x64-packages, build-ios-arm64-packages]
if: |
always() &&
(needs.build-android-packages.result == 'success' || needs.build-android-packages.result == 'skipped') &&
(needs.build-jvm-packages.result == 'success' || needs.build-jvm-packages.result == 'skipped') &&
(needs.build-macos-x64-packages.result == 'success' || needs.build-ios-x64-packages.result == 'skipped') &&
(needs.build-macos-arm64-packages.result == 'success' || needs.build-macos-arm64-packages.result == 'skipped') &&
(needs.build-ios-x64-packages.result == 'success' || needs.build-ios-x64-packages.result == 'skipped') &&
(needs.build-ios-arm64-packages.result == 'success' || needs.build-ios-arm64-packages.result == 'skipped')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Restore Android artifacts
uses: actions/download-artifact@v3
with:
name: packages-android-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Restore JVM artifacts
uses: actions/download-artifact@v3
with:
name: packages-jvm-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Restore JVM artifacts
uses: actions/download-artifact@v3
with:
name: packages-jvm-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Restore MacOS x64 artifacts
uses: actions/download-artifact@v3
with:
name: packages-macos-x64-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Restore MacOS arm64 artifacts
uses: actions/download-artifact@v3
with:
name: packages-macos-arm64-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Restore iOS x64 artifacts
uses: actions/download-artifact@v3
with:
name: packages-ios-x64-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Restore iOS arm64 artifacts
uses: actions/download-artifact@v3
with:
name: packages-ios-arm64-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
- name: Upload artifacts bundle
uses: actions/upload-artifact@v3
with:
name: all-packages-${{ needs.check-cache.outputs.version-label }}
path: ./packages/build/m2-buildrepo
retention-days: 7
integration-tests:
uses: ./.github/workflows/include-integration-tests.yml
needs: [check-cache, package-all-artifacts]
if: |
always() &&
(needs.package-all-artifacts.result == 'success' || needs.package-all-artifacts.result == 'skipped')
with:
version-label: ${{ needs.check-cache.outputs.version-label }}
# TODO: Should only deploy snapshots from certain branches. For now deploy always until GHA branch is closer to being done.
deploy-snapshot:
uses: ./.github/workflows/include-deploy-snapshot.yml
needs: [
check-cache,
static-analysis,
integration-tests,
test-jvm-packages,
test-macos-packages,
test-ios-packages,
test-android-packages-emulator,
test-android-packages-device-farm,
package-all-artifacts
]
if: always() &&
endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') &&
needs.check-cache.result == 'success' &&
needs.static-analysis.result == 'success' &&
needs.static-analysis.result == 'success' &&
needs.integration-tests.result == 'success' &&
needs.test-jvm-packages.result == 'success' &&
needs.test-macos-packages.result == 'success' &&
needs.test-ios-packages.result == 'success' &&
needs.test-android-packages-emulator.result == 'success' &&
needs.test-android-packages-device-farm.result == 'success' &&
needs.package-all-artifacts.result == 'success'
secrets: inherit
with:
version-label: ${{ needs.check-cache.outputs.version-label }}
cleanup-baas:
uses: ./.github/workflows/include-cleanup-baas.yml
if: always()
name: Cleanup BAAS Cluster
needs: [deploy-baas, test-jvm-packages, test-ios-packages, test-macos-packages, test-android-packages-emulator]
with:
BaseUrl: https://realm-qa.mongodb.com
AtlasBaseUrl: https://cloud-qa.mongodb.com
AppIdPrefix: ${{ needs.deploy-baas.outputs.runId }}
secrets:
AtlasProjectId: ${{ secrets.ATLAS_QA_PROJECT_ID }}
AtlasPublicKey: ${{ secrets.ATLAS_QA_PUBLIC_API_KEY }}
AtlasPrivateKey: ${{ secrets.ATLAS_QA_PRIVATE_API_KEY }}