Skip to content

Commit

Permalink
Moved integration tests to GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Apr 21, 2021
1 parent 5431db7 commit 2f785d6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 132 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/pr-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Integration Testing Realm JS (Pull Request)

on:
pull_request:
paths:
# Source code
- '*'
- 'lib/**'
- 'src/**'
- 'types/**'
- 'react-native/**'
- 'vendor/**'
# Integration tests
- 'integration-tests/**'
# No need to run when updating documentation
- '!**.md'

jobs:
node:
name: Integration Tests (Node.js on Linux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
# Install the root package (builds the native module)
- run: npm ci
# Bootstrap lerna sub-packages (builds the packages)
- run: npx lerna bootstrap --scope realm-node-tests --include-dependencies
# Lint, build and test the package
- run: npm test --prefix integration-tests/environments/node
env:
MOCHA_REMOTE_CONTEXT: missingServer
4 changes: 3 additions & 1 deletion .github/workflows/pr-realm-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
# Install the root package (--ignore-scripts to avoid downloading or building the native module)
- run: npm ci --ignore-scripts
# Bootstrap lerna sub-packages
- run: npx lerna bootstrap --scope realm-web realm-web-integration-tests --include-dependencies
- run: npx lerna bootstrap --scope realm-web-integration-tests --include-dependencies
# Lint, build and test the package
- run: npm run lint
working-directory: packages/realm-web
Expand Down
131 changes: 0 additions & 131 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,6 @@ stage('test') {
parallel parallelExecutors
}

stage('integration tests') {
parallel(
'Node.js on Mac': buildMacOS { nodeIntegrationTests(nodeTestVersion, it) },
'Node.js on Linux': buildLinux { nodeIntegrationTests(nodeTestVersion, it) },

'Electron on Mac': buildMacOS { electronIntegrationTests(electronTestVersion, it) },
'Electron on Linux': buildLinux { electronIntegrationTests(electronTestVersion, it) },

'React Native on Android': inAndroidContainer { reactNativeIntegrationTests('android') },
'React Native on iOS': buildMacOS { reactNativeIntegrationTests('ios') },
)
}

def exclusivelyChanged(regexp) {
// Checks if this is a change/pull request and if the files changed exclusively match the provided regular expression
return env.CHANGE_TARGET && sh(
Expand All @@ -170,124 +157,6 @@ def exclusivelyChanged(regexp) {
}

// == Methods
def nodeIntegrationTests(nodeVersion, platform) {
unstash 'source'
unstash "prebuild-${platform}"
sh "./scripts/nvm-wrapper.sh ${nodeVersion} ./scripts/pack-with-pre-gyp.sh"
sh "./scripts/nvm-wrapper.sh ${nodeVersion} npx lerna bootstrap --scope realm-node-tests --include-dependencies"
dir('integration-tests/environments/node') {
try {
withEnv([
"MOCHA_REMOTE_REPORTER=mocha-junit-reporter",
"MOCHA_REMOTE_CONTEXT=localOnly"
]) {
sh "../../../scripts/nvm-wrapper.sh ${nodeVersion} npm test"
}
} finally {
junit(
allowEmptyResults: true,
testResults: 'test-results.xml',
)
}
}
}

def electronIntegrationTests(electronVersion, platform) {
// Validate platform argument
assert (platform in platforms)

def nodeVersion = nodeTestVersion
unstash 'source'
unstash "prebuild-${platform}"
sh "./scripts/nvm-wrapper.sh ${nodeVersion} ./scripts/pack-with-pre-gyp.sh"
sh "./scripts/nvm-wrapper.sh ${nodeVersion} npx lerna bootstrap --scope realm-electron-tests --include-dependencies"

// On linux we need to use xvfb to let up open GUI windows on the headless machine
def commandPrefix = platform == 'linux-x64' ? 'xvfb-run ' : ''

dir('integration-tests/environments/electron') {
try {
withEnv([
"MOCHA_REMOTE_REPORTER=mocha-junit-reporter",
"MOCHA_REMOTE_REPORTER_OPTIONS=mochaFile=main-test-results.xml",
"MOCHA_REMOTE_CONTEXT=localOnly"
]) {
sh "../../../scripts/nvm-wrapper.sh ${nodeVersion} ${commandPrefix} npm run test/main"
}

withEnv([
"MOCHA_REMOTE_REPORTER=mocha-junit-reporter",
"MOCHA_REMOTE_REPORTER_OPTIONS=mochaFile=renderer-test-results.xml",
"MOCHA_REMOTE_CONTEXT=localOnly"
]) {
sh "../../../scripts/nvm-wrapper.sh ${nodeVersion} ${commandPrefix} npm run test/renderer"
}
} finally {
junit(
allowEmptyResults: true,
testResults: '*-test-results.xml',
)
}
}
}

def reactNativeIntegrationTests(targetPlatform) {
def nodeVersion = nodeTestVersion
unstash 'source'

def nvm
if (targetPlatform == "android") {
nvm = ""
} else {
nvm = "${env.WORKSPACE}/scripts/nvm-wrapper.sh ${nodeVersion}"
}

sh "${nvm} npx lerna bootstrap --scope realm-react-native-tests --include-dependencies"

if (targetPlatform == "android") {
dir('react-native/android/src/main') {
unstash 'android-jnilibs'
}
} else {
dir('react-native/ios') {
unstash 'realm-js-ios.xcframework'
}
}

dir('integration-tests/environments/react-native') {
if (targetPlatform == "android") {
runEmulator();
// In case the tests fail, it's nice to have an idea on the devices attached to the machine
// Uninstall any other installations of this package before trying to install it again
sh 'adb uninstall io.realm.tests.reactnative || true' // '|| true' because the app might already not be installed
} else if (targetPlatform == "ios") {
dir('ios') {
sh 'pod install --verbose'
}
}

timeout(30) { // minutes
try {
withEnv([
"MOCHA_REMOTE_REPORTER=mocha-junit-reporter",
"MOCHA_REMOTE_CONTEXT=localOnly"
]) {
sh "${nvm} npm run test/${targetPlatform}"
}
} finally {
junit(
allowEmptyResults: true,
testResults: 'test-results.xml',
)
if (targetPlatform == "android") {
// Read out the logs in case we want some more information to debug from
sh 'adb logcat -d -s ReactNativeJS:*'
}
}
}
}
}

def myNode(nodeSpec, block) {
node(nodeSpec) {
echo "Running job on ${env.NODE_NAME}"
Expand Down

0 comments on commit 2f785d6

Please sign in to comment.