diff --git a/.github/workflows/pr-integration-tests.yml b/.github/workflows/pr-integration-tests.yml new file mode 100644 index 00000000000..85bbe081f7a --- /dev/null +++ b/.github/workflows/pr-integration-tests.yml @@ -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 diff --git a/.github/workflows/pr-realm-web.yml b/.github/workflows/pr-realm-web.yml index 71d842b79b5..8c6f49fc31c 100644 --- a/.github/workflows/pr-realm-web.yml +++ b/.github/workflows/pr-realm-web.yml @@ -17,6 +17,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + submodules: 'recursive' - uses: actions/setup-node@v1 with: node-version: 12 @@ -24,7 +26,7 @@ jobs: # 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 diff --git a/Jenkinsfile b/Jenkinsfile index 3869d139ba7..6b1f0c4fdd0 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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( @@ -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}"