From 0e5c4ff67e6f7b7fbf0f76b43b4d16fe822680e8 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 12:02:20 +0100 Subject: [PATCH 01/93] Add test workflow for PR's. Disable JenkinsFile. --- .github/workflows/pr.yml | 90 +++++++++++++++++++++++++++ Jenkinsfile => DEPRECATED-Jenkinsfile | 0 2 files changed, 90 insertions(+) create mode 100644 .github/workflows/pr.yml rename Jenkinsfile => DEPRECATED-Jenkinsfile (100%) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000000..6d169541a3 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,90 @@ +# Define how pull requests are built and tested. +name: Pull Requests + +on: + pull_request: + paths-ignore: + - '*.md' + +jobs: + prepare-environment: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + + +#jobs: +# build: +# strategy: +# matrix: +# os: [macOS-latest, windows-latest, ubuntu-latest] +# job: [instrumentation, test] +# exclude: +# - os: windows-latest +# job: instrumentation +# +# runs-on: ${{matrix.os}} +# +# steps: +# - name: Checkout the repo +# uses: actions/checkout@v2 +# - name: Validate Gradle Wrapper +# uses: gradle/wrapper-validation-action@v1 +# - name: Cache intellij download +# uses: actions/cache@v2.1.0 +# with: +# path: lib/download +# key: intellij-${{ hashFiles('gradle/dependencies.gradle') }} +# - name: Cache gradle +# uses: actions/cache@v2.1.0 +# with: +# path: ~/.gradle/caches +# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} +# restore-keys: | +# ${{ runner.os }}-gradle- +# +# - name: Run ubuntu tests +# if: matrix.os == 'ubuntu-latest' && matrix.job == 'test' +# run: | +# ./gradlew build -x :sqldelight-idea-plugin:build -x :sqldelight-gradle-plugin:test --stacktrace +# ./gradlew :sqldelight-gradle-plugin:test --tests="com.squareup.sqldelight.tests.*" +# ./gradlew :sqldelight-gradle-plugin:test --tests="com.squareup.sqldelight.integrations.*" +# +# - name: Run the IntelliJ plugin +# if: matrix.os == 'ubuntu-latest' && matrix.job == 'instrumentation' +# run: ./gradlew :sqldelight-idea-plugin:build --stacktrace +# - name: Verify IntelliJ plugin +# if: matrix.os == 'ubuntu-latest' && matrix.job == 'instrumentation' +# run: | +# ./gradlew :sqldelight-idea-plugin:runPluginVerifier +# +# - name: Run windows tests +# if: matrix.os == 'windows-latest' +# run: ./gradlew mingwTest sqldelight-idea-plugin:check --stacktrace +# +# - name: Run instrumentation tests +# if: matrix.os == 'macOS-latest' && matrix.job == 'instrumentation' +# uses: reactivecircus/android-emulator-runner@v2 +# with: +# api-level: 29 +# script: ./gradlew connectedCheck :sqldelight-gradle-plugin:build --stacktrace -PInstrumentation +# - name: Run ios tests +# if: matrix.os == 'macOS-latest' && matrix.job == 'test' +# run: ./gradlew iosX64Test --stacktrace +# +# - name: Bundle the build report +# if: failure() +# run: find . -type d -name 'reports' | zip -@ -r build-reports.zip +# - name: Upload the build report +# if: failure() +# uses: actions/upload-artifact@master +# with: +# name: error-report +# path: build-reports.zip + +#env: +# GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m" \ No newline at end of file diff --git a/Jenkinsfile b/DEPRECATED-Jenkinsfile similarity index 100% rename from Jenkinsfile rename to DEPRECATED-Jenkinsfile From 88281686911fd76fd6e621ada4731b0ee06b1f50 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 12:22:08 +0100 Subject: [PATCH 02/93] Attempt to build library --- .github/workflows/pr.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6d169541a3..de91b587b2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,7 +14,10 @@ jobs: uses: actions/checkout@v2 with: submodules: 'recursive' - + - name: Cache gradle + uses: actions/cache@v2.1.0 + - name: Build library + run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace" #jobs: From 92128dd1813edf58341efa094c14b711a020c584 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 12:28:42 +0100 Subject: [PATCH 03/93] Add key to caching --- .github/workflows/gradle-wrapper-validation.yml | 2 +- .github/workflows/pr.yml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 405a2b3065..f365456a1e 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -1,5 +1,5 @@ name: "Validate Gradle Wrapper" -on: [push, pull_request] +on: [pull_request] jobs: validation: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index de91b587b2..064e074227 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,8 +14,14 @@ jobs: uses: actions/checkout@v2 with: submodules: 'recursive' + - name: Cache gradle uses: actions/cache@v2.1.0 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-gradle- + - name: Build library run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace" From 21ce19a1c4f121795e001de01b8601f79bed2c49 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 12:30:04 +0100 Subject: [PATCH 04/93] Syntax error --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 064e074227..7ef33c4d20 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,7 +23,7 @@ jobs: restore-keys: ${{ runner.os }}-gradle- - name: Build library - run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace" + run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace #jobs: From 17a9358b78f7dbc883f8839f1125a53754b30306 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 12:43:39 +0100 Subject: [PATCH 05/93] Attempt to use specific version of CMake --- .github/workflows/pr.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7ef33c4d20..018172ff3f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,7 +15,12 @@ jobs: with: submodules: 'recursive' - - name: Cache gradle + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: '3.18.4' + + - name: Cache Gradle uses: actions/cache@v2.1.0 with: path: ~/.gradle/caches From 1a0b99c862e4f4702c95c6bcf76eb0e72ba56b22 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 12:54:17 +0100 Subject: [PATCH 06/93] Install Ninja --- .github/workflows/pr.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 018172ff3f..63424b17d4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,6 +15,10 @@ jobs: with: submodules: 'recursive' + - name: Install dependencies + run: brew install ninja + + # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? - name: Setup cmake uses: jwlawson/actions-setup-cmake@v1.8 with: @@ -27,6 +31,7 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ${{ runner.os }}-gradle- + # TODO: Figure out how to do different build flags depending on the build type - name: Build library run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace @@ -64,7 +69,7 @@ jobs: # - name: Run ubuntu tests # if: matrix.os == 'ubuntu-latest' && matrix.job == 'test' # run: | -# ./gradlew build -x :sqldelight-idea-plugin:build -x :sqldelight-gradle-plugin:test --stacktrace +# ./gradlew build -x :.sqldelight-idea-plugin:b4ight-gradle-plugin:test --stacktrace # ./gradlew :sqldelight-gradle-plugin:test --tests="com.squareup.sqldelight.tests.*" # ./gradlew :sqldelight-gradle-plugin:test --tests="com.squareup.sqldelight.integrations.*" # From 73f5134a907d2fb4fc176ebb86e330248ce27827 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 15:15:08 +0100 Subject: [PATCH 07/93] Add ccache --- .github/workflows/pr.yml | 71 ++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 63424b17d4..84d76e6c44 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,39 +1,62 @@ # Define how pull requests are built and tested. name: Pull Requests - on: pull_request: paths-ignore: - '*.md' +env: + # TODO: From DockerFile, not sure if needed + CCACHE_CPP2: yes + # CMAKE_VERSION: 3.18.4 + # CCACHE_VERSION: 3.7.7 + jobs: - prepare-environment: - runs-on: macos-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: 'recursive' + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + # TODO How to optimize this? Can we cache it? + - name: Install dependencies + run: | + brew install ninja + brew install ccache + + # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") - - name: Install dependencies - run: brew install ninja + - name: ccache cache files + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-ccache- - # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1.8 - with: - cmake-version: '3.18.4' + # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: '3.18.4' - - name: Cache Gradle - uses: actions/cache@v2.1.0 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: ${{ runner.os }}-gradle- + - name: Cache Gradle + uses: actions/cache@v2.1.0 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-gradle- - # TODO: Figure out how to do different build flags depending on the build type - - name: Build library - run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace + # TODO: Figure out how to do different build flags depending on the build type + - name: Build library + run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace #jobs: From 925f16126099cbdc34ccc4d95baf494b66bbf1a5 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 15:32:57 +0100 Subject: [PATCH 08/93] Run PR build --- .github/workflows/pr.yml | 79 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 84d76e6c44..1b7083eb3f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,51 +12,52 @@ env: # CCACHE_VERSION: 3.7.7 jobs: - runs-on: macos-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: 'recursive' + run-pr-build: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' - # TODO How to optimize this? Can we cache it? - - name: Install dependencies - run: | - brew install ninja - brew install ccache + # TODO How to optimize this? Can we cache it? + - name: Install dependencies + run: | + brew install ninja + brew install ccache - # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml - - name: Prepare ccache timestamp - id: ccache_cache_timestamp - shell: cmake -P {0} - run: | - string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) - message("::set-output name=timestamp::${current_date}") + # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") - - name: ccache cache files - uses: actions/cache@v1.1.0 - with: - path: .ccache - key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} - restore-keys: | - ${{ runner.os }}-ccache- + - name: ccache cache files + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-ccache- - # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1.8 - with: - cmake-version: '3.18.4' + # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: '3.18.4' - - name: Cache Gradle - uses: actions/cache@v2.1.0 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: ${{ runner.os }}-gradle- + - name: Cache Gradle + uses: actions/cache@v2.1.0 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-gradle- - # TODO: Figure out how to do different build flags depending on the build type - - name: Build library - run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace + # TODO: Figure out how to do different build flags depending on the build type + - name: Build library + run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace #jobs: From 5a76b1a38f3c9da6c1ebf53644f97d571a82fa03 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 17:54:03 +0100 Subject: [PATCH 09/93] Attempt to publish test results --- .github/workflows/pr.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1b7083eb3f..ec2f8ada4d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -6,6 +6,9 @@ on: - '*.md' env: + # GitHub Actions does not support variables. Use environments vars as a work-around + BUILD_FLAGS: -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true + # TODO: From DockerFile, not sure if needed CCACHE_CPP2: yes # CMAKE_VERSION: 3.18.4 @@ -27,6 +30,7 @@ jobs: brew install ccache # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml + # TODO: How to verify this works at all? - name: Prepare ccache timestamp id: ccache_cache_timestamp shell: cmake -P {0} @@ -57,7 +61,30 @@ jobs: # TODO: Figure out how to do different build flags depending on the build type - name: Build library - run: ./gradlew assemble -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true --stacktrace + run: ./gradlew assemble $BUILD_FLAGS --stacktrace + + - name: Run Tests + run: ./gradlew check $BUILD_FLAGS --stacktrace + + - name: Publish Annotion Processor Tests + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + files: realm/realm-annotations-processor/build/test-results/test/TEST-*.xml + + - name: Publish Example App Unit Tests + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + files: examples/unitTestExample/build/test-results/**/TEST-*.xml + + - name: Publish Library Unit Tests + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + files: realm/realm-library/build/test-results/**/TEST-*.xml + + #jobs: From 7c07ccd3b114f746e9491ddd98234992ab58f56f Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 19:43:33 +0100 Subject: [PATCH 10/93] Handle test result uploads --- .github/workflows/pr.yml | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ec2f8ada4d..d0683f440a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -66,26 +66,40 @@ jobs: - name: Run Tests run: ./gradlew check $BUILD_FLAGS --stacktrace - - name: Publish Annotion Processor Tests - uses: EnricoMi/publish-unit-test-result-action@v1 + # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around + # we archive the test results from mac-os and download them to a Linux runner. + - name: Upload Test Results if: always() + uses: actions/upload-artifact@v2 with: - files: realm/realm-annotations-processor/build/test-results/test/TEST-*.xml - - - name: Publish Example App Unit Tests - uses: EnricoMi/publish-unit-test-result-action@v1 - if: always() + name: Unit Test Results + path: | + realm/realm-annotations-processor/build/test-results/test/TEST-*.xml + examples/unitTestExample/build/test-results/**/TEST-*.xml + realm/realm-library/build/test-results/**/TEST-*.xml + + process-test-results: + runs-on: ubuntu-latest + steps: + - name: Download Artifacts + uses: actions/download-artifact@v2 with: - files: examples/unitTestExample/build/test-results/**/TEST-*.xml + path: artifacts - - name: Publish Library Unit Tests - uses: EnricoMi/publish-unit-test-result-action@v1 - if: always() + - name: Publish Annotation Processor Results + uses: EnricoMi/publish-unit-test-result-action@master with: - files: realm/realm-library/build/test-results/**/TEST-*.xml - + files: artifacts/realm/realm-annotations-processor/build/test-results/test/TEST-*.xml + - name: Publish Example Project Results + uses: EnricoMi/publish-unit-test-result-action@master + with: + files: artifacts/examples/unitTestExample/build/test-results/**/TEST-*.xml + - name: Publish Library Test Results + uses: EnricoMi/publish-unit-test-result-action@master + with: + files: artifacts/realm/realm-library/build/test-results/**/TEST-*.xml #jobs: # build: From fdc4e267ed0db135a4ac5ff0a68f5592856826d5 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 19:50:45 +0100 Subject: [PATCH 11/93] Publish test results must wait for build --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d0683f440a..d947872259 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -79,6 +79,7 @@ jobs: realm/realm-library/build/test-results/**/TEST-*.xml process-test-results: + needs: run-pr-build runs-on: ubuntu-latest steps: - name: Download Artifacts From da35de6c07737316b3da6e68e77d4fb6f6cba18a Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 20:27:24 +0100 Subject: [PATCH 12/93] Use proper paths for test result artifacts --- .github/workflows/pr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d947872259..b573d3125e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -90,17 +90,17 @@ jobs: - name: Publish Annotation Processor Results uses: EnricoMi/publish-unit-test-result-action@master with: - files: artifacts/realm/realm-annotations-processor/build/test-results/test/TEST-*.xml + files: artifacts/realm-java/realm/realm-annotations-processor/build/test-results/test/TEST-*.xml - name: Publish Example Project Results uses: EnricoMi/publish-unit-test-result-action@master with: - files: artifacts/examples/unitTestExample/build/test-results/**/TEST-*.xml + files: artifacts/realm-java/examples/unitTestExample/build/test-results/**/TEST-*.xml - name: Publish Library Test Results uses: EnricoMi/publish-unit-test-result-action@master with: - files: artifacts/realm/realm-library/build/test-results/**/TEST-*.xml + files: artifacts/realm-java/realm/realm-library/build/test-results/**/TEST-*.xml #jobs: # build: From e12c96716614909c91aece6e6bdd453b509f9107 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 20:42:49 +0100 Subject: [PATCH 13/93] Add emulator support --- .github/workflows/pr.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b573d3125e..c545819548 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -78,6 +78,28 @@ jobs: examples/unitTestExample/build/test-results/**/TEST-*.xml realm/realm-library/build/test-results/**/TEST-*.xml + - name: Run Integration Tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 30 + target: default + arch: x86_64 + ndk: 22.0.7026061 + cmake: 3.18.4 + profile: Nexus 6 + script: | + cd realm + ./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + + - name: Upload Integration Test Results + if: always() + uses: actions/upload-artifact@v2 + with: + name: Integration Test Results + path: | + realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' + realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' + process-test-results: needs: run-pr-build runs-on: ubuntu-latest From d72aa4bcb3a4754daf81f8f75a89c7f6e150ec54 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 21:45:27 +0100 Subject: [PATCH 14/93] Use Emulator 29 instead of 30 --- .github/workflows/pr.yml | 76 ++-------------------------------------- 1 file changed, 3 insertions(+), 73 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c545819548..7205f763a4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -6,6 +6,8 @@ on: - '*.md' env: + # GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m" + # GitHub Actions does not support variables. Use environments vars as a work-around BUILD_FLAGS: -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true @@ -81,7 +83,7 @@ jobs: - name: Run Integration Tests uses: reactivecircus/android-emulator-runner@v2 with: - api-level: 30 + api-level: 29 target: default arch: x86_64 ndk: 22.0.7026061 @@ -123,75 +125,3 @@ jobs: uses: EnricoMi/publish-unit-test-result-action@master with: files: artifacts/realm-java/realm/realm-library/build/test-results/**/TEST-*.xml - -#jobs: -# build: -# strategy: -# matrix: -# os: [macOS-latest, windows-latest, ubuntu-latest] -# job: [instrumentation, test] -# exclude: -# - os: windows-latest -# job: instrumentation -# -# runs-on: ${{matrix.os}} -# -# steps: -# - name: Checkout the repo -# uses: actions/checkout@v2 -# - name: Validate Gradle Wrapper -# uses: gradle/wrapper-validation-action@v1 -# - name: Cache intellij download -# uses: actions/cache@v2.1.0 -# with: -# path: lib/download -# key: intellij-${{ hashFiles('gradle/dependencies.gradle') }} -# - name: Cache gradle -# uses: actions/cache@v2.1.0 -# with: -# path: ~/.gradle/caches -# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} -# restore-keys: | -# ${{ runner.os }}-gradle- -# -# - name: Run ubuntu tests -# if: matrix.os == 'ubuntu-latest' && matrix.job == 'test' -# run: | -# ./gradlew build -x :.sqldelight-idea-plugin:b4ight-gradle-plugin:test --stacktrace -# ./gradlew :sqldelight-gradle-plugin:test --tests="com.squareup.sqldelight.tests.*" -# ./gradlew :sqldelight-gradle-plugin:test --tests="com.squareup.sqldelight.integrations.*" -# -# - name: Run the IntelliJ plugin -# if: matrix.os == 'ubuntu-latest' && matrix.job == 'instrumentation' -# run: ./gradlew :sqldelight-idea-plugin:build --stacktrace -# - name: Verify IntelliJ plugin -# if: matrix.os == 'ubuntu-latest' && matrix.job == 'instrumentation' -# run: | -# ./gradlew :sqldelight-idea-plugin:runPluginVerifier -# -# - name: Run windows tests -# if: matrix.os == 'windows-latest' -# run: ./gradlew mingwTest sqldelight-idea-plugin:check --stacktrace -# -# - name: Run instrumentation tests -# if: matrix.os == 'macOS-latest' && matrix.job == 'instrumentation' -# uses: reactivecircus/android-emulator-runner@v2 -# with: -# api-level: 29 -# script: ./gradlew connectedCheck :sqldelight-gradle-plugin:build --stacktrace -PInstrumentation -# - name: Run ios tests -# if: matrix.os == 'macOS-latest' && matrix.job == 'test' -# run: ./gradlew iosX64Test --stacktrace -# -# - name: Bundle the build report -# if: failure() -# run: find . -type d -name 'reports' | zip -@ -r build-reports.zip -# - name: Upload the build report -# if: failure() -# uses: actions/upload-artifact@master -# with: -# name: error-report -# path: build-reports.zip - -#env: -# GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m" \ No newline at end of file From 7d283a998f1ebc95649b0a463a930039648217d2 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 22:17:32 +0100 Subject: [PATCH 15/93] Use proper artifact file path --- .github/workflows/pr.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7205f763a4..1d5aded1cc 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -74,7 +74,7 @@ jobs: if: always() uses: actions/upload-artifact@v2 with: - name: Unit Test Results + name: unit-test-results path: | realm/realm-annotations-processor/build/test-results/test/TEST-*.xml examples/unitTestExample/build/test-results/**/TEST-*.xml @@ -114,14 +114,14 @@ jobs: - name: Publish Annotation Processor Results uses: EnricoMi/publish-unit-test-result-action@master with: - files: artifacts/realm-java/realm/realm-annotations-processor/build/test-results/test/TEST-*.xml + files: artifacts/unit-test-results/realm-java/realm/realm-annotations-processor/build/test-results/test/TEST-*.xml - name: Publish Example Project Results uses: EnricoMi/publish-unit-test-result-action@master with: - files: artifacts/realm-java/examples/unitTestExample/build/test-results/**/TEST-*.xml + files: artifacts/unit-test-results/realm-java/examples/unitTestExample/build/test-results/**/TEST-*.xml - name: Publish Library Test Results uses: EnricoMi/publish-unit-test-result-action@master with: - files: artifacts/realm-java/realm/realm-library/build/test-results/**/TEST-*.xml + files: artifacts/unit-test-results/realm-java/realm/realm-library/build/test-results/**/TEST-*.xml From c4c487bea6e6b5257d451d048831802bf94d455d Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 22:22:26 +0100 Subject: [PATCH 16/93] Disable Cmake check for emulator --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1d5aded1cc..faa76cd608 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -87,7 +87,7 @@ jobs: target: default arch: x86_64 ndk: 22.0.7026061 - cmake: 3.18.4 + # TODO: Cannot find Cmake? cmake: 3.18.4 profile: Nexus 6 script: | cd realm From d0234e8f022847fd65eeb2e81dd22cdedac71c9d Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 23:00:40 +0100 Subject: [PATCH 17/93] Run tests in a single command --- .github/workflows/pr.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index faa76cd608..2f7ebbc926 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -89,9 +89,7 @@ jobs: ndk: 22.0.7026061 # TODO: Cannot find Cmake? cmake: 3.18.4 profile: Nexus 6 - script: | - cd realm - ./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + script: cd realm && ./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS - name: Upload Integration Test Results if: always() From f1328307c140ea7f1aec40981d5c821a4a97e1cc Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 23:23:36 +0100 Subject: [PATCH 18/93] Use shellscript to start Docker image for testing --- .github/workflows/pr.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2f7ebbc926..5f893ca2e8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -61,6 +61,13 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ${{ runner.os }}-gradle- + # TODO Move to later, but run here to verify it works + - name: Start Docker test image + env: + GITHUB_DOCKER_USER: ${{ secrets.GH_DOCKER_USER }} + GITHUB_DOCKER_TOKEN: ${{ secrets.GH_DOCKER_TOKEN }} + run: cd tools/sync_test_server && sh ./start_server.sh + # TODO: Figure out how to do different build flags depending on the build type - name: Build library run: ./gradlew assemble $BUILD_FLAGS --stacktrace @@ -87,7 +94,6 @@ jobs: target: default arch: x86_64 ndk: 22.0.7026061 - # TODO: Cannot find Cmake? cmake: 3.18.4 profile: Nexus 6 script: cd realm && ./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS @@ -95,7 +101,7 @@ jobs: if: always() uses: actions/upload-artifact@v2 with: - name: Integration Test Results + name: integration-test-results path: | realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' From 160c7ae9f1781b75c100b7a0a2bf3450c4b3476e Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 23:31:14 +0100 Subject: [PATCH 19/93] Fun with Docker --- .github/workflows/pr.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5f893ca2e8..b14d6119db 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -63,9 +63,23 @@ jobs: # TODO Move to later, but run here to verify it works - name: Start Docker test image + uses: reactivecircus/android-emulator-runner@v2 env: GITHUB_DOCKER_USER: ${{ secrets.GH_DOCKER_USER }} GITHUB_DOCKER_TOKEN: ${{ secrets.GH_DOCKER_TOKEN }} + with: + api-level: 29 + target: default + arch: x86_64 + ndk: 22.0.7026061 + profile: Nexus 6 + script: | + cd tools/sync_test_server + sh ./start_server.sh + cd ../../realm + ./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + + - name: Start Docker test image run: cd tools/sync_test_server && sh ./start_server.sh # TODO: Figure out how to do different build flags depending on the build type From 01dc6f2a1a48f30bc24005358331936985da8bc4 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 10 Mar 2021 23:38:20 +0100 Subject: [PATCH 20/93] Run as a single line --- .github/workflows/pr.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b14d6119db..5f7058877a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -73,14 +73,10 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: | - cd tools/sync_test_server - sh ./start_server.sh - cd ../../realm - ./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + script: cd tools/sync_test_server && sh ./start_server.sh && cd ../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS - - name: Start Docker test image - run: cd tools/sync_test_server && sh ./start_server.sh +# - name: Start Docker test image +# run: cd tools/sync_test_server && sh ./start_server.sh # TODO: Figure out how to do different build flags depending on the build type - name: Build library From 2f13ea56cec4f4fac7aff55bef42e1760d4ee7a3 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 00:04:27 +0100 Subject: [PATCH 21/93] Disable using Docker image --- .github/workflows/pr.yml | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5f7058877a..c8b00a658e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -61,22 +61,19 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ${{ runner.os }}-gradle- - # TODO Move to later, but run here to verify it works - - name: Start Docker test image - uses: reactivecircus/android-emulator-runner@v2 - env: - GITHUB_DOCKER_USER: ${{ secrets.GH_DOCKER_USER }} - GITHUB_DOCKER_TOKEN: ${{ secrets.GH_DOCKER_TOKEN }} - with: - api-level: 29 - target: default - arch: x86_64 - ndk: 22.0.7026061 - profile: Nexus 6 - script: cd tools/sync_test_server && sh ./start_server.sh && cd ../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS - + # TODO Find a way to start the Docker test image while also having the emulator available # - name: Start Docker test image -# run: cd tools/sync_test_server && sh ./start_server.sh +# uses: reactivecircus/android-emulator-runner@v2 +# env: +# GITHUB_DOCKER_USER: ${{ secrets.GH_DOCKER_USER }} +# GITHUB_DOCKER_TOKEN: ${{ secrets.GH_DOCKER_TOKEN }} +# with: +# api-level: 29 +# target: default +# arch: x86_64 +# ndk: 22.0.7026061 +# profile: Nexus 6 +# script: cd tools/sync_test_server && sh ./start_server.sh && cd ../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS # TODO: Figure out how to do different build flags depending on the build type - name: Build library From 4bad0d1eb2808dbcff8d21913636d98a59ee6813 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 17:22:02 +0100 Subject: [PATCH 22/93] Add scripts for starting local BAAS --- .github/workflows/pr.yml | 27 +-- tools/sync_test_server/abspath.sh | 14 ++ tools/sync_test_server/install_baas.sh | 272 ++++++++++++++++++++++++ tools/sync_test_server/wait_for_baas.sh | 23 ++ 4 files changed, 324 insertions(+), 12 deletions(-) create mode 100755 tools/sync_test_server/abspath.sh create mode 100644 tools/sync_test_server/install_baas.sh create mode 100755 tools/sync_test_server/wait_for_baas.sh diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c8b00a658e..f7cf3b4f13 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -62,18 +62,21 @@ jobs: restore-keys: ${{ runner.os }}-gradle- # TODO Find a way to start the Docker test image while also having the emulator available -# - name: Start Docker test image -# uses: reactivecircus/android-emulator-runner@v2 -# env: -# GITHUB_DOCKER_USER: ${{ secrets.GH_DOCKER_USER }} -# GITHUB_DOCKER_TOKEN: ${{ secrets.GH_DOCKER_TOKEN }} -# with: -# api-level: 29 -# target: default -# arch: x86_64 -# ndk: 22.0.7026061 -# profile: Nexus 6 -# script: cd tools/sync_test_server && sh ./start_server.sh && cd ../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + - name: Start MongoDB Realm Test Server + env: + GITHUB_DOCKER_USER: ${{ secrets.GH_DOCKER_USER }} + GITHUB_DOCKER_TOKEN: ${{ secrets.GH_DOCKER_TOKEN }} + run: | + cd tools/sync_test_server + sh install_baash.sh + sh setp + with: + api-level: 29 + target: default + arch: x86_64 + ndk: 22.0.7026061 + profile: Nexus 6 + script: cd tools/sync_test_server && sh ./start_server.sh && cd ../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS # TODO: Figure out how to do different build flags depending on the build type - name: Build library diff --git a/tools/sync_test_server/abspath.sh b/tools/sync_test_server/abspath.sh new file mode 100755 index 0000000000..4ab1dc323c --- /dev/null +++ b/tools/sync_test_server/abspath.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +PLATFORM=$(uname -s) +case $(uname -s) in + Darwin) + exec perl -e 'use File::Spec; print File::Spec->rel2abs(shift); print "\n"' $1 + ;; + CYGWIN*) + exec cygpath -am $1 + ;; + *) + exec realpath -s $1 + ;; +esac \ No newline at end of file diff --git a/tools/sync_test_server/install_baas.sh b/tools/sync_test_server/install_baas.sh new file mode 100644 index 0000000000..017536cded --- /dev/null +++ b/tools/sync_test_server/install_baas.sh @@ -0,0 +1,272 @@ +#!/bin/bash +# Clone of https://raw.githubusercontent.com/realm/realm-core/master/evergreen/install_baas.sh +# But removed the part that import apps. +# +# This script will download all the dependencies for and build/start a Realm Cloud app server +# and will import a given app into it. +# +# Usage: +# ./evergreen/build_and_run_baas.sh {path to working directory} {path to app to import} [git revision of baas] +# + +set -o errexit +set -o pipefail + +unset -v CC + +# Go and CCache on Mac does not play well together +case $(uname -s) in + Darwin) + STITCH_SUPPORT_LIB_URL="https://s3.amazonaws.com/stitch-artifacts/stitch-support/stitch-support-macos-debug-4.3.2-721-ge791a2e-patch-5e2a6ad2a4cf473ae2e67b09.tgz" + STITCH_ASSISTED_AGG_URL="https://stitch-artifacts.s3.amazonaws.com/stitch-mongo-libs/stitch_mongo_libs_osx_ac073d06065af6e00103a8a3cf64672a3f875bea_20_12_01_19_47_16/assisted_agg" + GO_URL="https://golang.org/dl/go1.14.10.darwin-amd64.tar.gz" + MONGODB_DOWNLOAD_URL="http://downloads.10gen.com/osx/mongodb-macos-x86_64-enterprise-4.4.1.tgz" + YQ_DOWNLOAD_URL="https://github.com/mikefarah/yq/releases/download/3.4.1/yq_darwin_amd64" + JQ_DOWNLOAD_URL="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64" + ;; + Linux) + GO_URL="https://golang.org/dl/go1.14.10.linux-amd64.tar.gz" + YQ_DOWNLOAD_URL="https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64" + JQ_DOWNLOAD_URL="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64" + + # Detect what distro/versionf of Linux we are running on to download the right version of MongoDB to download + # /etc/os-release covers debian/ubuntu/suse + if [[ -e /etc/os-release ]]; then + # Amazon Linux 2 comes back as 'amzn' + DISTRO_NAME="$(. /etc/os-release ; echo "$ID")" + DISTRO_VERSION="$(. /etc/os-release ; echo "$VERSION_ID")" + DISTRO_VERSION_MAJOR="$(cut -d. -f1 <<< "$DISTRO_VERSION" )" + elif [[ -e /etc/redhat-release ]]; then + # /etc/redhat-release covers RHEL + DISTRO_NAME=rhel + DISTRO_VERSION="$(lsb_release -s -r)" + DISTRO_VERSION_MAJOR="$(cut -d. -f1 <<< "$DISTRO_VERSION" )" + fi + case $DISTRO_NAME in + ubuntu) + MONGODB_DOWNLOAD_URL="http://downloads.10gen.com/linux/mongodb-linux-$(uname -m)-enterprise-ubuntu${DISTRO_VERSION_MAJOR}04-4.4.1.tgz" + STITCH_ASSISTED_AGG_LIB_URL="https://stitch-artifacts.s3.amazonaws.com/stitch-mongo-libs/stitch_mongo_libs_ubuntu2004_x86_64_ac073d06065af6e00103a8a3cf64672a3f875bea_20_12_01_19_47_16/libmongo-ubuntu2004-x86_64.so" + STITCH_SUPPORT_LIB_URL="https://mciuploads.s3.amazonaws.com/mongodb-mongo-v4.4/stitch-support/ubuntu2004/03d22bb5884e280934d36702136d99a9363fb720/stitch-support-4.4.2-rc0-3-g03d22bb.tgz" + ;; + rhel) + case $DISTRO_VERSION_MAJOR in + 7) + MONGODB_DOWNLOAD_URL="http://downloads.10gen.com/linux/mongodb-linux-x86_64-enterprise-rhel70-4.4.1.tgz" + STITCH_ASSISTED_AGG_LIB_URL="https://stitch-artifacts.s3.amazonaws.com/stitch-mongo-libs/stitch_mongo_libs_linux_64_ac073d06065af6e00103a8a3cf64672a3f875bea_20_12_01_19_47_16/libmongo.so" + STITCH_SUPPORT_LIB_URL="https://s3.amazonaws.com/stitch-artifacts/stitch-support/stitch-support-rhel-70-4.3.2-721-ge791a2e-patch-5e2a6ad2a4cf473ae2e67b09.tgz" + ;; + *) + echo "Unsupported version of RHEL $DISTRO_VERSION" + exit 1 + ;; + esac + ;; + *) + echo "Unsupported platform $DISTRO_NAME $DISTRO_VERSION" + exit 1 + ;; + esac + ;; + *) + echo "Unsupported platform $(uname -s)" + exit 1 + ;; +esac + +# Allow path to $CURL to be overloaded by an environment variable +CURL=${CURL:=curl} + +BASE_PATH=$(cd $(dirname "$0"); pwd) + +REALPATH=$BASE_PATH/abspath.sh + +#if [[ -z $1 || -z $2 ]]; then +# echo "Must specify working directory and stitch app" +# exit 1 +#fi +WORK_PATH=$($REALPATH $1) +#STITCH_APP=$($REALPATH $2) +BAAS_VERSION=$2 + +#if [[ ! -f "$STITCH_APP/stitch.json" ]]; then +# echo "Invalid app to import: $STITCH_APP/stitch.json does not exist." +# exit 1 +#fi + +[[ -d $WORK_PATH ]] || mkdir -p $WORK_PATH +cd $WORK_PATH + +if [[ -f $WORK_PATH/baas_ready ]]; then + rm $WORK_PATH/baas_ready +fi + +echo "Installing node and go to build baas and its dependencies" + +export NVM_DIR="$WORK_PATH/.nvm" +if [ ! -d "$NVM_DIR" ]; then + git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" + cd "$NVM_DIR" + git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` + cd - +fi +[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh" +NODE_VERSION=12.16.2 +nvm install --no-progress $NODE_VERSION +nvm use $NODE_VERSION + +[[ -x $WORK_PATH/go/bin/go ]] || ($CURL -sL $GO_URL | tar -xz) +export GOROOT=$WORK_PATH/go +export PATH=$WORK_PATH/go/bin:$PATH + +[[ -d baas_dep_binaries ]] || mkdir baas_dep_binaries +export PATH=$WORK_PATH/baas_dep_binaries:$PATH +if [[ ! -x baas_dep_binaries/yq || ! -x baas_dep_binaries/jq ]]; then + cd baas_dep_binaries + which yq || ($CURL -LsS $YQ_DOWNLOAD_URL > yq && chmod +x yq) + which jq || ($CURL -LsS $JQ_DOWNLOAD_URL > jq && chmod +x jq) + cd - +fi + +if [[ -z "$BAAS_VERSION" ]]; then + BAAS_VERSION=$($CURL -LsS "https://realm.mongodb.com/api/private/v1.0/version" | jq -r '.backend.git_hash') +fi + +if [[ ! -d $WORK_PATH/baas/.git ]]; then + git clone git@github.com:10gen/baas.git + +fi + +cd baas +echo "Checking out baas version $BAAS_VERSION" +git checkout $BAAS_VERSION +cd - + +if [[ ! -d $WORK_PATH/baas/etc/dylib/lib ]]; then + echo "Downloading stitch support library" + mkdir baas/etc/dylib + cd baas/etc/dylib + $CURL -LsS $STITCH_SUPPORT_LIB_URL | tar -xz --strip-components=1 + cd - +fi +export LD_LIBRARY_PATH=$WORK_PATH/baas/etc/dylib/lib + +if [[ ! -x $WORK_PATH/baas_dep_binaries/libmongo.so && -n "$STITCH_ASSISTED_AGG_LIB_URL" ]]; then + echo "Downloading assisted agg library" + cd $WORK_PATH/baas_dep_binaries + $CURL -LsS $STITCH_ASSISTED_AGG_LIB_URL > libmongo.so + chmod 755 libmongo.so + cd - +fi + +if [[ ! -x $WORK_PATH/baas_dep_binaries/assisted_agg && -n "$STITCH_ASSISTED_AGG_URL" ]]; then + echo "Downloading assisted agg binary" + cd $WORK_PATH/baas_dep_binaries + $CURL -LsS $STITCH_ASSISTED_AGG_URL > assisted_agg + chmod 755 assisted_agg + cd - +fi + +YARN=$WORK_PATH/yarn/bin/yarn +if [[ ! -x $YARN ]]; then + echo "Getting yarn" + mkdir yarn && cd yarn + $CURL -LsS https://s3.amazonaws.com/stitch-artifacts/yarn/latest.tar.gz | tar -xz --strip-components=1 + cd - + mkdir $WORK_PATH/yarn_cache +fi + +if [[ ! -x baas_dep_binaries/transpiler ]]; then + echo "Building transpiler" + cd baas/etc/transpiler + $YARN --non-interactive --silent --cache-folder $WORK_PATH/yarn_cache + $YARN build --cache-folder $WORK_PATH/yarn_cache --non-interactive --silent + cd - + ln -s $(pwd)/baas/etc/transpiler/bin/transpiler baas_dep_binaries/transpiler +fi + +if [[ ! -x baas_dep_binaries/stitch-cli ]]; then + env CCACHE_DISABLE=1 + export CCACHE_DISABLE=1 + mkdir stitch-cli + cd stitch-cli + $CURL -LsS https://github.com/10gen/stitch-cli/archive/v1.9.0.tar.gz | tar -xz --strip-components=1 + go build -o $WORK_PATH/baas_dep_binaries/stitch-cli + cd - +fi + +if [ ! -x $WORK_PATH/mongodb-binaries/bin/mongod ]; then + echo "Downloading mongodb" + $CURL -sLS $MONGODB_DOWNLOAD_URL --output mongodb-binaries.tgz + + tar -xzf mongodb-binaries.tgz + rm mongodb-binaries.tgz + mv mongodb* mongodb-binaries + chmod +x ./mongodb-binaries/bin/* +fi + +# ulimit -n 32000 + +if [[ -d mongodb-dbpath ]]; then + rm -rf mongodb-dbpath +fi +mkdir mongodb-dbpath + +function cleanup() { + if [[ -f $WORK_PATH/baas_server.pid ]]; then + PIDS_TO_KILL="$(< $WORK_PATH/baas_server.pid)" + fi + + if [[ -f $WORK_PATH/mongod.pid ]]; then + PIDS_TO_KILL="$(< $WORK_PATH/mongod.pid) $PIDS_TO_KILL" + fi + + if [[ -n "$PIDS_TO_KILL" ]]; then + echo "Killing $PIDS_TO_KILL" + kill $PIDS_TO_KILL + echo "Waiting for processes to exit" + wait + fi +} + +trap "exit" INT TERM ERR +trap cleanup EXIT + +echo "Starting mongodb" +[[ -f $WORK_PATH/mongodb-dbpath/mongod.pid ]] && rm $WORK_PATH/mongodb-path/mongod.pid +./mongodb-binaries/bin/mongod \ + --replSet rs \ + --bind_ip_all \ + --port 26000 \ + --logpath $WORK_PATH/mongodb-dbpath/mongod.log \ + --dbpath $WORK_PATH/mongodb-dbpath/ \ + --pidfilepath $WORK_PATH/mongod.pid & + +./mongodb-binaries/bin/mongo \ + --nodb \ + --eval 'assert.soon(function(x){try{var d = new Mongo("localhost:26000"); return true}catch(e){return false}}, "timed out connecting")' \ +> /dev/null + +echo "Initializing replica set" +./mongodb-binaries/bin/mongo --port 26000 --eval 'rs.initiate()' > /dev/null + +cd $WORK_PATH/baas +echo "Adding stitch user" +go run -exec="env LD_LIBRARY_PATH=$LD_LIBRARY_PATH" cmd/auth/user.go \ + addUser \ + -domainID 000000000000000000000000 \ + -mongoURI mongodb://localhost:26000 \ + -salt 'DQOWene1723baqD!_@#'\ + -id "unique_user@domain.com" \ + -password "password" + +[[ -d tmp ]] || mkdir tmp +echo "Starting stitch app server" +[[ -f $WORK_PATH/baas_server.pid ]] && rm $WORK_PATH/baas_server.pid +go build -o $WORK_PATH/baas_server cmd/server/main.go +$WORK_PATH/baas_server \ + --configFile=etc/configs/test_config.json 2>&1 > $WORK_PATH/baas_server.log & +echo $! > $WORK_PATH/baas_server.pid +$BASE_PATH/wait_for_baas.sh $WORK_PATH/baas_server.pid +touch $WORK_PATH/baas_ready +echo "Baas server ready" +wait diff --git a/tools/sync_test_server/wait_for_baas.sh b/tools/sync_test_server/wait_for_baas.sh new file mode 100755 index 0000000000..604ae5bb1d --- /dev/null +++ b/tools/sync_test_server/wait_for_baas.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -o errexit +set -o pipefail + +CURL=${CURL:=curl} +STITCH_PID_FILE=$1 +RETRY_COUNT=${2:-36} + +WAIT_COUNTER=0 +until $CURL --output /dev/null --head --fail http://localhost:9090 --silent ; do + if [[ -f $STITCH_PID_FILE ]]; then + pgrep -F $STITCH_PID_FILE > /dev/null || (echo "Stitch $(< $STITCH_PID_FILE) is not running"; exit 1) + fi + + WAIT_COUNTER=$(($WAIT_COUNTER + 1 )) + if [[ $WAIT_COUNTER = $RETRY_COUNT ]]; then + echo "Timed out waiting for stitch to start" + exit 1 + fi + + sleep 5 +done From 89cbfd097302eb46c875959c35241d10ddcf6b55 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 21:20:08 +0100 Subject: [PATCH 23/93] Add support for build BAAS locally --- .github/workflows/pr.yml | 5 +- .gitignore | 4 + .../{ => baas_docker}/Dockerfile | 2 +- .../start_docker_server.sh} | 2 +- .../stop_docker_server.sh} | 0 .../{ => baas_local}/abspath.sh | 0 .../{ => baas_local}/install_baas.sh | 26 ++---- .../baas_local/start_local_server.sh | 86 +++++++++++++++++++ .../baas_local/stop_local_server.sh | 22 +++++ .../{ => baas_local}/wait_for_baas.sh | 0 .../mongodb-realm-command-server.js | 4 +- 11 files changed, 126 insertions(+), 25 deletions(-) rename tools/sync_test_server/{ => baas_docker}/Dockerfile (96%) rename tools/sync_test_server/{start_server.sh => baas_docker/start_docker_server.sh} (97%) rename tools/sync_test_server/{stop_server.sh => baas_docker/stop_docker_server.sh} (100%) rename tools/sync_test_server/{ => baas_local}/abspath.sh (100%) rename tools/sync_test_server/{ => baas_local}/install_baas.sh (95%) create mode 100755 tools/sync_test_server/baas_local/start_local_server.sh create mode 100755 tools/sync_test_server/baas_local/stop_local_server.sh rename tools/sync_test_server/{ => baas_local}/wait_for_baas.sh (100%) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f7cf3b4f13..391081f692 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -63,9 +63,6 @@ jobs: # TODO Find a way to start the Docker test image while also having the emulator available - name: Start MongoDB Realm Test Server - env: - GITHUB_DOCKER_USER: ${{ secrets.GH_DOCKER_USER }} - GITHUB_DOCKER_TOKEN: ${{ secrets.GH_DOCKER_TOKEN }} run: | cd tools/sync_test_server sh install_baash.sh @@ -76,7 +73,7 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: cd tools/sync_test_server && sh ./start_server.sh && cd ../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + script: cd tools/sync_test_server/baas_local && sh ./start_local_server.sh && cd ../../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS # TODO: Figure out how to do different build flags depending on the build type - name: Build library diff --git a/.gitignore b/.gitignore index 8754b69638..95b2c86870 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,10 @@ realm/build # Gradle local properties local.properties +# Test server temp dirs +tools/sync_test_server/baas_local/tmp-baas +tools/sync_test_server/baas_local/tmp-command-server + # Core core core-* diff --git a/tools/sync_test_server/Dockerfile b/tools/sync_test_server/baas_docker/Dockerfile similarity index 96% rename from tools/sync_test_server/Dockerfile rename to tools/sync_test_server/baas_docker/Dockerfile index 1fda76b43c..434a15fd41 100644 --- a/tools/sync_test_server/Dockerfile +++ b/tools/sync_test_server/baas_docker/Dockerfile @@ -26,7 +26,7 @@ RUN apt-get update \ # Copy webserver script and install dependencies WORKDIR "/tmp" -COPY mongodb-realm-command-server.js /tmp +COPY ../mongodb-realm-command-server.js /tmp RUN npm install winston@2.4.0 temp httpdispatcher@1.0.0 fs-extra moment is-port-available@0.1.5 # Run integration test server diff --git a/tools/sync_test_server/start_server.sh b/tools/sync_test_server/baas_docker/start_docker_server.sh similarity index 97% rename from tools/sync_test_server/start_server.sh rename to tools/sync_test_server/baas_docker/start_docker_server.sh index 74962e3333..1ae4066b3b 100755 --- a/tools/sync_test_server/start_server.sh +++ b/tools/sync_test_server/baas_docker/start_docker_server.sh @@ -24,7 +24,7 @@ fi # Get the script dir which contains the Dockerfile DOCKERFILE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -MONGODB_REALM_VERSION=$(grep MONGODB_REALM_SERVER $DOCKERFILE_DIR/../../dependencies.list | cut -d'=' -f2) +MONGODB_REALM_VERSION=$(grep MONGODB_REALM_SERVER $DOCKERFILE_DIR/../../../dependencies.list | cut -d'=' -f2) adb reverse tcp:9443 tcp:9443 && \ adb reverse tcp:9080 tcp:9080 && \ diff --git a/tools/sync_test_server/stop_server.sh b/tools/sync_test_server/baas_docker/stop_docker_server.sh similarity index 100% rename from tools/sync_test_server/stop_server.sh rename to tools/sync_test_server/baas_docker/stop_docker_server.sh diff --git a/tools/sync_test_server/abspath.sh b/tools/sync_test_server/baas_local/abspath.sh similarity index 100% rename from tools/sync_test_server/abspath.sh rename to tools/sync_test_server/baas_local/abspath.sh diff --git a/tools/sync_test_server/install_baas.sh b/tools/sync_test_server/baas_local/install_baas.sh similarity index 95% rename from tools/sync_test_server/install_baas.sh rename to tools/sync_test_server/baas_local/install_baas.sh index 017536cded..04bcd95387 100644 --- a/tools/sync_test_server/install_baas.sh +++ b/tools/sync_test_server/baas_local/install_baas.sh @@ -2,19 +2,18 @@ # Clone of https://raw.githubusercontent.com/realm/realm-core/master/evergreen/install_baas.sh # But removed the part that import apps. # -# This script will download all the dependencies for and build/start a Realm Cloud app server -# and will import a given app into it. +# This script will download all the dependencies for and build/start a Realm Cloud app server. # # Usage: -# ./evergreen/build_and_run_baas.sh {path to working directory} {path to app to import} [git revision of baas] +# ./evergreen/build_and_run_baas.sh {path to working directory} [git revision of baas] # set -o errexit set -o pipefail +# Go and CCache on Mac does not play well together unset -v CC -# Go and CCache on Mac does not play well together case $(uname -s) in Darwin) STITCH_SUPPORT_LIB_URL="https://s3.amazonaws.com/stitch-artifacts/stitch-support/stitch-support-macos-debug-4.3.2-721-ge791a2e-patch-5e2a6ad2a4cf473ae2e67b09.tgz" @@ -80,19 +79,13 @@ BASE_PATH=$(cd $(dirname "$0"); pwd) REALPATH=$BASE_PATH/abspath.sh -#if [[ -z $1 || -z $2 ]]; then -# echo "Must specify working directory and stitch app" -# exit 1 -#fi +if [[ -z $1 ]]; then + echo "Must specify working directory." + exit 1 +fi WORK_PATH=$($REALPATH $1) -#STITCH_APP=$($REALPATH $2) BAAS_VERSION=$2 -#if [[ ! -f "$STITCH_APP/stitch.json" ]]; then -# echo "Invalid app to import: $STITCH_APP/stitch.json does not exist." -# exit 1 -#fi - [[ -d $WORK_PATH ]] || mkdir -p $WORK_PATH cd $WORK_PATH @@ -127,6 +120,7 @@ if [[ ! -x baas_dep_binaries/yq || ! -x baas_dep_binaries/jq ]]; then cd - fi +# If no baas version is specified. Find latest released version if [[ -z "$BAAS_VERSION" ]]; then BAAS_VERSION=$($CURL -LsS "https://realm.mongodb.com/api/private/v1.0/version" | jq -r '.backend.git_hash') fi @@ -185,8 +179,6 @@ if [[ ! -x baas_dep_binaries/transpiler ]]; then fi if [[ ! -x baas_dep_binaries/stitch-cli ]]; then - env CCACHE_DISABLE=1 - export CCACHE_DISABLE=1 mkdir stitch-cli cd stitch-cli $CURL -LsS https://github.com/10gen/stitch-cli/archive/v1.9.0.tar.gz | tar -xz --strip-components=1 @@ -204,8 +196,6 @@ if [ ! -x $WORK_PATH/mongodb-binaries/bin/mongod ]; then chmod +x ./mongodb-binaries/bin/* fi -# ulimit -n 32000 - if [[ -d mongodb-dbpath ]]; then rm -rf mongodb-dbpath fi diff --git a/tools/sync_test_server/baas_local/start_local_server.sh b/tools/sync_test_server/baas_local/start_local_server.sh new file mode 100755 index 0000000000..3220677bdd --- /dev/null +++ b/tools/sync_test_server/baas_local/start_local_server.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# +# This script controls starting a MongoDB Realm test server and import two running apps into it. +# +# It also starts a local command server that the integration tests use to control the MongoDB Realm +# instance. +# + +# Copy from https://github.com/realm/ci/edit/master/realm/docker/mongodb-realm/run.sh +# Requires jq and mongodb-realm-cli +function import_apps () { + app_dir="$1" + realm-cli login --config-path=/tmp/stitch-config --base-url=http://localhost:9090 --auth-provider=local-userpass --username=unique_user@domain.com --password=password + access_token=$(yq ".access_token" /tmp/stitch-config -r) + group_id=$(curl --header "Authorization: Bearer $access_token" http://localhost:9090/api/admin/v3.0/auth/profile -s | jq '.roles[0].group_id' -r) + cd $app_dir + for app in *; do + echo "importing app: ${app}" + + manifest_file="config.json" + app_id_param="" + if [ -f "$app/secrets.json" ]; then + # create app by importing an empty skeleton with the same name + app_name=$(jq '.name' "$app/$manifest_file" -r) + temp_app="/tmp/stitch-apps/$app" + mkdir -p "$temp_app" && echo "{ \"name\": \"$app_name\" }" > "$temp_app/$manifest_file" + realm-cli import --config-path=/tmp/stitch-config --base-url=http://localhost:9090 --path="$temp_app" --project-id $group_id -y --strategy replace + + app_id=$(jq '.app_id' "$temp_app/$manifest_file" -r) + app_id_param="--app-id=$app_id" + + # import secrets into the created app + while read -r secret value; do + realm-cli secrets add --config-path=/tmp/stitch-config --base-url=http://localhost:9090 --app-id=$app_id --name="$secret" --value="$(echo $value | sed 's/\\n/\n/g')" + done < <(jq 'to_entries[] | [.key, .value] | @tsv' "$app/secrets.json" -r) + fi + + realm-cli import --config-path=/tmp/stitch-config --base-url=http://localhost:9090 --path="$app" $app_id_param --project-id $group_id -y --strategy replace + jq '.app_id' "$app/$manifest_file" -r > "$app/app_id" + done +} + +SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +MONGODB_REALM_VERSION=$(grep MONGODB_REALM_SERVER $SCRIPTPATH/../../../dependencies.list | cut -d'=' -f2) + +adb reverse tcp:9443 tcp:9443 && \ +adb reverse tcp:9080 tcp:9080 && \ +adb reverse tcp:9090 tcp:9090 && \ +adb reverse tcp:8888 tcp:8888 || { echo "Failed to reverse adb port." ; exit 1 ; } + +SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +# Cleanup any old installation +echo "Cleanup old tmp directories..." +if [[ -d tmp-command-server ]]; then + rm -rf tmp-command-server +fi +if [[ -d tmp-baas ]]; then + rm -rf tmp-baas +fi + +# Install and run BAAS +echo "Install and start BAAS..." +sh ./install_baas.sh ./tmp-baas & #$MONGODB_REALM_VERSION +while [[ ! -e $SCRIPTPATH/tmp-baas/baas_ready ]] ; do + sleep 1 +done + +# Create app configurations +echo "Prepare app templates..." +APP_CONFIG_DIR=`mktemp -d -t app_config` +$SCRIPTPATH/../app_config_generator.sh $APP_CONFIG_DIR $SCRIPTPATH/../app_template testapp1 testapp2 + +echo "Import apps..." +import_apps "$APP_CONFIG_DIR" +cd $SCRIPTPATH + +# Start command server +echo "Start command server..." +mkdir tmp-command-server +cd tmp-command-server +cp ../../mongodb-realm-command-server.js ./ +npm install winston@2.4.0 temp httpdispatcher@1.0.0 fs-extra moment is-port-available@0.1.5 +node ./mongodb-realm-command-server.js $APP_CONFIG_DIR & +echo $! > command_server.pid diff --git a/tools/sync_test_server/baas_local/stop_local_server.sh b/tools/sync_test_server/baas_local/stop_local_server.sh new file mode 100755 index 0000000000..ae639690ee --- /dev/null +++ b/tools/sync_test_server/baas_local/stop_local_server.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# +# Stops any running BAAS and command server +# +SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +if [[ -f $SCRIPTPATH/tmp-command-server/command_server.pid ]]; then + PIDS_TO_KILL="$(< $SCRIPTPATH/tmp-command-server/command_server.pid)" +fi +if [[ -f $SCRIPTPATH/tmp-baas/baas_server.pid ]]; then + PIDS_TO_KILL="$(< $SCRIPTPATH/tmp-baas/baas_server.pid) $PIDS_TO_KILL" +fi +if [[ -f $SCRIPTPATH/tmp-baas/baas_ready ]]; then + rm $SCRIPTPATH/tmp-baas/baas_ready +fi +if [[ -n "$PIDS_TO_KILL" ]]; then + echo "Killing $PIDS_TO_KILL" + kill $PIDS_TO_KILL + echo "Waiting for processes to exit" + wait +fi \ No newline at end of file diff --git a/tools/sync_test_server/wait_for_baas.sh b/tools/sync_test_server/baas_local/wait_for_baas.sh similarity index 100% rename from tools/sync_test_server/wait_for_baas.sh rename to tools/sync_test_server/baas_local/wait_for_baas.sh diff --git a/tools/sync_test_server/mongodb-realm-command-server.js b/tools/sync_test_server/mongodb-realm-command-server.js index d38c271cde..fe454d0136 100755 --- a/tools/sync_test_server/mongodb-realm-command-server.js +++ b/tools/sync_test_server/mongodb-realm-command-server.js @@ -10,6 +10,8 @@ * stopped, so a new integration test will start from a clean slate. */ +var commandlineArgs = process.argv.slice(2); +var APP_DIR = commandlineArgs[0] ? commandlineArgs[0] : "/apps"; var winston = require('winston'); //logging var http = require('http'); const fs = require('fs') @@ -44,7 +46,7 @@ function handleApplicationId(appName, req, resp) { switch(req.method) { case "GET": try { - const data = fs.readFileSync('/apps/' + appName + '/app_id', 'utf8') + const data = fs.readFileSync(APP_DIR + '/' + appName + '/app_id', 'utf8') console.log(data) resp.writeHead(200, {'Content-Type': 'text/plain'}); resp.end(data.replace(/\n$/, '')); From 5f005fd48c1a9a22a17cc5ea7231728852858750 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 21:45:21 +0100 Subject: [PATCH 24/93] Bad copy/paste --- .github/workflows/pr.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 391081f692..37346ffc0e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -63,11 +63,8 @@ jobs: # TODO Find a way to start the Docker test image while also having the emulator available - name: Start MongoDB Realm Test Server - run: | - cd tools/sync_test_server - sh install_baash.sh - sh setp - with: + uses: reactivecircus/android-emulator-runner@v2 + with: api-level: 29 target: default arch: x86_64 From 45a972d2ce83ac101741ab1b9e6c6ae624437872 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 22:10:56 +0100 Subject: [PATCH 25/93] Install JQ --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 37346ffc0e..a9adc196b5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -30,6 +30,7 @@ jobs: run: | brew install ninja brew install ccache + brew install jq # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml # TODO: How to verify this works at all? From bde4f8c414a70797ff4b78898164b932659a622b Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 22:22:34 +0100 Subject: [PATCH 26/93] Don't use sh --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a9adc196b5..1d2d2dfeb7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -71,7 +71,7 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: cd tools/sync_test_server/baas_local && sh ./start_local_server.sh && cd ../../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + script: cd tools/sync_test_server/baas_local && ./start_local_server.sh && cd ../../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS # TODO: Figure out how to do different build flags depending on the build type - name: Build library From 8c87c1c148b7c28b08c9c1e09d6bb654ad56ef0a Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 22:44:01 +0100 Subject: [PATCH 27/93] Add SSH credentials --- .github/workflows/pr.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1d2d2dfeb7..798bf4e5fb 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -62,8 +62,18 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ${{ runner.os }}-gradle- + + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" + # TODO Find a way to start the Docker test image while also having the emulator available - name: Start MongoDB Realm Test Server + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 From d4040a6de67abdfd9a4cbc1651408eae5944d565 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 22:56:19 +0100 Subject: [PATCH 28/93] Install Realm CLI --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 798bf4e5fb..c0fb077f40 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -31,6 +31,7 @@ jobs: brew install ninja brew install ccache brew install jq + npm install -g mongodb-realm-cli # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml # TODO: How to verify this works at all? From 6a7d795471291ebc1d203d0f8b72a46a04f127a8 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 23:21:54 +0100 Subject: [PATCH 29/93] Assume node is available --- .github/workflows/pr.yml | 3 ++- .../baas_local/install_baas.sh | 24 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c0fb077f40..31675eb389 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -26,11 +26,12 @@ jobs: submodules: 'recursive' # TODO How to optimize this? Can we cache it? + # Already available on Github Runners + # - brew install jq - name: Install dependencies run: | brew install ninja brew install ccache - brew install jq npm install -g mongodb-realm-cli # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml diff --git a/tools/sync_test_server/baas_local/install_baas.sh b/tools/sync_test_server/baas_local/install_baas.sh index 04bcd95387..c396e41921 100644 --- a/tools/sync_test_server/baas_local/install_baas.sh +++ b/tools/sync_test_server/baas_local/install_baas.sh @@ -94,18 +94,18 @@ if [[ -f $WORK_PATH/baas_ready ]]; then fi echo "Installing node and go to build baas and its dependencies" - -export NVM_DIR="$WORK_PATH/.nvm" -if [ ! -d "$NVM_DIR" ]; then - git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" - cd "$NVM_DIR" - git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` - cd - -fi -[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh" -NODE_VERSION=12.16.2 -nvm install --no-progress $NODE_VERSION -nvm use $NODE_VERSION +echo "Assume node is available" +#export NVM_DIR="$WORK_PATH/.nvm" +#if [ ! -d "$NVM_DIR" ]; then +# git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" +# cd "$NVM_DIR" +# git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` +# cd - +#fi +#[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh" +#NODE_VERSION=12.16.2 +#nvm install --no-progress $NODE_VERSION +#nvm use $NODE_VERSION [[ -x $WORK_PATH/go/bin/go ]] || ($CURL -sL $GO_URL | tar -xz) export GOROOT=$WORK_PATH/go From a9e27a26e71f2753d33e0f758fbc45f16b5c94f1 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Thu, 11 Mar 2021 23:48:03 +0100 Subject: [PATCH 30/93] Add yq --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 31675eb389..15c72ce688 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -33,6 +33,7 @@ jobs: brew install ninja brew install ccache npm install -g mongodb-realm-cli + pip install yg # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml # TODO: How to verify this works at all? From 0b937c9800e797462cb332c8952ec9bebf7d9818 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 00:10:17 +0100 Subject: [PATCH 31/93] Disable downloading Go --- tools/sync_test_server/baas_local/install_baas.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/sync_test_server/baas_local/install_baas.sh b/tools/sync_test_server/baas_local/install_baas.sh index c396e41921..521487cfa1 100644 --- a/tools/sync_test_server/baas_local/install_baas.sh +++ b/tools/sync_test_server/baas_local/install_baas.sh @@ -107,9 +107,10 @@ echo "Assume node is available" #nvm install --no-progress $NODE_VERSION #nvm use $NODE_VERSION -[[ -x $WORK_PATH/go/bin/go ]] || ($CURL -sL $GO_URL | tar -xz) -export GOROOT=$WORK_PATH/go -export PATH=$WORK_PATH/go/bin:$PATH +echo "Assume Go is available" +#[[ -x $WORK_PATH/go/bin/go ]] || ($CURL -sL $GO_URL | tar -xz) +#export GOROOT=$WORK_PATH/go +#export PATH=$WORK_PATH/go/bin:$PATH [[ -d baas_dep_binaries ]] || mkdir baas_dep_binaries export PATH=$WORK_PATH/baas_dep_binaries:$PATH From 0e6e208806b12cbadcd8df67512e602c0d0769af Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 00:54:45 +0100 Subject: [PATCH 32/93] Assume yg/jq is available --- .github/workflows/pr.yml | 1 - .../sync_test_server/baas_local/install_baas.sh | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 15c72ce688..4640774ae1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -65,7 +65,6 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ${{ runner.os }}-gradle- - - name: Setup SSH Keys and known_hosts env: SSH_AUTH_SOCK: /tmp/ssh_agent.sock diff --git a/tools/sync_test_server/baas_local/install_baas.sh b/tools/sync_test_server/baas_local/install_baas.sh index 521487cfa1..df432c25d4 100644 --- a/tools/sync_test_server/baas_local/install_baas.sh +++ b/tools/sync_test_server/baas_local/install_baas.sh @@ -112,14 +112,15 @@ echo "Assume Go is available" #export GOROOT=$WORK_PATH/go #export PATH=$WORK_PATH/go/bin:$PATH -[[ -d baas_dep_binaries ]] || mkdir baas_dep_binaries -export PATH=$WORK_PATH/baas_dep_binaries:$PATH -if [[ ! -x baas_dep_binaries/yq || ! -x baas_dep_binaries/jq ]]; then - cd baas_dep_binaries - which yq || ($CURL -LsS $YQ_DOWNLOAD_URL > yq && chmod +x yq) - which jq || ($CURL -LsS $JQ_DOWNLOAD_URL > jq && chmod +x jq) - cd - -fi +echo "Assume jq and yg is available" +#[[ -d baas_dep_binaries ]] || mkdir baas_dep_binaries +#export PATH=$WORK_PATH/baas_dep_binaries:$PATH +#if [[ ! -x baas_dep_binaries/yq || ! -x baas_dep_binaries/jq ]]; then +# cd baas_dep_binaries +# which yq || ($CURL -LsS $YQ_DOWNLOAD_URL > yq && chmod +x yq) +# which jq || ($CURL -LsS $JQ_DOWNLOAD_URL > jq && chmod +x jq) +# cd - +#fi # If no baas version is specified. Find latest released version if [[ -z "$BAAS_VERSION" ]]; then From 4bfd4d1980221ddb0ced88580cb4a2f02fdb0c0b Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 01:01:37 +0100 Subject: [PATCH 33/93] Create dependencies folder --- tools/sync_test_server/baas_local/install_baas.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/sync_test_server/baas_local/install_baas.sh b/tools/sync_test_server/baas_local/install_baas.sh index df432c25d4..55fa3f2d5a 100644 --- a/tools/sync_test_server/baas_local/install_baas.sh +++ b/tools/sync_test_server/baas_local/install_baas.sh @@ -113,7 +113,7 @@ echo "Assume Go is available" #export PATH=$WORK_PATH/go/bin:$PATH echo "Assume jq and yg is available" -#[[ -d baas_dep_binaries ]] || mkdir baas_dep_binaries +[[ -d baas_dep_binaries ]] || mkdir baas_dep_binaries #export PATH=$WORK_PATH/baas_dep_binaries:$PATH #if [[ ! -x baas_dep_binaries/yq || ! -x baas_dep_binaries/jq ]]; then # cd baas_dep_binaries From 3541ac57716c3bf8ef8df3e38966b899ea8ee061 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 01:31:43 +0100 Subject: [PATCH 34/93] Test for yq --- .github/workflows/pr.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4640774ae1..142483c286 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -65,12 +65,15 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ${{ runner.os }}-gradle- - - name: Setup SSH Keys and known_hosts - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - run: | - ssh-agent -a $SSH_AUTH_SOCK > /dev/null - ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" + + - name: Test for yq + run: which yq # TODO Find a way to start the Docker test image while also having the emulator available - name: Start MongoDB Realm Test Server @@ -83,7 +86,7 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: cd tools/sync_test_server/baas_local && ./start_local_server.sh && cd ../../../realm &&./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + script: cd tools/sync_test_server/baas_local && ./start_local_server.sh && cd ../../../realm && ./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS # TODO: Figure out how to do different build flags depending on the build type - name: Build library From 9a08de1fd86e129f1614e64aad3a0633bd3baff2 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 10:57:32 +0100 Subject: [PATCH 35/93] Other test for yq --- .github/workflows/pr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 142483c286..1764bb9e9b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -35,6 +35,9 @@ jobs: npm install -g mongodb-realm-cli pip install yg + - name: Test for yq + run: type yq + # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml # TODO: How to verify this works at all? - name: Prepare ccache timestamp @@ -72,9 +75,6 @@ jobs: ssh-agent -a $SSH_AUTH_SOCK > /dev/null ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" - - name: Test for yq - run: which yq - # TODO Find a way to start the Docker test image while also having the emulator available - name: Start MongoDB Realm Test Server env: From 5e314dae34592c6c5dedb47ceb0a60b015de88c2 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 12:13:54 +0100 Subject: [PATCH 36/93] Specific step for python packages --- .github/workflows/pr.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1764bb9e9b..cbf2f24c71 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -33,7 +33,11 @@ jobs: brew install ninja brew install ccache npm install -g mongodb-realm-cli - pip install yg + + # See https://stackoverflow.com/questions/59207134/cant-install-a-python-package-use-it-in-a-github-action + - name: Install Python dependencies + - uses: actions/setup-python@v1 + run: pip install yg - name: Test for yq run: type yq From a57d60ba6254d7326f967fa8ef2f48051f554946 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 12:15:44 +0100 Subject: [PATCH 37/93] Syntax error --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index cbf2f24c71..5517aaf71a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -36,7 +36,7 @@ jobs: # See https://stackoverflow.com/questions/59207134/cant-install-a-python-package-use-it-in-a-github-action - name: Install Python dependencies - - uses: actions/setup-python@v1 + uses: actions/setup-python@v1 run: pip install yg - name: Test for yq From 382067e939131cbb2514cec8f6f83cdfba3a2e26 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 12:19:50 +0100 Subject: [PATCH 38/93] More syntax --- .github/workflows/pr.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5517aaf71a..a92bf1c6e5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -27,17 +27,17 @@ jobs: # TODO How to optimize this? Can we cache it? # Already available on Github Runners + # See https://stackoverflow.com/questions/59207134/cant-install-a-python-package-use-it-in-a-github-action + - name: Install Python dependencies + uses: actions/setup-python@v1 + # - brew install jq - name: Install dependencies run: | brew install ninja brew install ccache npm install -g mongodb-realm-cli - - # See https://stackoverflow.com/questions/59207134/cant-install-a-python-package-use-it-in-a-github-action - - name: Install Python dependencies - uses: actions/setup-python@v1 - run: pip install yg + pip install yg - name: Test for yq run: type yq From 8f64e4d2ab7ccad8f44c33d320fcacab1fe9b70e Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 12:38:23 +0100 Subject: [PATCH 39/93] Attempt to hack path --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a92bf1c6e5..f56c0bef0d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,6 +13,7 @@ env: # TODO: From DockerFile, not sure if needed CCACHE_CPP2: yes + PATH: $PATH:~/.local/bin/yq # CMAKE_VERSION: 3.18.4 # CCACHE_VERSION: 3.7.7 From c330cde55a76de7c7bb15e39cfa296bd261ab208 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 12:47:19 +0100 Subject: [PATCH 40/93] Add local path --- .github/workflows/pr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f56c0bef0d..384ca9bf12 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,7 +13,6 @@ env: # TODO: From DockerFile, not sure if needed CCACHE_CPP2: yes - PATH: $PATH:~/.local/bin/yq # CMAKE_VERSION: 3.18.4 # CCACHE_VERSION: 3.7.7 @@ -32,6 +31,9 @@ jobs: - name: Install Python dependencies uses: actions/setup-python@v1 + - name: Modify Path + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + # - brew install jq - name: Install dependencies run: | From 1694b3a41dca8b1677ca909aa7e63578cc2ebafd Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 12:57:58 +0100 Subject: [PATCH 41/93] More path hacks --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 384ca9bf12..7f55581293 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -32,7 +32,7 @@ jobs: uses: actions/setup-python@v1 - name: Modify Path - run: echo "$HOME/.local/bin" >> $GITHUB_PATH + run: echo "$HOME/.pyenv/shims" >> $GITHUB_PATH # - brew install jq - name: Install dependencies From 607d5949d26e07873633cf74cf7bb727a871a8ef Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 13:00:57 +0100 Subject: [PATCH 42/93] Debug python --- .github/workflows/pr.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7f55581293..2c74a844ea 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,6 +34,11 @@ jobs: - name: Modify Path run: echo "$HOME/.pyenv/shims" >> $GITHUB_PATH + - name: Bleh + run: | + python -m site + python -m site --user-site + # - brew install jq - name: Install dependencies run: | From 3926833dfbb71e22c4477b49924423f335d8b629 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 13:02:45 +0100 Subject: [PATCH 43/93] PATH check --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2c74a844ea..68b8d6d648 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -38,6 +38,7 @@ jobs: run: | python -m site python -m site --user-site + echo $PATH # - brew install jq - name: Install dependencies From 350a11b67778b415da5537792027430037916659 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 14:09:48 +0100 Subject: [PATCH 44/93] Manually install yq --- .github/workflows/pr.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 68b8d6d648..17bff3bf9c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -28,17 +28,11 @@ jobs: # TODO How to optimize this? Can we cache it? # Already available on Github Runners # See https://stackoverflow.com/questions/59207134/cant-install-a-python-package-use-it-in-a-github-action + # TODO: I don't know why installing pip packages doesn't work, so steal workaround from BAAS install script - name: Install Python dependencies - uses: actions/setup-python@v1 - - - name: Modify Path - run: echo "$HOME/.pyenv/shims" >> $GITHUB_PATH - - - name: Bleh run: | - python -m site - python -m site --user-site - echo $PATH + curl -LsS https://github.com/mikefarah/yq/releases/download/3.4.1/yq_darwin_amd64 > yq && chmod +x yq + cp ./yq /usr/local/bin/yq # - brew install jq - name: Install dependencies @@ -46,7 +40,6 @@ jobs: brew install ninja brew install ccache npm install -g mongodb-realm-cli - pip install yg - name: Test for yq run: type yq From 13f1a5b27c0daa9d34c263e67aa9bfa5bbd3b36b Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 19:31:24 +0100 Subject: [PATCH 45/93] Start tests from script --- .github/workflows/pr.yml | 2 +- tools/sync_test_server/ci_run_integration_tests.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tools/sync_test_server/ci_run_integration_tests.sh diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 17bff3bf9c..8711056b50 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -92,7 +92,7 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: cd tools/sync_test_server/baas_local && ./start_local_server.sh && cd ../../../realm && ./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + script: sh tools/sync_test_server/ci_run_integration_testsh.sh # TODO: Figure out how to do different build flags depending on the build type - name: Build library diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh new file mode 100644 index 0000000000..4bec739d1c --- /dev/null +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +cd $SCRIPTPATH/tools/sync_test_server/baas_local +./start_local_server.sh +cd ../../../realm +./gradlew connectedBaseDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true \ No newline at end of file From d67a951f52bb1f18d87899a48431cd25bb78eab5 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 19:55:56 +0100 Subject: [PATCH 46/93] Minor change --- tools/sync_test_server/ci_run_integration_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index 4bec739d1c..463268a6b0 100644 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -5,4 +5,4 @@ SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" cd $SCRIPTPATH/tools/sync_test_server/baas_local ./start_local_server.sh cd ../../../realm -./gradlew connectedBaseDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true \ No newline at end of file +./gradlew connectedBaseDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true From 6eb9c66eecb74c5d1d7daf690928c0a54389f991 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 20:06:03 +0100 Subject: [PATCH 47/93] Proper file name --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8711056b50..2b307a826b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -92,7 +92,7 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: sh tools/sync_test_server/ci_run_integration_testsh.sh + script: sh tools/sync_test_server/ci_run_integration_tests.sh # TODO: Figure out how to do different build flags depending on the build type - name: Build library From 32ce4b218d1e714b7a133fc3f7043acfddf74ba6 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 20:16:00 +0100 Subject: [PATCH 48/93] Fix path --- tools/sync_test_server/ci_run_integration_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index 463268a6b0..827e4fe21b 100644 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -2,7 +2,7 @@ SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" -cd $SCRIPTPATH/tools/sync_test_server/baas_local +cd $SCRIPTPATH/baas_local ./start_local_server.sh cd ../../../realm ./gradlew connectedBaseDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true From 9cf73f71d9d3162b81696cb3107926cc35533294 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 20:59:18 +0100 Subject: [PATCH 49/93] Dont use sh to start script --- .github/workflows/pr.yml | 2 +- tools/sync_test_server/baas_local/start_local_server.sh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2b307a826b..3537892a24 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -92,7 +92,7 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: sh tools/sync_test_server/ci_run_integration_tests.sh + script: tools/sync_test_server/ci_run_integration_tests.sh # TODO: Figure out how to do different build flags depending on the build type - name: Build library diff --git a/tools/sync_test_server/baas_local/start_local_server.sh b/tools/sync_test_server/baas_local/start_local_server.sh index 3220677bdd..08ab967581 100755 --- a/tools/sync_test_server/baas_local/start_local_server.sh +++ b/tools/sync_test_server/baas_local/start_local_server.sh @@ -1,14 +1,16 @@ #!/bin/bash - # # This script controls starting a MongoDB Realm test server and import two running apps into it. # # It also starts a local command server that the integration tests use to control the MongoDB Realm # instance. # - +# # Copy from https://github.com/realm/ci/edit/master/realm/docker/mongodb-realm/run.sh # Requires jq and mongodb-realm-cli + +set -e + function import_apps () { app_dir="$1" realm-cli login --config-path=/tmp/stitch-config --base-url=http://localhost:9090 --auth-provider=local-userpass --username=unique_user@domain.com --password=password From d5684e26b2eebfe4dce3190c5bf335f26cd51adc Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 21:05:41 +0100 Subject: [PATCH 50/93] Use bash to start script --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3537892a24..706302df44 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -92,7 +92,7 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: tools/sync_test_server/ci_run_integration_tests.sh + script: bash tools/sync_test_server/ci_run_integration_tests.sh # TODO: Figure out how to do different build flags depending on the build type - name: Build library From 53831aea4733efc801ebd5abce8fd6bf5613d53d Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 22:02:29 +0100 Subject: [PATCH 51/93] Use bash everywhere --- tools/sync_test_server/ci_run_integration_tests.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index 827e4fe21b..4330dbffed 100644 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -3,6 +3,8 @@ SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" cd $SCRIPTPATH/baas_local -./start_local_server.sh +bash ./start_local_server.sh cd ../../../realm ./gradlew connectedBaseDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true +cd $SCRIPTPATH/baas_local +bash ./stop_local_server.sh \ No newline at end of file From a8a3b496fc3100fe295c7a90171e95d6c2499688 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 22:14:25 +0100 Subject: [PATCH 52/93] Install yq from brew instead of pip --- .github/workflows/pr.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 706302df44..c7ff30e831 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -27,18 +27,12 @@ jobs: # TODO How to optimize this? Can we cache it? # Already available on Github Runners - # See https://stackoverflow.com/questions/59207134/cant-install-a-python-package-use-it-in-a-github-action - # TODO: I don't know why installing pip packages doesn't work, so steal workaround from BAAS install script - - name: Install Python dependencies - run: | - curl -LsS https://github.com/mikefarah/yq/releases/download/3.4.1/yq_darwin_amd64 > yq && chmod +x yq - cp ./yq /usr/local/bin/yq - # - brew install jq - name: Install dependencies run: | brew install ninja brew install ccache + brew install yq npm install -g mongodb-realm-cli - name: Test for yq From 4640d299a46c357cd2b481aa478745a17cdd5d80 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 22:25:42 +0100 Subject: [PATCH 53/93] yq debug --- .github/workflows/pr.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c7ff30e831..235ff82654 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -36,7 +36,10 @@ jobs: npm install -g mongodb-realm-cli - name: Test for yq - run: type yq + run: | + type yq + yq --version + yq --help # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml # TODO: How to verify this works at all? From 896edc6e45d4def5c4a4090a87871db29faba8be Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 22:36:56 +0100 Subject: [PATCH 54/93] Update yq syntax --- tools/sync_test_server/baas_local/start_local_server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/sync_test_server/baas_local/start_local_server.sh b/tools/sync_test_server/baas_local/start_local_server.sh index 08ab967581..7abd3328ea 100755 --- a/tools/sync_test_server/baas_local/start_local_server.sh +++ b/tools/sync_test_server/baas_local/start_local_server.sh @@ -14,7 +14,7 @@ set -e function import_apps () { app_dir="$1" realm-cli login --config-path=/tmp/stitch-config --base-url=http://localhost:9090 --auth-provider=local-userpass --username=unique_user@domain.com --password=password - access_token=$(yq ".access_token" /tmp/stitch-config -r) + access_token=$(yq e ".access_token" /tmp/stitch-config) group_id=$(curl --header "Authorization: Bearer $access_token" http://localhost:9090/api/admin/v3.0/auth/profile -s | jq '.roles[0].group_id' -r) cd $app_dir for app in *; do From abc22d617c4c088433251153fe52f09bd0228b2d Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 22:57:21 +0100 Subject: [PATCH 55/93] Fix command server startup --- tools/sync_test_server/baas_local/start_local_server.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/sync_test_server/baas_local/start_local_server.sh b/tools/sync_test_server/baas_local/start_local_server.sh index 7abd3328ea..b45b45c63d 100755 --- a/tools/sync_test_server/baas_local/start_local_server.sh +++ b/tools/sync_test_server/baas_local/start_local_server.sh @@ -80,9 +80,9 @@ cd $SCRIPTPATH # Start command server echo "Start command server..." -mkdir tmp-command-server +mkdir tmp-command-server || true cd tmp-command-server -cp ../../mongodb-realm-command-server.js ./ +cp $SCRIPTPATH/../mongodb-realm-command-server.js ./ npm install winston@2.4.0 temp httpdispatcher@1.0.0 fs-extra moment is-port-available@0.1.5 node ./mongodb-realm-command-server.js $APP_CONFIG_DIR & echo $! > command_server.pid From 4b75bcae4cc0cd2c79683e4e30fa38a0500388a4 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Fri, 12 Mar 2021 23:29:23 +0100 Subject: [PATCH 56/93] Run tests in proper order --- .github/workflows/pr.yml | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 235ff82654..ba33e57db0 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -35,12 +35,6 @@ jobs: brew install yq npm install -g mongodb-realm-cli - - name: Test for yq - run: | - type yq - yq --version - yq --help - # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml # TODO: How to verify this works at all? - name: Prepare ccache timestamp @@ -78,6 +72,13 @@ jobs: ssh-agent -a $SSH_AUTH_SOCK > /dev/null ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" + # TODO: Figure out how to do different build flags depending on the build type + - name: Build library + run: ./gradlew assemble $BUILD_FLAGS --stacktrace + + - name: Run Tests + run: ./gradlew check $BUILD_FLAGS --stacktrace + # TODO Find a way to start the Docker test image while also having the emulator available - name: Start MongoDB Realm Test Server env: @@ -91,13 +92,6 @@ jobs: profile: Nexus 6 script: bash tools/sync_test_server/ci_run_integration_tests.sh - # TODO: Figure out how to do different build flags depending on the build type - - name: Build library - run: ./gradlew assemble $BUILD_FLAGS --stacktrace - - - name: Run Tests - run: ./gradlew check $BUILD_FLAGS --stacktrace - # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around # we archive the test results from mac-os and download them to a Linux runner. - name: Upload Test Results From f793e9661e9417a3bbd0f0b6523221355a73c46c Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sat, 13 Mar 2021 01:06:24 +0100 Subject: [PATCH 57/93] Don't wait when killing servers --- .github/workflows/pr.yml | 24 ++++++------------- .../baas_local/stop_local_server.sh | 1 - 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ba33e57db0..695858fbbc 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -79,21 +79,6 @@ jobs: - name: Run Tests run: ./gradlew check $BUILD_FLAGS --stacktrace - # TODO Find a way to start the Docker test image while also having the emulator available - - name: Start MongoDB Realm Test Server - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - target: default - arch: x86_64 - ndk: 22.0.7026061 - profile: Nexus 6 - script: bash tools/sync_test_server/ci_run_integration_tests.sh - - # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around - # we archive the test results from mac-os and download them to a Linux runner. - name: Upload Test Results if: always() uses: actions/upload-artifact@v2 @@ -104,7 +89,10 @@ jobs: examples/unitTestExample/build/test-results/**/TEST-*.xml realm/realm-library/build/test-results/**/TEST-*.xml - - name: Run Integration Tests + # TODO Find a way to start the Docker test image while also having the emulator available + - name: Start MongoDB Realm Test Server + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 @@ -112,8 +100,10 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: cd realm && ./gradlew connectedBaseDebugAndroidTest $BUILD_FLAGS + script: bash tools/sync_test_server/ci_run_integration_tests.sh + # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around + # we archive the test results from mac-os and download them to a Linux runner. - name: Upload Integration Test Results if: always() uses: actions/upload-artifact@v2 diff --git a/tools/sync_test_server/baas_local/stop_local_server.sh b/tools/sync_test_server/baas_local/stop_local_server.sh index ae639690ee..8bbdc9b935 100755 --- a/tools/sync_test_server/baas_local/stop_local_server.sh +++ b/tools/sync_test_server/baas_local/stop_local_server.sh @@ -18,5 +18,4 @@ if [[ -n "$PIDS_TO_KILL" ]]; then echo "Killing $PIDS_TO_KILL" kill $PIDS_TO_KILL echo "Waiting for processes to exit" - wait fi \ No newline at end of file From f257781efa4c75ec459bb0873afff96d7d253605 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sat, 13 Mar 2021 12:34:36 +0100 Subject: [PATCH 58/93] Force kill test servers --- .github/workflows/pr.yml | 5 +++++ tools/sync_test_server/baas_local/stop_local_server.sh | 3 +-- tools/sync_test_server/ci_run_integration_tests.sh | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 695858fbbc..81256219e7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,6 +25,11 @@ jobs: with: submodules: 'recursive' + - name: Setup script variables + - run: | + echo "Comment on PR #${{ github.event.issue.number }} + echo "Running on branch ${GITHUB_REF##*/}" + # TODO How to optimize this? Can we cache it? # Already available on Github Runners # - brew install jq diff --git a/tools/sync_test_server/baas_local/stop_local_server.sh b/tools/sync_test_server/baas_local/stop_local_server.sh index 8bbdc9b935..b8d8d4422d 100755 --- a/tools/sync_test_server/baas_local/stop_local_server.sh +++ b/tools/sync_test_server/baas_local/stop_local_server.sh @@ -16,6 +16,5 @@ if [[ -f $SCRIPTPATH/tmp-baas/baas_ready ]]; then fi if [[ -n "$PIDS_TO_KILL" ]]; then echo "Killing $PIDS_TO_KILL" - kill $PIDS_TO_KILL - echo "Waiting for processes to exit" + kill -9 $PIDS_TO_KILL fi \ No newline at end of file diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index 4330dbffed..a49c73c6f8 100644 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -2,9 +2,11 @@ SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +echo "Start building local BAAS" cd $SCRIPTPATH/baas_local bash ./start_local_server.sh cd ../../../realm ./gradlew connectedBaseDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true cd $SCRIPTPATH/baas_local -bash ./stop_local_server.sh \ No newline at end of file +bash ./stop_local_server.sh +echo "Local servers stopped" \ No newline at end of file From 02e7afe69a83d213a2f851b3057d24fb60773902 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sat, 13 Mar 2021 12:36:27 +0100 Subject: [PATCH 59/93] Syntax error --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 81256219e7..d2da41d9b9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -26,7 +26,7 @@ jobs: submodules: 'recursive' - name: Setup script variables - - run: | + run: | echo "Comment on PR #${{ github.event.issue.number }} echo "Running on branch ${GITHUB_REF##*/}" From a65d8f85c18584994062aaadc647eed7a85f2cc2 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sat, 13 Mar 2021 12:38:30 +0100 Subject: [PATCH 60/93] More syntax --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d2da41d9b9..09d36ed0fe 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -27,7 +27,7 @@ jobs: - name: Setup script variables run: | - echo "Comment on PR #${{ github.event.issue.number }} + echo "Comment on PR #${{ github.event.issue.number }}" echo "Running on branch ${GITHUB_REF##*/}" # TODO How to optimize this? Can we cache it? From 4ced0fd04ee2638480b8ee8b9cfb15be97d8b84e Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sat, 13 Mar 2021 21:51:13 +0100 Subject: [PATCH 61/93] Test emulator --- .github/workflows/pr.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 09d36ed0fe..4b9c5ff166 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,10 +25,17 @@ jobs: with: submodules: 'recursive' - - name: Setup script variables - run: | - echo "Comment on PR #${{ github.event.issue.number }}" - echo "Running on branch ${GITHUB_REF##*/}" + - name: Debug emulator + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + target: default + arch: x86_64 + ndk: 22.0.7026061 + profile: Nexus 6 + script: adb devices && echo "Done running" # TODO How to optimize this? Can we cache it? # Already available on Github Runners From 6ebe987abdf9e4b251586d2fa9b5d315f600f214 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sat, 13 Mar 2021 23:42:02 +0100 Subject: [PATCH 62/93] Attempt to run ci script directly --- .github/workflows/pr.yml | 14 +------------- tools/sync_test_server/ci_run_integration_tests.sh | 0 2 files changed, 1 insertion(+), 13 deletions(-) mode change 100644 => 100755 tools/sync_test_server/ci_run_integration_tests.sh diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4b9c5ff166..906043f639 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,18 +25,6 @@ jobs: with: submodules: 'recursive' - - name: Debug emulator - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - target: default - arch: x86_64 - ndk: 22.0.7026061 - profile: Nexus 6 - script: adb devices && echo "Done running" - # TODO How to optimize this? Can we cache it? # Already available on Github Runners # - brew install jq @@ -112,7 +100,7 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: bash tools/sync_test_server/ci_run_integration_tests.sh + script: tools/sync_test_server/ci_run_integration_tests.sh # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around # we archive the test results from mac-os and download them to a Linux runner. diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh old mode 100644 new mode 100755 From 0305723bd0ac3fd2b6103b919c12ca7c58afd6cc Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sun, 14 Mar 2021 20:54:44 +0100 Subject: [PATCH 63/93] Attempt to close integration tests --- .github/workflows/pr.yml | 26 +++++++++---------- .../ci_run_integration_tests.sh | 5 ++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 906043f639..9d81febed1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -74,20 +74,20 @@ jobs: # TODO: Figure out how to do different build flags depending on the build type - name: Build library - run: ./gradlew assemble $BUILD_FLAGS --stacktrace + run: ./gradlew assembleObjectServerDebug $BUILD_FLAGS --stacktrace - - name: Run Tests - run: ./gradlew check $BUILD_FLAGS --stacktrace +# - name: Run Tests +# run: ./gradlew check $BUILD_FLAGS --stacktrace - - name: Upload Test Results - if: always() - uses: actions/upload-artifact@v2 - with: - name: unit-test-results - path: | - realm/realm-annotations-processor/build/test-results/test/TEST-*.xml - examples/unitTestExample/build/test-results/**/TEST-*.xml - realm/realm-library/build/test-results/**/TEST-*.xml +# - name: Upload Test Results +# if: always() +# uses: actions/upload-artifact@v2 +# with: +# name: unit-test-results +# path: | +# realm/realm-annotations-processor/build/test-results/test/TEST-*.xml +# examples/unitTestExample/build/test-results/**/TEST-*.xml +# realm/realm-library/build/test-results/**/TEST-*.xml # TODO Find a way to start the Docker test image while also having the emulator available - name: Start MongoDB Realm Test Server @@ -100,7 +100,7 @@ jobs: arch: x86_64 ndk: 22.0.7026061 profile: Nexus 6 - script: tools/sync_test_server/ci_run_integration_tests.sh + script: bash tools/sync_test_server/ci_run_integration_tests.sh # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around # we archive the test results from mac-os and download them to a Linux runner. diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index a49c73c6f8..5d1b94a51f 100755 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -6,7 +6,8 @@ echo "Start building local BAAS" cd $SCRIPTPATH/baas_local bash ./start_local_server.sh cd ../../../realm -./gradlew connectedBaseDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true +./gradlew connectedObjectServerDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true cd $SCRIPTPATH/baas_local bash ./stop_local_server.sh -echo "Local servers stopped" \ No newline at end of file +echo "Local servers stopped" +return 0 \ No newline at end of file From 4d3a2c607ed4850c7b33c8b0af490c04145ade8f Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sun, 14 Mar 2021 21:20:20 +0100 Subject: [PATCH 64/93] Assemble all flavours --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9d81febed1..f12666852e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -74,7 +74,7 @@ jobs: # TODO: Figure out how to do different build flags depending on the build type - name: Build library - run: ./gradlew assembleObjectServerDebug $BUILD_FLAGS --stacktrace + run: ./gradlew assemble $BUILD_FLAGS --stacktrace # - name: Run Tests # run: ./gradlew check $BUILD_FLAGS --stacktrace From 1a7f35babd8f00a6fc84ae69ba5afc1853fe1513 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sun, 14 Mar 2021 22:34:37 +0100 Subject: [PATCH 65/93] More debugging attempts --- .github/workflows/pr.yml | 35 ++++++++++++------- .../ci_run_integration_tests.sh | 2 +- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f12666852e..5b717d56d6 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -72,6 +72,18 @@ jobs: ssh-agent -a $SSH_AUTH_SOCK > /dev/null ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" + - name: Debug why tests don't finish + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + target: default + arch: x86_64 + ndk: 22.0.7026061 + profile: Nexus 6 + script: bash tools/sync_test_server/ci_run_integration_tests.sh + # TODO: Figure out how to do different build flags depending on the build type - name: Build library run: ./gradlew assemble $BUILD_FLAGS --stacktrace @@ -89,18 +101,17 @@ jobs: # examples/unitTestExample/build/test-results/**/TEST-*.xml # realm/realm-library/build/test-results/**/TEST-*.xml - # TODO Find a way to start the Docker test image while also having the emulator available - - name: Start MongoDB Realm Test Server - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - target: default - arch: x86_64 - ndk: 22.0.7026061 - profile: Nexus 6 - script: bash tools/sync_test_server/ci_run_integration_tests.sh +# - name: Start MongoDB Realm Test Server +# env: +# SSH_AUTH_SOCK: /tmp/ssh_agent.sock +# uses: reactivecircus/android-emulator-runner@v2 +# with: +# api-level: 29 +# target: default +# arch: x86_64 +# ndk: 22.0.7026061 +# profile: Nexus 6 +# script: bash tools/sync_test_server/ci_run_integration_tests.sh # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around # we archive the test results from mac-os and download them to a Linux runner. diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index 5d1b94a51f..d53f4a3292 100755 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -6,7 +6,7 @@ echo "Start building local BAAS" cd $SCRIPTPATH/baas_local bash ./start_local_server.sh cd ../../../realm -./gradlew connectedObjectServerDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true +# ./gradlew connectedObjectServerDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true cd $SCRIPTPATH/baas_local bash ./stop_local_server.sh echo "Local servers stopped" From 31a1d4c0f181ca0a822a56f2b4115059f20b7fef Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sun, 14 Mar 2021 22:50:03 +0100 Subject: [PATCH 66/93] Also kill mongodb service --- tools/sync_test_server/baas_local/stop_local_server.sh | 5 ++++- tools/sync_test_server/ci_run_integration_tests.sh | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/sync_test_server/baas_local/stop_local_server.sh b/tools/sync_test_server/baas_local/stop_local_server.sh index b8d8d4422d..98f08462c4 100755 --- a/tools/sync_test_server/baas_local/stop_local_server.sh +++ b/tools/sync_test_server/baas_local/stop_local_server.sh @@ -11,10 +11,13 @@ fi if [[ -f $SCRIPTPATH/tmp-baas/baas_server.pid ]]; then PIDS_TO_KILL="$(< $SCRIPTPATH/tmp-baas/baas_server.pid) $PIDS_TO_KILL" fi +if [[ -f $SCRIPTPATH/tmp-baas/mongod.pid ]]; then + PIDS_TO_KILL="$(< $SCRIPTPATH/tmp-baas/mongod.pid) $PIDS_TO_KILL" +fi if [[ -f $SCRIPTPATH/tmp-baas/baas_ready ]]; then rm $SCRIPTPATH/tmp-baas/baas_ready fi if [[ -n "$PIDS_TO_KILL" ]]; then echo "Killing $PIDS_TO_KILL" - kill -9 $PIDS_TO_KILL + kill $PIDS_TO_KILL fi \ No newline at end of file diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index d53f4a3292..b280f55542 100755 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -10,4 +10,3 @@ cd ../../../realm cd $SCRIPTPATH/baas_local bash ./stop_local_server.sh echo "Local servers stopped" -return 0 \ No newline at end of file From 86e18152f36c336dd2b1b546f6ca475706c804bf Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Sun, 14 Mar 2021 23:13:31 +0100 Subject: [PATCH 67/93] Cleanup. Re-enable integration tests --- .github/workflows/pr.yml | 99 ++++++++----------- .../ci_run_integration_tests.sh | 3 +- 2 files changed, 45 insertions(+), 57 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5b717d56d6..d100e1383e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,9 +25,7 @@ jobs: with: submodules: 'recursive' - # TODO How to optimize this? Can we cache it? - # Already available on Github Runners - # - brew install jq + # TODO Can we optimize this? Caching? - name: Install dependencies run: | brew install ninja @@ -72,7 +70,24 @@ jobs: ssh-agent -a $SSH_AUTH_SOCK > /dev/null ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" - - name: Debug why tests don't finish + # TODO: Figure out how to do different build flags depending on the build type. + - name: Build library + run: ./gradlew assemble $BUILD_FLAGS --stacktrace + + - name: Run Unit Tests + run: ./gradlew check $BUILD_FLAGS --stacktrace + + - name: Upload Unit Test Results + if: always() + uses: actions/upload-artifact@v2 + with: + name: unit-test-results + path: | + realm/realm-annotations-processor/build/test-results/test/TEST-*.xml + examples/unitTestExample/build/test-results/**/TEST-*.xml + realm/realm-library/build/test-results/**/TEST-*.xml + + - name: Run Integration Tests env: SSH_AUTH_SOCK: /tmp/ssh_agent.sock uses: reactivecircus/android-emulator-runner@v2 @@ -84,35 +99,6 @@ jobs: profile: Nexus 6 script: bash tools/sync_test_server/ci_run_integration_tests.sh - # TODO: Figure out how to do different build flags depending on the build type - - name: Build library - run: ./gradlew assemble $BUILD_FLAGS --stacktrace - -# - name: Run Tests -# run: ./gradlew check $BUILD_FLAGS --stacktrace - -# - name: Upload Test Results -# if: always() -# uses: actions/upload-artifact@v2 -# with: -# name: unit-test-results -# path: | -# realm/realm-annotations-processor/build/test-results/test/TEST-*.xml -# examples/unitTestExample/build/test-results/**/TEST-*.xml -# realm/realm-library/build/test-results/**/TEST-*.xml - -# - name: Start MongoDB Realm Test Server -# env: -# SSH_AUTH_SOCK: /tmp/ssh_agent.sock -# uses: reactivecircus/android-emulator-runner@v2 -# with: -# api-level: 29 -# target: default -# arch: x86_64 -# ndk: 22.0.7026061 -# profile: Nexus 6 -# script: bash tools/sync_test_server/ci_run_integration_tests.sh - # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around # we archive the test results from mac-os and download them to a Linux runner. - name: Upload Integration Test Results @@ -124,26 +110,27 @@ jobs: realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' - process-test-results: - needs: run-pr-build - runs-on: ubuntu-latest - steps: - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - path: artifacts - - - name: Publish Annotation Processor Results - uses: EnricoMi/publish-unit-test-result-action@master - with: - files: artifacts/unit-test-results/realm-java/realm/realm-annotations-processor/build/test-results/test/TEST-*.xml - - - name: Publish Example Project Results - uses: EnricoMi/publish-unit-test-result-action@master - with: - files: artifacts/unit-test-results/realm-java/examples/unitTestExample/build/test-results/**/TEST-*.xml - - - name: Publish Library Test Results - uses: EnricoMi/publish-unit-test-result-action@master - with: - files: artifacts/unit-test-results/realm-java/realm/realm-library/build/test-results/**/TEST-*.xml +# TODO: Figure out another way to publish Unit Test Results. Maybe https://github.com/mikepenz/action-junit-report +# process-test-results: +# needs: run-pr-build +# runs-on: ubuntu-latest +# steps: +# - name: Download Artifacts +# uses: actions/download-artifact@v2 +# with: +# path: artifacts +# +# - name: Publish Annotation Processor Results +# uses: EnricoMi/publish-unit-test-result-action@master +# with: +# files: artifacts/unit-test-results/realm-java/realm/realm-annotations-processor/build/test-results/test/TEST-*.xml +# +# - name: Publish Example Project Results +# uses: EnricoMi/publish-unit-test-result-action@master +# with: +# files: artifacts/unit-test-results/realm-java/examples/unitTestExample/build/test-results/**/TEST-*.xml +# +# - name: Publish Library Test Results +# uses: EnricoMi/publish-unit-test-result-action@master +# with: +# files: artifacts/unit-test-results/realm-java/realm/realm-library/build/test-results/**/TEST-*.xml diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index b280f55542..df1d1a041c 100755 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -6,7 +6,8 @@ echo "Start building local BAAS" cd $SCRIPTPATH/baas_local bash ./start_local_server.sh cd ../../../realm -# ./gradlew connectedObjectServerDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true +# TODO: Support different flags and tests for full release buils +./gradlew connectedObjectServerDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true cd $SCRIPTPATH/baas_local bash ./stop_local_server.sh echo "Local servers stopped" From e597d84a10d1f916ed20706212bd389445408b0f Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 08:02:33 +0100 Subject: [PATCH 68/93] Exit code from intetegration tests are the only one that matters --- tools/sync_test_server/ci_run_integration_tests.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index df1d1a041c..c0a130d9f7 100755 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -8,6 +8,9 @@ bash ./start_local_server.sh cd ../../../realm # TODO: Support different flags and tests for full release buils ./gradlew connectedObjectServerDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true +EXIT_CODE=`echo $?` +print "Android tests exit code: $EXIT_CODE" cd $SCRIPTPATH/baas_local bash ./stop_local_server.sh echo "Local servers stopped" +exit $EXIT_CODE \ No newline at end of file From d73a9b7bd24e0dc2df08237aabe380ba051c52d3 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 09:28:57 +0100 Subject: [PATCH 69/93] Composite builds. Add preliminary boilerplate for snapshot/full releases --- .github/actions/build-library.yml | 123 ++++++++++++++++++ .github/workflows/pr.yml | 101 +------------- .github/workflows/releases.yml | 11 ++ .github/workflows/snapshots.yml | 12 ++ .../ci_run_integration_tests.sh | 2 +- 5 files changed, 152 insertions(+), 97 deletions(-) create mode 100644 .github/actions/build-library.yml create mode 100644 .github/workflows/releases.yml create mode 100644 .github/workflows/snapshots.yml diff --git a/.github/actions/build-library.yml b/.github/actions/build-library.yml new file mode 100644 index 0000000000..6c7c87e64e --- /dev/null +++ b/.github/actions/build-library.yml @@ -0,0 +1,123 @@ +# Configurable build step that build and test the library depending +name: 'Build and Test Library' +description: 'Runs the build and test steps of verifying ' +inputs: + scope: + description: > + The scope of the build. Must either be `full` or `minimal`. Full builds build for all + architectures and with LTO enabled. `minimal` only built for x86 and without LTO + required: true + default: 'minimal' +env: + # Define possible toggles. + FULL_BUILD_FLAGS: -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true + FULL_TEST_TARGET: connectedAndroidTest + MIN_BUILD_FLAGS: -PenableLTO=true -PbuildCore=true + MIN_TEST_TARGET: connectedObjectServerDebugAndroidTest + + CCACHE_CPP2: yes + +runs: + using: "composite" + steps: + steps: + - name: Setup conditional environment variables + run: | + if [[ $INPUT_SCOPE == 'full' ]]; then + echo "BUILD_FLAGS=$FULL_BUILD_FLAGS" >> $GITHUB_ENV + echo "TEST_TARGET=$FULL_TEST_TARGET" >> $GITHUB_ENV + else + echo "BUILD_FLAGS=$MIN_BUILD_FLAGS" >> $GITHUB_ENV + echo "TEST_TARGET=$MIN_TEST_TARGET" >> $GITHUB_ENV + + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + # TODO Can we optimize this? Caching? + - name: Install dependencies + run: | + brew install ninja + brew install ccache + brew install yq + npm install -g mongodb-realm-cli + + # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml + # TODO: How to verify this works at all? + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + + - name: ccache cache files + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-ccache- + + # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: '3.18.4' + + - name: Cache Gradle + uses: actions/cache@v2.1.0 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-gradle- + + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" + + # TODO: Figure out how to do different build flags depending on the build type. + - name: Build library + run: ./gradlew assemble $BUILD_FLAGS --stacktrace + + - name: Run Unit Tests + run: ./gradlew check $BUILD_FLAGS --stacktrace + + - name: Upload Unit Test Results + if: always() + uses: actions/upload-artifact@v2 + with: + name: unit-test-results + path: | + realm/realm-annotations-processor/build/test-results/test/TEST-*.xml + examples/unitTestExample/build/test-results/**/TEST-*.xml + realm/realm-library/build/test-results/**/TEST-*.xml + + - name: Run Integration Tests + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + target: default + arch: x86_64 + ndk: 22.0.7026061 + profile: Nexus 6 + script: bash tools/sync_test_server/ci_run_integration_tests.sh + + # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around + # we archive the test results from mac-os and download them to a Linux runner. + - name: Upload Integration Test Results + if: always() + uses: actions/upload-artifact@v2 + with: + name: integration-test-results + path: | + realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' + realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' + +# \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d100e1383e..5d802f4f14 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,4 @@ -# Define how pull requests are built and tested. +# Workflow that defines how pull requests are built and tested. name: Pull Requests on: pull_request: @@ -7,12 +7,6 @@ on: env: # GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m" - - # GitHub Actions does not support variables. Use environments vars as a work-around - BUILD_FLAGS: -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true - - # TODO: From DockerFile, not sure if needed - CCACHE_CPP2: yes # CMAKE_VERSION: 3.18.4 # CCACHE_VERSION: 3.7.7 @@ -20,97 +14,12 @@ jobs: run-pr-build: runs-on: macos-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - # TODO Can we optimize this? Caching? - - name: Install dependencies - run: | - brew install ninja - brew install ccache - brew install yq - npm install -g mongodb-realm-cli - - # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml - # TODO: How to verify this works at all? - - name: Prepare ccache timestamp - id: ccache_cache_timestamp - shell: cmake -P {0} - run: | - string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) - message("::set-output name=timestamp::${current_date}") - - - name: ccache cache files - uses: actions/cache@v1.1.0 - with: - path: .ccache - key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} - restore-keys: | - ${{ runner.os }}-ccache- - - # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1.8 - with: - cmake-version: '3.18.4' - - - name: Cache Gradle - uses: actions/cache@v2.1.0 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: ${{ runner.os }}-gradle- - - - name: Setup SSH Keys and known_hosts - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - run: | - ssh-agent -a $SSH_AUTH_SOCK > /dev/null - ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" - - # TODO: Figure out how to do different build flags depending on the build type. - - name: Build library - run: ./gradlew assemble $BUILD_FLAGS --stacktrace - - - name: Run Unit Tests - run: ./gradlew check $BUILD_FLAGS --stacktrace - - - name: Upload Unit Test Results - if: always() - uses: actions/upload-artifact@v2 - with: - name: unit-test-results - path: | - realm/realm-annotations-processor/build/test-results/test/TEST-*.xml - examples/unitTestExample/build/test-results/**/TEST-*.xml - realm/realm-library/build/test-results/**/TEST-*.xml - - - name: Run Integration Tests - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - target: default - arch: x86_64 - ndk: 22.0.7026061 - profile: Nexus 6 - script: bash tools/sync_test_server/ci_run_integration_tests.sh - - # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around - # we archive the test results from mac-os and download them to a Linux runner. - - name: Upload Integration Test Results - if: always() - uses: actions/upload-artifact@v2 + - name: Build and Test Library + uses: ./.github/actions/build-library with: - name: integration-test-results - path: | - realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' - realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' + scope: minimal -# TODO: Figure out another way to publish Unit Test Results. Maybe https://github.com/mikepenz/action-junit-report +# TODO: Figure out another way to publish Unit Test Results. Maybe https://github.com/mikepenz/action-junit-report # process-test-results: # needs: run-pr-build # runs-on: ubuntu-latest diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml new file mode 100644 index 0000000000..25f7019b75 --- /dev/null +++ b/.github/workflows/releases.yml @@ -0,0 +1,11 @@ +# Workflow for building and publishing releases to Maven Central. +name: Publish release +on: + push: + tags: + - 'v*' + +jobs: + + + diff --git a/.github/workflows/snapshots.yml b/.github/workflows/snapshots.yml new file mode 100644 index 0000000000..601bc631c5 --- /dev/null +++ b/.github/workflows/snapshots.yml @@ -0,0 +1,12 @@ +# Workflow for building and publishing SNAPSHOT releases to Maven Central. +name: Create SNAPSHOT release +on: + push: + branches: + - master + - releases +env: +jobs: + + + diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index c0a130d9f7..7adfa51469 100755 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -9,7 +9,7 @@ cd ../../../realm # TODO: Support different flags and tests for full release buils ./gradlew connectedObjectServerDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true EXIT_CODE=`echo $?` -print "Android tests exit code: $EXIT_CODE" +echo "Android tests exit code: $EXIT_CODE" cd $SCRIPTPATH/baas_local bash ./stop_local_server.sh echo "Local servers stopped" From cb86f1759db32171678a1905285078cf0f2e8917 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 09:32:32 +0100 Subject: [PATCH 70/93] Syntax fixes --- .github/workflows/pr.yml | 2 +- .github/workflows/releases.yml | 5 +++++ .github/workflows/snapshots.yml | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5d802f4f14..f747668736 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,7 +5,7 @@ on: paths-ignore: - '*.md' -env: +#env: # GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m" # CMAKE_VERSION: 3.18.4 # CCACHE_VERSION: 3.7.7 diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 25f7019b75..728b8a62ec 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -6,6 +6,11 @@ on: - 'v*' jobs: + run-release-build: + runs-on: macos-latest + steps: + - name: Build and Test Library + run: echo "Work work work..." diff --git a/.github/workflows/snapshots.yml b/.github/workflows/snapshots.yml index 601bc631c5..9ea23c351c 100644 --- a/.github/workflows/snapshots.yml +++ b/.github/workflows/snapshots.yml @@ -7,6 +7,11 @@ on: - releases env: jobs: + run-snapshot-build: + runs-on: macos-latest + steps: + - name: Build and Test Library + run: echo "Work work work..." From fd9566e27218937b9364b17e03249bffb2fbcd56 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 09:39:36 +0100 Subject: [PATCH 71/93] Correct location for sharing actions --- .github/actions/{build-library.yml => build-library/action.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/actions/{build-library.yml => build-library/action.yml} (100%) diff --git a/.github/actions/build-library.yml b/.github/actions/build-library/action.yml similarity index 100% rename from .github/actions/build-library.yml rename to .github/actions/build-library/action.yml From 8dc564b7f2a828a1bf5ac556a6745897b75ffd72 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 09:42:41 +0100 Subject: [PATCH 72/93] Checkout action before usage --- .github/workflows/pr.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f747668736..34a1560f81 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,6 +14,8 @@ jobs: run-pr-build: runs-on: macos-latest steps: + # See https://github.community/t/path-to-action-in-the-same-repository-as-workflow/16952/2 + - uses: actions/checkout@v1 - name: Build and Test Library uses: ./.github/actions/build-library with: From e07592b4efda6b87e26bbdd8a22b47fe2b3b8ca1 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 09:47:53 +0100 Subject: [PATCH 73/93] Fix shell script syntax --- .github/actions/build-library/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/build-library/action.yml b/.github/actions/build-library/action.yml index 6c7c87e64e..5deba1677f 100644 --- a/.github/actions/build-library/action.yml +++ b/.github/actions/build-library/action.yml @@ -29,6 +29,7 @@ runs: else echo "BUILD_FLAGS=$MIN_BUILD_FLAGS" >> $GITHUB_ENV echo "TEST_TARGET=$MIN_TEST_TARGET" >> $GITHUB_ENV + endif - name: Checkout code uses: actions/checkout@v2 From b6beab4853dc22697e37bd5ce07154082d6cc167 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 10:07:16 +0100 Subject: [PATCH 74/93] Attempt to fix script --- .github/actions/build-library/action.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/actions/build-library/action.yml b/.github/actions/build-library/action.yml index 5deba1677f..b9260933f4 100644 --- a/.github/actions/build-library/action.yml +++ b/.github/actions/build-library/action.yml @@ -8,14 +8,6 @@ inputs: architectures and with LTO enabled. `minimal` only built for x86 and without LTO required: true default: 'minimal' -env: - # Define possible toggles. - FULL_BUILD_FLAGS: -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true - FULL_TEST_TARGET: connectedAndroidTest - MIN_BUILD_FLAGS: -PenableLTO=true -PbuildCore=true - MIN_TEST_TARGET: connectedObjectServerDebugAndroidTest - - CCACHE_CPP2: yes runs: using: "composite" @@ -23,13 +15,14 @@ runs: steps: - name: Setup conditional environment variables run: | - if [[ $INPUT_SCOPE == 'full' ]]; then - echo "BUILD_FLAGS=$FULL_BUILD_FLAGS" >> $GITHUB_ENV - echo "TEST_TARGET=$FULL_TEST_TARGET" >> $GITHUB_ENV + if [[ $INPUT_SCOPE == full ]]; then + echo "BUILD_FLAGS=-PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true" >> $GITHUB_ENV + echo "TEST_TARGET=connectedAndroidTest" >> $GITHUB_ENV else - echo "BUILD_FLAGS=$MIN_BUILD_FLAGS" >> $GITHUB_ENV - echo "TEST_TARGET=$MIN_TEST_TARGET" >> $GITHUB_ENV + echo "BUILD_FLAGS=-PenableLTO=true -PbuildCore=true" >> $GITHUB_ENV + echo "TEST_TARGET=connectedObjectServerDebugAndroidTest" >> $GITHUB_ENV endif + echo "CCACHE_CPP2=yes" >> $GITHUB_ENV - name: Checkout code uses: actions/checkout@v2 From eccf10f9e65705d23856bc6bda1a3a01b953927e Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 10:15:36 +0100 Subject: [PATCH 75/93] Disable env for debugging --- .github/actions/build-library/action.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/actions/build-library/action.yml b/.github/actions/build-library/action.yml index b9260933f4..10f83e5fcc 100644 --- a/.github/actions/build-library/action.yml +++ b/.github/actions/build-library/action.yml @@ -13,16 +13,16 @@ runs: using: "composite" steps: steps: - - name: Setup conditional environment variables - run: | - if [[ $INPUT_SCOPE == full ]]; then - echo "BUILD_FLAGS=-PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true" >> $GITHUB_ENV - echo "TEST_TARGET=connectedAndroidTest" >> $GITHUB_ENV - else - echo "BUILD_FLAGS=-PenableLTO=true -PbuildCore=true" >> $GITHUB_ENV - echo "TEST_TARGET=connectedObjectServerDebugAndroidTest" >> $GITHUB_ENV - endif - echo "CCACHE_CPP2=yes" >> $GITHUB_ENV +# - name: Setup conditional environment variables +# run: | +# if [[ $INPUT_SCOPE == full ]]; then +# echo "BUILD_FLAGS=-PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true" >> $GITHUB_ENV +# echo "TEST_TARGET=connectedAndroidTest" >> $GITHUB_ENV +# else +# echo "BUILD_FLAGS=-PenableLTO=true -PbuildCore=true" >> $GITHUB_ENV +# echo "TEST_TARGET=connectedObjectServerDebugAndroidTest" >> $GITHUB_ENV +# endif +# echo "CCACHE_CPP2=yes" >> $GITHUB_ENV - name: Checkout code uses: actions/checkout@v2 From dbd2c2d245ac3a5030e99e406da66c159a974e06 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 10:17:59 +0100 Subject: [PATCH 76/93] Checkout code in workflow --- .github/actions/build-library/action.yml | 7 +------ .github/workflows/pr.yml | 6 +++++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/actions/build-library/action.yml b/.github/actions/build-library/action.yml index 10f83e5fcc..13fc1f9379 100644 --- a/.github/actions/build-library/action.yml +++ b/.github/actions/build-library/action.yml @@ -23,12 +23,7 @@ runs: # echo "TEST_TARGET=connectedObjectServerDebugAndroidTest" >> $GITHUB_ENV # endif # echo "CCACHE_CPP2=yes" >> $GITHUB_ENV - - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: 'recursive' - + - # TODO Can we optimize this? Caching? - name: Install dependencies run: | diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 34a1560f81..28991490a5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,7 +15,11 @@ jobs: runs-on: macos-latest steps: # See https://github.community/t/path-to-action-in-the-same-repository-as-workflow/16952/2 - - uses: actions/checkout@v1 + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Build and Test Library uses: ./.github/actions/build-library with: From aba113c6384e8912af54006566500e929db86882 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 10:21:18 +0100 Subject: [PATCH 77/93] Attempt to disable secrets for debugging --- .github/actions/build-library/action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/build-library/action.yml b/.github/actions/build-library/action.yml index 13fc1f9379..0bda84f163 100644 --- a/.github/actions/build-library/action.yml +++ b/.github/actions/build-library/action.yml @@ -62,12 +62,12 @@ runs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ${{ runner.os }}-gradle- - - name: Setup SSH Keys and known_hosts - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - run: | - ssh-agent -a $SSH_AUTH_SOCK > /dev/null - ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" +# - name: Setup SSH Keys and known_hosts +# env: +# SSH_AUTH_SOCK: /tmp/ssh_agent.sock +# run: | +# ssh-agent -a $SSH_AUTH_SOCK > /dev/null +# ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" # TODO: Figure out how to do different build flags depending on the build type. - name: Build library From fd92765567abf489318a908dd5b7b4b7eae177d0 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 10:23:32 +0100 Subject: [PATCH 78/93] Remove duplicate steps section --- .github/actions/build-library/action.yml | 171 +++++++++++------------ 1 file changed, 85 insertions(+), 86 deletions(-) diff --git a/.github/actions/build-library/action.yml b/.github/actions/build-library/action.yml index 0bda84f163..f8a6aa54a8 100644 --- a/.github/actions/build-library/action.yml +++ b/.github/actions/build-library/action.yml @@ -12,101 +12,100 @@ inputs: runs: using: "composite" steps: - steps: -# - name: Setup conditional environment variables -# run: | -# if [[ $INPUT_SCOPE == full ]]; then -# echo "BUILD_FLAGS=-PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true" >> $GITHUB_ENV -# echo "TEST_TARGET=connectedAndroidTest" >> $GITHUB_ENV -# else -# echo "BUILD_FLAGS=-PenableLTO=true -PbuildCore=true" >> $GITHUB_ENV -# echo "TEST_TARGET=connectedObjectServerDebugAndroidTest" >> $GITHUB_ENV -# endif -# echo "CCACHE_CPP2=yes" >> $GITHUB_ENV - - - # TODO Can we optimize this? Caching? - - name: Install dependencies - run: | - brew install ninja - brew install ccache - brew install yq - npm install -g mongodb-realm-cli + - name: Setup conditional environment variables + run: | + if [[ $INPUT_SCOPE == full ]]; then + echo "BUILD_FLAGS=-PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true" >> $GITHUB_ENV + echo "TEST_TARGET=connectedAndroidTest" >> $GITHUB_ENV + else + echo "BUILD_FLAGS=-PenableLTO=true -PbuildCore=true" >> $GITHUB_ENV + echo "TEST_TARGET=connectedObjectServerDebugAndroidTest" >> $GITHUB_ENV + endif + echo "CCACHE_CPP2=yes" >> $GITHUB_ENV - # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml - # TODO: How to verify this works at all? - - name: Prepare ccache timestamp - id: ccache_cache_timestamp - shell: cmake -P {0} - run: | - string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) - message("::set-output name=timestamp::${current_date}") + # TODO Can we optimize this? Caching? + - name: Install dependencies + run: | + brew install ninja + brew install ccache + brew install yq + npm install -g mongodb-realm-cli - - name: ccache cache files - uses: actions/cache@v1.1.0 - with: - path: .ccache - key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} - restore-keys: | - ${{ runner.os }}-ccache- + # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml + # TODO: How to verify this works at all? + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") - # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1.8 - with: - cmake-version: '3.18.4' + - name: ccache cache files + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-ccache- - - name: Cache Gradle - uses: actions/cache@v2.1.0 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: ${{ runner.os }}-gradle- + # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: '3.18.4' -# - name: Setup SSH Keys and known_hosts -# env: -# SSH_AUTH_SOCK: /tmp/ssh_agent.sock -# run: | -# ssh-agent -a $SSH_AUTH_SOCK > /dev/null -# ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" + - name: Cache Gradle + uses: actions/cache@v2.1.0 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-gradle- - # TODO: Figure out how to do different build flags depending on the build type. - - name: Build library - run: ./gradlew assemble $BUILD_FLAGS --stacktrace + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" - - name: Run Unit Tests - run: ./gradlew check $BUILD_FLAGS --stacktrace + # TODO: Figure out how to do different build flags depending on the build type. + - name: Build library + run: ./gradlew assemble $BUILD_FLAGS --stacktrace - - name: Upload Unit Test Results - if: always() - uses: actions/upload-artifact@v2 - with: - name: unit-test-results - path: | - realm/realm-annotations-processor/build/test-results/test/TEST-*.xml - examples/unitTestExample/build/test-results/**/TEST-*.xml - realm/realm-library/build/test-results/**/TEST-*.xml + - name: Run Unit Tests + run: ./gradlew check $BUILD_FLAGS --stacktrace - - name: Run Integration Tests - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - target: default - arch: x86_64 - ndk: 22.0.7026061 - profile: Nexus 6 - script: bash tools/sync_test_server/ci_run_integration_tests.sh + - name: Upload Unit Test Results + if: always() + uses: actions/upload-artifact@v2 + with: + name: unit-test-results + path: | + realm/realm-annotations-processor/build/test-results/test/TEST-*.xml + examples/unitTestExample/build/test-results/**/TEST-*.xml + realm/realm-library/build/test-results/**/TEST-*.xml - # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around - # we archive the test results from mac-os and download them to a Linux runner. - - name: Upload Integration Test Results - if: always() - uses: actions/upload-artifact@v2 - with: - name: integration-test-results - path: | - realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' - realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' + - name: Run Integration Tests + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + target: default + arch: x86_64 + ndk: 22.0.7026061 + profile: Nexus 6 + script: bash tools/sync_test_server/ci_run_integration_tests.sh + + # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around + # we archive the test results from mac-os and download them to a Linux runner. + - name: Upload Integration Test Results + if: always() + uses: actions/upload-artifact@v2 + with: + name: integration-test-results + path: | + realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' + realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' # \ No newline at end of file From 0dfadc666c63fa36364332e4b8c06831cb4dfa1a Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 10:50:40 +0100 Subject: [PATCH 79/93] Back to having a single action --- .github/actions/build-library/action.yml | 2 +- .github/workflows/pr.yml | 99 ++++++++++++++++++++++-- 2 files changed, 93 insertions(+), 8 deletions(-) diff --git a/.github/actions/build-library/action.yml b/.github/actions/build-library/action.yml index f8a6aa54a8..2c2a07d75a 100644 --- a/.github/actions/build-library/action.yml +++ b/.github/actions/build-library/action.yml @@ -13,7 +13,7 @@ runs: using: "composite" steps: - name: Setup conditional environment variables - run: | + shell: | if [[ $INPUT_SCOPE == full ]]; then echo "BUILD_FLAGS=-PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true" >> $GITHUB_ENV echo "TEST_TARGET=connectedAndroidTest" >> $GITHUB_ENV diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 28991490a5..d100e1383e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,12 +1,18 @@ -# Workflow that defines how pull requests are built and tested. +# Define how pull requests are built and tested. name: Pull Requests on: pull_request: paths-ignore: - '*.md' -#env: +env: # GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m" + + # GitHub Actions does not support variables. Use environments vars as a work-around + BUILD_FLAGS: -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true + + # TODO: From DockerFile, not sure if needed + CCACHE_CPP2: yes # CMAKE_VERSION: 3.18.4 # CCACHE_VERSION: 3.7.7 @@ -14,18 +20,97 @@ jobs: run-pr-build: runs-on: macos-latest steps: - # See https://github.community/t/path-to-action-in-the-same-repository-as-workflow/16952/2 - name: Checkout code uses: actions/checkout@v2 with: submodules: 'recursive' - - name: Build and Test Library - uses: ./.github/actions/build-library + # TODO Can we optimize this? Caching? + - name: Install dependencies + run: | + brew install ninja + brew install ccache + brew install yq + npm install -g mongodb-realm-cli + + # CCache setup copied from https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml + # TODO: How to verify this works at all? + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + + - name: ccache cache files + uses: actions/cache@v1.1.0 + with: + path: .ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-ccache- + + # TODO: Figure out why we require 3.18.4. Ideally it should just be minimum versions everywhere? + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: '3.18.4' + + - name: Cache Gradle + uses: actions/cache@v2.1.0 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-gradle- + + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" + + # TODO: Figure out how to do different build flags depending on the build type. + - name: Build library + run: ./gradlew assemble $BUILD_FLAGS --stacktrace + + - name: Run Unit Tests + run: ./gradlew check $BUILD_FLAGS --stacktrace + + - name: Upload Unit Test Results + if: always() + uses: actions/upload-artifact@v2 + with: + name: unit-test-results + path: | + realm/realm-annotations-processor/build/test-results/test/TEST-*.xml + examples/unitTestExample/build/test-results/**/TEST-*.xml + realm/realm-library/build/test-results/**/TEST-*.xml + + - name: Run Integration Tests + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + target: default + arch: x86_64 + ndk: 22.0.7026061 + profile: Nexus 6 + script: bash tools/sync_test_server/ci_run_integration_tests.sh + + # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around + # we archive the test results from mac-os and download them to a Linux runner. + - name: Upload Integration Test Results + if: always() + uses: actions/upload-artifact@v2 with: - scope: minimal + name: integration-test-results + path: | + realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' + realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' -# TODO: Figure out another way to publish Unit Test Results. Maybe https://github.com/mikepenz/action-junit-report +# TODO: Figure out another way to publish Unit Test Results. Maybe https://github.com/mikepenz/action-junit-report # process-test-results: # needs: run-pr-build # runs-on: ubuntu-latest From 180c34f29c9028bd1692bc772f2f7bc5d0571fb0 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 14:30:19 +0100 Subject: [PATCH 80/93] Use commit sha for the test server --- dependencies.list | 6 +++--- tools/sync_test_server/baas_local/start_local_server.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dependencies.list b/dependencies.list index 4c90a89d30..8575fa038b 100644 --- a/dependencies.list +++ b/dependencies.list @@ -2,9 +2,9 @@ # https://github.com/realm/realm-core/releases REALM_CORE=10.3.3 -# Version of MongoDB Realm used by integration tests -# See https://github.com/realm/ci/packages/147854 for available versions -MONGODB_REALM_SERVER=2021-03-09 +# Git commit SHA of MongoDB Realm used by integration tests +# See https://github.com/10gen/baas for available versions +MONGODB_REALM_SERVER=acb927b3b2042b4df38e00928183e62c29b20236 # Common Android settings across projects GRADLE_BUILD_TOOLS=4.0.0 diff --git a/tools/sync_test_server/baas_local/start_local_server.sh b/tools/sync_test_server/baas_local/start_local_server.sh index b45b45c63d..01ac98d39f 100755 --- a/tools/sync_test_server/baas_local/start_local_server.sh +++ b/tools/sync_test_server/baas_local/start_local_server.sh @@ -63,8 +63,8 @@ if [[ -d tmp-baas ]]; then fi # Install and run BAAS -echo "Install and start BAAS..." -sh ./install_baas.sh ./tmp-baas & #$MONGODB_REALM_VERSION +echo "Install and start BAAS: $MONGODB_REALM_VERSION ..." +sh ./install_baas.sh ./tmp-baas $MONGODB_REALM_VERSION & while [[ ! -e $SCRIPTPATH/tmp-baas/baas_ready ]] ; do sleep 1 done @@ -84,5 +84,5 @@ mkdir tmp-command-server || true cd tmp-command-server cp $SCRIPTPATH/../mongodb-realm-command-server.js ./ npm install winston@2.4.0 temp httpdispatcher@1.0.0 fs-extra moment is-port-available@0.1.5 -node ./mongodb-realm-command-server.js $APP_CONFIG_DIR & +node ./mongodb-realm-command-server.js $APP_CONFIG_DIR > command_server_log.txt & echo $! > command_server.pid From 5547f0318d4b8ccf0c6385a54e7073b98762e267 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 15:07:10 +0100 Subject: [PATCH 81/93] Better gradle caching --- .github/workflows/pr.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d100e1383e..90669a76c9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -56,12 +56,15 @@ jobs: with: cmake-version: '3.18.4' - - name: Cache Gradle - uses: actions/cache@v2.1.0 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: ${{ runner.os }}-gradle- + - name: Cache Gradle packages + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- - name: Setup SSH Keys and known_hosts env: @@ -110,6 +113,16 @@ jobs: realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' + # Source: https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle + - name: Cleanup Gradle Cache + if: always() + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties + + # TODO: Figure out another way to publish Unit Test Results. Maybe https://github.com/mikepenz/action-junit-report # process-test-results: # needs: run-pr-build From ea0e1ded69d259f2204455a21168a6bcd4096ca7 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 15:17:18 +0100 Subject: [PATCH 82/93] Fix indentation --- .github/workflows/pr.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 90669a76c9..49e88b4407 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -56,15 +56,15 @@ jobs: with: cmake-version: '3.18.4' - - name: Cache Gradle packages - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + - name: Cache Gradle packages + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- - name: Setup SSH Keys and known_hosts env: From 09e1e04f37a4d4fd85cebf5af0f9ad349d1904f5 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 16:40:43 +0100 Subject: [PATCH 83/93] Archive logcat and mongodb logs --- .github/workflows/pr.yml | 4 +++- tools/sync_test_server/ci_run_integration_tests.sh | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 49e88b4407..0a50436893 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -104,7 +104,7 @@ jobs: # EnricoMi/publish-unit-test-result-action@v1 only works on Linux, so as a work-around # we archive the test results from mac-os and download them to a Linux runner. - - name: Upload Integration Test Results + - name: Archive Integration Test Results and Logs if: always() uses: actions/upload-artifact@v2 with: @@ -112,6 +112,8 @@ jobs: path: | realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' + tools/sync_server_server/logcat.txt + tools/sync_server_server/baas_local/tmp-baas/baas_server.pid # Source: https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle - name: Cleanup Gradle Cache diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index 7adfa51469..5b752e2edc 100755 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -1,15 +1,20 @@ #!/bin/bash - +# Script for running integration tests on CI SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" echo "Start building local BAAS" cd $SCRIPTPATH/baas_local bash ./start_local_server.sh cd ../../../realm -# TODO: Support different flags and tests for full release buils +adb root +adb logcat -b all -c +adb logcat -v time > 'logcat.txt' & +LOG_CAT_PID=`echo \$!` +# TODO: Build parameters should be command line parameters ./gradlew connectedObjectServerDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true EXIT_CODE=`echo $?` echo "Android tests exit code: $EXIT_CODE" +kill $LOG_CAT_PID cd $SCRIPTPATH/baas_local bash ./stop_local_server.sh echo "Local servers stopped" From 457fa5bfde12e096bad758b7190bc1f9839cc326 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 18:03:56 +0100 Subject: [PATCH 84/93] Use latest version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7450372ee4..d29d972e5c 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'ch.netzwerg:gradle-release-plugin:1.2.0' + classpath 'ch.netzwerg:gradle-release-plugin:1.2.5' } } From dcbf3a7572342c4fccce3d4aca0a534f2ceaf851 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 18:08:09 +0100 Subject: [PATCH 85/93] Disable release plugin --- build.gradle | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index d29d972e5c..dd03babadc 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,9 @@ buildscript { jcenter() } dependencies { - classpath 'ch.netzwerg:gradle-release-plugin:1.2.5' + // TODO: https://jcenter.bintray.com/ch/netzwerg/gradle-release-plugin/1.2.5/gradle-release-plugin-1.2.5.pom + // currently returns 500 + // 'ch.netzwerg:gradle-release-plugin:1.2.5' } } @@ -551,8 +553,9 @@ task ojoUpload { // This is just a placeholder for the release plugin task build {} -release { - push = false - versionSuffix = '-SNAPSHOT' - tagPrefix = 'v' -} +// TODO: Re-enable this +//release { +// push = false +// versionSuffix = '-SNAPSHOT' +// tagPrefix = 'v' +//} From b53d93ade2beeed9172b15f4615859d0e3a16eeb Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 18:10:36 +0100 Subject: [PATCH 86/93] Disable release plugin --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index dd03babadc..8ad1a410ad 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,8 @@ buildscript { } } -apply plugin: 'ch.netzwerg.release' +// TODO: Re-enable this +// apply plugin: 'ch.netzwerg.release' def currentVersion = file("${projectDir}/version.txt").text.trim() From b2f178756c1718ad19030e6e3239ee1436f21870 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Mon, 15 Mar 2021 22:01:11 +0100 Subject: [PATCH 87/93] Re-enable parallel builds --- build.gradle | 18 +++++++----------- realm/gradle.properties | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 8ad1a410ad..d29d972e5c 100644 --- a/build.gradle +++ b/build.gradle @@ -3,14 +3,11 @@ buildscript { jcenter() } dependencies { - // TODO: https://jcenter.bintray.com/ch/netzwerg/gradle-release-plugin/1.2.5/gradle-release-plugin-1.2.5.pom - // currently returns 500 - // 'ch.netzwerg:gradle-release-plugin:1.2.5' + classpath 'ch.netzwerg:gradle-release-plugin:1.2.5' } } -// TODO: Re-enable this -// apply plugin: 'ch.netzwerg.release' +apply plugin: 'ch.netzwerg.release' def currentVersion = file("${projectDir}/version.txt").text.trim() @@ -554,9 +551,8 @@ task ojoUpload { // This is just a placeholder for the release plugin task build {} -// TODO: Re-enable this -//release { -// push = false -// versionSuffix = '-SNAPSHOT' -// tagPrefix = 'v' -//} +release { + push = false + versionSuffix = '-SNAPSHOT' + tagPrefix = 'v' +} diff --git a/realm/gradle.properties b/realm/gradle.properties index 29b7bf620b..d9d4d75b67 100644 --- a/realm/gradle.properties +++ b/realm/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs=-Xms1024m -Xmx4096m org.gradle.caching=true kotlin.incremental=false -org.gradle.parallel=false +org.gradle.parallel=true android.useAndroidX=true android.enableJetifier=true From 13f52ae5b18a838a4c33e0f48464a2f6c111020b Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Tue, 16 Mar 2021 09:16:26 +0100 Subject: [PATCH 88/93] Fix bugs when archiving files --- .github/workflows/pr.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 0a50436893..a83a182f04 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -85,6 +85,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: unit-test-results + if-no-files-found: warn path: | realm/realm-annotations-processor/build/test-results/test/TEST-*.xml examples/unitTestExample/build/test-results/**/TEST-*.xml @@ -109,11 +110,12 @@ jobs: uses: actions/upload-artifact@v2 with: name: integration-test-results + if-no-files-found: warn path: | - realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' - realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml' + realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml + realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml tools/sync_server_server/logcat.txt - tools/sync_server_server/baas_local/tmp-baas/baas_server.pid + tools/sync_server_server/baas_local/tmp-baas/baas_server.log # Source: https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle - name: Cleanup Gradle Cache From 93c1557720a192b3480be63cc374ba39e2c40d00 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Tue, 16 Mar 2021 10:47:30 +0100 Subject: [PATCH 89/93] Correctly archive service logs --- .github/workflows/pr.yml | 5 +++-- tools/sync_test_server/baas_local/start_local_server.sh | 2 +- tools/sync_test_server/ci_run_integration_tests.sh | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a83a182f04..89fd9e5e6d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -114,8 +114,9 @@ jobs: path: | realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml realm/kotlin-extensions/build/outputs/androidTest-results/connected/**/TEST-*.xml - tools/sync_server_server/logcat.txt - tools/sync_server_server/baas_local/tmp-baas/baas_server.log + tools/sync_test_server/logcat.txt + tools/sync_test_server/baas_local/tmp-baas/baas_server.log + tools/sync_test_server/baas_local/tmp-command-server/command_server.log # Source: https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle - name: Cleanup Gradle Cache diff --git a/tools/sync_test_server/baas_local/start_local_server.sh b/tools/sync_test_server/baas_local/start_local_server.sh index 01ac98d39f..0042b16413 100755 --- a/tools/sync_test_server/baas_local/start_local_server.sh +++ b/tools/sync_test_server/baas_local/start_local_server.sh @@ -84,5 +84,5 @@ mkdir tmp-command-server || true cd tmp-command-server cp $SCRIPTPATH/../mongodb-realm-command-server.js ./ npm install winston@2.4.0 temp httpdispatcher@1.0.0 fs-extra moment is-port-available@0.1.5 -node ./mongodb-realm-command-server.js $APP_CONFIG_DIR > command_server_log.txt & +node ./mongodb-realm-command-server.js $APP_CONFIG_DIR > command_server.log & echo $! > command_server.pid diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index 5b752e2edc..31a3708f0d 100755 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -8,7 +8,7 @@ bash ./start_local_server.sh cd ../../../realm adb root adb logcat -b all -c -adb logcat -v time > 'logcat.txt' & +adb logcat -v time > $SCRIPTPATH/logcat.txt & LOG_CAT_PID=`echo \$!` # TODO: Build parameters should be command line parameters ./gradlew connectedObjectServerDebugAndroidTest -PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=true From 92c104393f130a7e826519935d234a137e2c9393 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Tue, 16 Mar 2021 13:03:32 +0100 Subject: [PATCH 90/93] Move where adb root is called --- tools/sync_test_server/baas_local/start_local_server.sh | 3 +++ tools/sync_test_server/ci_run_integration_tests.sh | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/sync_test_server/baas_local/start_local_server.sh b/tools/sync_test_server/baas_local/start_local_server.sh index 0042b16413..43e7163e60 100755 --- a/tools/sync_test_server/baas_local/start_local_server.sh +++ b/tools/sync_test_server/baas_local/start_local_server.sh @@ -46,6 +46,9 @@ function import_apps () { SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" MONGODB_REALM_VERSION=$(grep MONGODB_REALM_SERVER $SCRIPTPATH/../../../dependencies.list | cut -d'=' -f2) +# Running as root is not directly required here, but we might want to access files later on the +# emulator. Set root here to avoid resetting network settings later. +adb root adb reverse tcp:9443 tcp:9443 && \ adb reverse tcp:9080 tcp:9080 && \ adb reverse tcp:9090 tcp:9090 && \ diff --git a/tools/sync_test_server/ci_run_integration_tests.sh b/tools/sync_test_server/ci_run_integration_tests.sh index 31a3708f0d..39bb9c8678 100755 --- a/tools/sync_test_server/ci_run_integration_tests.sh +++ b/tools/sync_test_server/ci_run_integration_tests.sh @@ -6,7 +6,6 @@ echo "Start building local BAAS" cd $SCRIPTPATH/baas_local bash ./start_local_server.sh cd ../../../realm -adb root adb logcat -b all -c adb logcat -v time > $SCRIPTPATH/logcat.txt & LOG_CAT_PID=`echo \$!` From 343371b57e1a0f0d98200a7af4f67ed9955d794e Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Tue, 16 Mar 2021 16:00:58 +0100 Subject: [PATCH 91/93] Disable breaking tests --- .../kotlin/io/realm/mongodb/MongoClientTest.kt | 2 ++ .../src/syncIntegrationTest/kotlin/io/realm/SyncSessionTests.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/realm/realm-library/src/androidTestObjectServer/kotlin/io/realm/mongodb/MongoClientTest.kt b/realm/realm-library/src/androidTestObjectServer/kotlin/io/realm/mongodb/MongoClientTest.kt index 1eb6e18310..17def9d0ab 100644 --- a/realm/realm-library/src/androidTestObjectServer/kotlin/io/realm/mongodb/MongoClientTest.kt +++ b/realm/realm-library/src/androidTestObjectServer/kotlin/io/realm/mongodb/MongoClientTest.kt @@ -267,6 +267,7 @@ class MongoClientTest { } @Test + @Ignore("FIXME: Fails on Github Actions CI - https://github.com/realm/realm-java/runs/2121717693") fun aggregate() { with(getCollectionInternal()) { // Aggregate on an empty collection returns false on hasNext and null on first @@ -1452,6 +1453,7 @@ class MongoClientTest { } @Test + @Ignore("FIXME: Fails on Github Actions CI - https://github.com/realm/realm-java/runs/2121717693") fun withDocument() { // aAd default codecs as they too are needed for proper collection initialization val expandedCodecRegistry = CodecRegistries diff --git a/realm/realm-library/src/syncIntegrationTest/kotlin/io/realm/SyncSessionTests.kt b/realm/realm-library/src/syncIntegrationTest/kotlin/io/realm/SyncSessionTests.kt index 311ccdacfd..852deef351 100644 --- a/realm/realm-library/src/syncIntegrationTest/kotlin/io/realm/SyncSessionTests.kt +++ b/realm/realm-library/src/syncIntegrationTest/kotlin/io/realm/SyncSessionTests.kt @@ -272,7 +272,7 @@ class SyncSessionTests { realm.executeTransaction { realm.createObject(SyncAllTypesWithFloat::class.java, ObjectId()) } - assertFailsWithErrorCode(ErrorCode.INVALID_SCHEMA_CHANGE) { + assertFailsWithErrorCode(ErrorCode.BAD_CHANGESET) { realm.syncSession.uploadAllLocalChanges() } } From f3e5008fada654841d11ab03325756f923b9ff3a Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Tue, 16 Mar 2021 16:22:27 +0100 Subject: [PATCH 92/93] Re-enable breaking tests --- .../kotlin/io/realm/mongodb/MongoClientTest.kt | 2 -- tools/sync_test_server/baas_local/install_baas.sh | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/realm/realm-library/src/androidTestObjectServer/kotlin/io/realm/mongodb/MongoClientTest.kt b/realm/realm-library/src/androidTestObjectServer/kotlin/io/realm/mongodb/MongoClientTest.kt index 17def9d0ab..1eb6e18310 100644 --- a/realm/realm-library/src/androidTestObjectServer/kotlin/io/realm/mongodb/MongoClientTest.kt +++ b/realm/realm-library/src/androidTestObjectServer/kotlin/io/realm/mongodb/MongoClientTest.kt @@ -267,7 +267,6 @@ class MongoClientTest { } @Test - @Ignore("FIXME: Fails on Github Actions CI - https://github.com/realm/realm-java/runs/2121717693") fun aggregate() { with(getCollectionInternal()) { // Aggregate on an empty collection returns false on hasNext and null on first @@ -1453,7 +1452,6 @@ class MongoClientTest { } @Test - @Ignore("FIXME: Fails on Github Actions CI - https://github.com/realm/realm-java/runs/2121717693") fun withDocument() { // aAd default codecs as they too are needed for proper collection initialization val expandedCodecRegistry = CodecRegistries diff --git a/tools/sync_test_server/baas_local/install_baas.sh b/tools/sync_test_server/baas_local/install_baas.sh index 55fa3f2d5a..fe1b6fff2e 100644 --- a/tools/sync_test_server/baas_local/install_baas.sh +++ b/tools/sync_test_server/baas_local/install_baas.sh @@ -114,7 +114,7 @@ echo "Assume Go is available" echo "Assume jq and yg is available" [[ -d baas_dep_binaries ]] || mkdir baas_dep_binaries -#export PATH=$WORK_PATH/baas_dep_binaries:$PATH +export PATH=$WORK_PATH/baas_dep_binaries:$PATH #if [[ ! -x baas_dep_binaries/yq || ! -x baas_dep_binaries/jq ]]; then # cd baas_dep_binaries # which yq || ($CURL -LsS $YQ_DOWNLOAD_URL > yq && chmod +x yq) From 52b33426e5e00f4ee1a8802b9790c71972928c59 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 17 Mar 2021 09:16:42 +0100 Subject: [PATCH 93/93] Disable parallel builds --- realm/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/realm/gradle.properties b/realm/gradle.properties index d9d4d75b67..29b7bf620b 100644 --- a/realm/gradle.properties +++ b/realm/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs=-Xms1024m -Xmx4096m org.gradle.caching=true kotlin.incremental=false -org.gradle.parallel=true +org.gradle.parallel=false android.useAndroidX=true android.enableJetifier=true