diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..6e3cc6599 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,131 @@ +defaults: + requiresInstall: &requiresInstall + requires: + - install + requiresTestApp: &requiresTestApp + requires: + - build-test-app + getDeps: &getDeps + restore_cache: + key: yarn-{{ checksum "yarn.lock" }} + nodeJob: &nodeJob + docker: + - image: circleci/node:8 + +version: 2 +jobs: + install: + <<: *nodeJob + steps: + - checkout + - *getDeps + - run: yarn install --frozen-lockfile + - save_cache: + key: yarn-{{ checksum "yarn.lock" }} + paths: + - node_modules + - packages/core/node_modules + - packages/integrations/node_modules + - packages/test-app/node_modules + + lint: + <<: *nodeJob + steps: + - checkout + - *getDeps + - run: yarn commitlint-circle + + test-core: + <<: *nodeJob + steps: + - checkout + - *getDeps + - run: yarn core test + - run: yarn codecov + + build-core: + <<: *nodeJob + steps: + - checkout + - *getDeps + - run: yarn core build + - persist_to_workspace: + root: . + paths: + - packages/core/build/**/* + + build-integrations: + <<: *nodeJob + steps: + - checkout + - *getDeps + - run: yarn integrations build + - persist_to_workspace: + root: . + paths: + - packages/integrations/build/**/* + + build-test-app: + <<: *nodeJob + steps: + - checkout + - *getDeps + - attach_workspace: + at: . + + - run: yarn test-app build:project + - persist_to_workspace: + root: . + paths: + - packages/test-app/project + build-test-app-android: + docker: + - image: circleci/android:api-26-node8-alpha + steps: + - checkout + - attach_workspace: + at: . + - run: yarn test-app build:android + + build-test-app-ios: + macos: + xcode: "9.4.0" + environment: + # Needed for fastlane, see https://docs.fastlane.tools/getting-started/ios/setup/#set-up-environment-variables + LC_ALL: en_US.UTF-8 + LANG: en_US.UTF-8 + steps: + - checkout + - attach_workspace: + at: . + + - restore_cache: + key: cocoapods-specs + - restore_cache: + key: gem-{{ checksum "packages/test-app/Gemfile.lock" }} + - run: yarn test-app build:ios + - save_cache: + key: gem-{{ checksum "packages/test-app/Gemfile.lock" }} + paths: + - packages/test-app/vendor/bundle + - save_cache: + key: cocoapods-specs + paths: + - ~/.cocoapods + +workflows: + version: 2 + + build_and_test: + jobs: + - install + - lint: *requiresInstall + - test-core: *requiresInstall + - build-core: *requiresInstall + - build-integrations: *requiresInstall + - build-test-app-android: *requiresTestApp + - build-test-app-ios: *requiresTestApp + - build-test-app: + requires: + - build-core + - build-integrations diff --git a/circle b/circle new file mode 100644 index 000000000..e69de29bb diff --git a/packages/core/package.json b/packages/core/package.json index 7f582a947..1fb66d96d 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -14,10 +14,10 @@ "RNAnalytics.podspec" ], "scripts": { + "build:clean": "rimraf build", "build:ts": "run-p build:ts:*", "build:ts:cjs": "tsc --target es5 --outDir build/cjs --module commonjs", "build:ts:esm": "tsc --target es5 --outDir build/esm --module esnext", - "build:clean": "rimraf build", "build": "run-s build:{clean,ts}", "docs:clean": "rimraf docs", "docs:gen": "typedoc --out docs --ignoreCompilerErrors --excludePrivate --excludeExternals --theme markdown --mode file --entrypoint Analytics --gitRevision master", diff --git a/packages/test-app/build_android.sh b/packages/test-app/build_android.sh new file mode 100755 index 000000000..4d3f439ff --- /dev/null +++ b/packages/test-app/build_android.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +cd project +rm -rf node_modules +yarn + +cd android + +# Upgrade the build tools to 3.1.4 and Gradle to 4.4 +./gradlew --no-daemon --max-workers=1 -Dorg.gradle.jvmargs="-Xmx1024m -XX:+HeapDumpOnOutOfMemoryError" wrapper --gradle-version=4.4 --distribution-type=bin +sed -i.bak s/tools.build:gradle:2.3.3/tools.build:gradle:3.1.4/g build.gradle + +yarn react-native link +./gradlew --no-daemon --max-workers=1 -Dorg.gradle.jvmargs="-Xmx1024m -XX:+HeapDumpOnOutOfMemoryError" build diff --git a/packages/test-app/build_ios.sh b/packages/test-app/build_ios.sh new file mode 100755 index 000000000..eb6bb89d9 --- /dev/null +++ b/packages/test-app/build_ios.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +bundle install --path vendor/bundle + +cd project/ios +cp ../../Podfile . + +yarn react-native link +pod install +bundle exec fastlane scan --scheme project --build_for_testing diff --git a/packages/test-app/generate.sh b/packages/test-app/generate.sh index dd1b86263..1a067a554 100755 --- a/packages/test-app/generate.sh +++ b/packages/test-app/generate.sh @@ -10,16 +10,8 @@ rm -rf project yarn react-native init project cp App.js project/ -cp Podfile project/ios cd project -# Upgrade the build tools to 3.1.4 and Gradle to 4.4 -( - cd android && - ./gradlew wrapper --gradle-version=4.4 --distribution-type=bin && - sed -i.bak s/tools.build:gradle:2.3.3/tools.build:gradle:3.1.4/g build.gradle -) - build_dir=$pwd/../integrations/build for integration in `cd $build_dir && echo @segment/*`; do @@ -28,9 +20,6 @@ for integration in `cd $build_dir && echo @segment/*`; do done yarn add $install_command -yarn react-native link - -(cd ios && pod install) write_key="qGHfVyLQjydiD6A3dipTZqbHvhlYJKFC" diff --git a/packages/test-app/package.json b/packages/test-app/package.json index a22a5602c..32c04d9a1 100644 --- a/packages/test-app/package.json +++ b/packages/test-app/package.json @@ -5,11 +5,8 @@ "scripts": { "build": "run-s build:{project,ios,android}", "build:project": "./generate.sh", - "build:android": "cd project/android && ./gradlew build", - "build:ios": "run-s fastlane:{install,code-sign,build}", - "fastlane:install": "bundle install --path vendor/bundle", - "fastlane:code-sign": "cd project/ios && bundle exec fastlane run automatic_code_signing use_automatic_signing:true", - "fastlane:build": "cd project/ios && bundle exec fastlane gym --scheme project" + "build:android": "./build_android.sh", + "build:ios": "./build_ios.sh" }, "devDependencies": { "react-native-cli": "^2.0.1"