-
Notifications
You must be signed in to change notification settings - Fork 1.8k
154 lines (136 loc) · 5.7 KB
/
pr.yml
File metadata and controls
154 lines (136 loc) · 5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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/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 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