Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Github Actions #7342

Draft
wants to merge 94 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
0e5c4ff
Add test workflow for PR's. Disable JenkinsFile.
cmelchior Mar 10, 2021
8828168
Attempt to build library
cmelchior Mar 10, 2021
92128dd
Add key to caching
cmelchior Mar 10, 2021
21ce19a
Syntax error
cmelchior Mar 10, 2021
17a9358
Attempt to use specific version of CMake
cmelchior Mar 10, 2021
1a0b99c
Install Ninja
cmelchior Mar 10, 2021
73f5134
Add ccache
cmelchior Mar 10, 2021
925f161
Run PR build
cmelchior Mar 10, 2021
5a76b1a
Attempt to publish test results
cmelchior Mar 10, 2021
7c07ccd
Handle test result uploads
cmelchior Mar 10, 2021
fdc4e26
Publish test results must wait for build
cmelchior Mar 10, 2021
da35de6
Use proper paths for test result artifacts
cmelchior Mar 10, 2021
e12c967
Add emulator support
cmelchior Mar 10, 2021
d72aa4b
Use Emulator 29 instead of 30
cmelchior Mar 10, 2021
7d283a9
Use proper artifact file path
cmelchior Mar 10, 2021
c4c487b
Disable Cmake check for emulator
cmelchior Mar 10, 2021
d0234e8
Run tests in a single command
cmelchior Mar 10, 2021
f132830
Use shellscript to start Docker image for testing
cmelchior Mar 10, 2021
160c7ae
Fun with Docker
cmelchior Mar 10, 2021
01dc6f2
Run as a single line
cmelchior Mar 10, 2021
2f13ea5
Disable using Docker image
cmelchior Mar 10, 2021
4bad0d1
Add scripts for starting local BAAS
cmelchior Mar 11, 2021
bdd18ad
Merge branch 'master' into cm/github-actions
cmelchior Mar 11, 2021
89cbfd0
Add support for build BAAS locally
cmelchior Mar 11, 2021
5f005fd
Bad copy/paste
cmelchior Mar 11, 2021
45a972d
Install JQ
cmelchior Mar 11, 2021
bde4f8c
Don't use sh
cmelchior Mar 11, 2021
8c87c1c
Add SSH credentials
cmelchior Mar 11, 2021
d4040a6
Install Realm CLI
cmelchior Mar 11, 2021
6a7d795
Assume node is available
cmelchior Mar 11, 2021
a9e27a2
Add yq
cmelchior Mar 11, 2021
0b937c9
Disable downloading Go
cmelchior Mar 11, 2021
0e6e208
Assume yg/jq is available
cmelchior Mar 11, 2021
4bfd4d1
Create dependencies folder
cmelchior Mar 12, 2021
3541ac5
Test for yq
cmelchior Mar 12, 2021
9a08de1
Other test for yq
cmelchior Mar 12, 2021
5e314da
Specific step for python packages
cmelchior Mar 12, 2021
a57d60b
Syntax error
cmelchior Mar 12, 2021
382067e
More syntax
cmelchior Mar 12, 2021
8f64e4d
Attempt to hack path
cmelchior Mar 12, 2021
c330cde
Add local path
cmelchior Mar 12, 2021
1694b3a
More path hacks
cmelchior Mar 12, 2021
607d594
Debug python
cmelchior Mar 12, 2021
3926833
PATH check
cmelchior Mar 12, 2021
350a11b
Manually install yq
cmelchior Mar 12, 2021
13f1a5b
Start tests from script
cmelchior Mar 12, 2021
d67a951
Minor change
cmelchior Mar 12, 2021
6eb9c66
Proper file name
cmelchior Mar 12, 2021
32ce4b2
Fix path
cmelchior Mar 12, 2021
9cf73f7
Dont use sh to start script
cmelchior Mar 12, 2021
d5684e2
Use bash to start script
cmelchior Mar 12, 2021
53831ae
Use bash everywhere
cmelchior Mar 12, 2021
a8a3b49
Install yq from brew instead of pip
cmelchior Mar 12, 2021
4640d29
yq debug
cmelchior Mar 12, 2021
896edc6
Update yq syntax
cmelchior Mar 12, 2021
abc22d6
Fix command server startup
cmelchior Mar 12, 2021
4b75bca
Run tests in proper order
cmelchior Mar 12, 2021
f793e96
Don't wait when killing servers
cmelchior Mar 13, 2021
f257781
Force kill test servers
cmelchior Mar 13, 2021
02e7afe
Syntax error
cmelchior Mar 13, 2021
a65d8f8
More syntax
cmelchior Mar 13, 2021
4ced0fd
Test emulator
cmelchior Mar 13, 2021
6ebe987
Attempt to run ci script directly
cmelchior Mar 13, 2021
0305723
Attempt to close integration tests
cmelchior Mar 14, 2021
4d3a2c6
Assemble all flavours
cmelchior Mar 14, 2021
1a7f35b
More debugging attempts
cmelchior Mar 14, 2021
31a1d4c
Also kill mongodb service
cmelchior Mar 14, 2021
86e1815
Cleanup. Re-enable integration tests
cmelchior Mar 14, 2021
e597d84
Exit code from intetegration tests are the only one that matters
cmelchior Mar 15, 2021
d73a9b7
Composite builds. Add preliminary boilerplate for snapshot/full releases
cmelchior Mar 15, 2021
cb86f17
Syntax fixes
cmelchior Mar 15, 2021
fd9566e
Correct location for sharing actions
cmelchior Mar 15, 2021
8dc564b
Checkout action before usage
cmelchior Mar 15, 2021
e07592b
Fix shell script syntax
cmelchior Mar 15, 2021
b6beab4
Attempt to fix script
cmelchior Mar 15, 2021
eccf10f
Disable env for debugging
cmelchior Mar 15, 2021
dbd2c2d
Checkout code in workflow
cmelchior Mar 15, 2021
aba113c
Attempt to disable secrets for debugging
cmelchior Mar 15, 2021
fd92765
Remove duplicate steps section
cmelchior Mar 15, 2021
0dfadc6
Back to having a single action
cmelchior Mar 15, 2021
180c34f
Use commit sha for the test server
cmelchior Mar 15, 2021
5547f03
Better gradle caching
cmelchior Mar 15, 2021
ea0e1de
Fix indentation
cmelchior Mar 15, 2021
09e1e04
Archive logcat and mongodb logs
cmelchior Mar 15, 2021
457fa5b
Use latest version
cmelchior Mar 15, 2021
dcbf3a7
Disable release plugin
cmelchior Mar 15, 2021
b53d93a
Disable release plugin
cmelchior Mar 15, 2021
b2f1787
Re-enable parallel builds
cmelchior Mar 15, 2021
13f52ae
Fix bugs when archiving files
cmelchior Mar 16, 2021
93c1557
Correctly archive service logs
cmelchior Mar 16, 2021
92c1043
Move where adb root is called
cmelchior Mar 16, 2021
343371b
Disable breaking tests
cmelchior Mar 16, 2021
f3e5008
Re-enable breaking tests
cmelchior Mar 16, 2021
52b3342
Disable parallel builds
cmelchior Mar 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions .github/actions/build-library/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# 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'

