Skip to content

Commit

Permalink
ci(circle): add config
Browse files Browse the repository at this point in the history
  • Loading branch information
fathyb committed Aug 13, 2018
1 parent 36e6f8d commit 9bbe011
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 17 deletions.
131 changes: 131 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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
Empty file added circle
Empty file.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions packages/test-app/build_android.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions packages/test-app/build_ios.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 0 additions & 11 deletions packages/test-app/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down
7 changes: 2 additions & 5 deletions packages/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9bbe011

Please sign in to comment.