runs:
using: "composite"
steps:
- name: Setup conditional environment variables
shell: |
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

# 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/[email protected]
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/[email protected]
with:
cmake-version: '3.18.4'

- name: Cache Gradle
uses: actions/[email protected]
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'

#
2 changes: 1 addition & 1 deletion .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Validate Gradle Wrapper"
on: [push, pull_request]
on: [pull_request]

jobs:
validation:
Expand Down
154 changes: 154 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Define how pull requests are built and tested.
name: Pull Requests
on:
pull_request:
paths-ignore:
- '*.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

# TODO: From DockerFile, not sure if needed
CCACHE_CPP2: yes
# CMAKE_VERSION: 3.18.4
# CCACHE_VERSION: 3.7.7

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/[email protected]
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/[email protected]
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: 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
if-no-files-found: warn
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: Archive Integration Test Results and Logs
if: always()
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
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
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
# 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
16 changes: 16 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Workflow for building and publishing releases to Maven Central.
name: Publish release
on:
push:
tags:
- 'v*'

jobs:
run-release-build:
runs-on: macos-latest
steps:
- name: Build and Test Library
run: echo "Work work work..."



17 changes: 17 additions & 0 deletions .github/workflows/snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Workflow for building and publishing SNAPSHOT releases to Maven Central.
name: Create SNAPSHOT release
on:
push:
branches:
- master
- releases
env:
jobs:
run-snapshot-build:
runs-on: macos-latest
steps:
- name: Build and Test Library
run: echo "Work work work..."



4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down
6 changes: 3 additions & 3 deletions dependencies.list
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] temp [email protected] fs-extra moment [email protected]

# Run integration test server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
14 changes: 14 additions & 0 deletions tools/sync_test_server/baas_local/abspath.sh
Original file line number Diff line number Diff line change
@@ -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
Loading