Commit bb595898 authored by Mark Harding's avatar Mark Harding
Browse files

(test): circle ci

parent 716df031
Loading
Loading
Loading
Loading

.circleci/config.yml

0 → 100644
+149 −0
Original line number Original line Diff line number Diff line
version: 2
jobs:
  node:
    working_directory: ~/mobile-native
    docker:
      - image: circleci/node:10
    steps:
      - checkout

      - restore_cache:
          key: yarn-v1-{{ checksum "yarn.lock" }}-{{ arch }}

      - restore_cache:
          key: node-v1-{{ checksum "package.json" }}-{{ arch }}

      - run: yarn install

      - save_cache:
          key: yarn-v1-{{ checksum "yarn.lock" }}-{{ arch }}
          paths:
            - ~/.cache/yarn

      - save_cache:
          key: node-v1-{{ checksum "package.json" }}-{{ arch }}
          paths:
            - node_modules

      - run:
          name: jest tests
          command: |
            mkdir -p test-results/jest
            yarn run test --maxWorkers=2
          environment:
            JEST_JUNIT_OUTPUT: test-results/jest/junit.xml

      - persist_to_workspace:
          root: ~/mobile-native
          paths:
            - node_modules

      - store_test_results:
          path: test-results

      - store_artifacts:
          path: test-results
  
  ios:
    macos:
      xcode: "10.1"
    working_directory: ~/mobile-native

    # use a --login shell so our "set Ruby version" command gets picked up for later steps
    shell: /bin/bash --login -o pipefail

    steps:
      - checkout

      - run:
          name: set Ruby version
          command:  echo "ruby-2.4" > ~/.ruby-version

      - restore_cache:
          key: yarn-v1-{{ checksum "yarn.lock" }}-{{ arch }}

      - restore_cache:
          key: node-v1-{{ checksum "package.json" }}-{{ arch }}

      # not using a workspace here as Node and Yarn versions
      # differ between our macOS executor image and the Docker containers above
      - run: yarn install

      - save_cache:
          key: yarn-v1-{{ checksum "yarn.lock" }}-{{ arch }}
          paths:
            - ~/.cache/yarn

      - save_cache:
          key: node-v1-{{ checksum "package.json" }}-{{ arch }}
          paths:
            - node_modules

      - restore_cache:
          key: bundle-v1-{{ checksum "ios/Gemfile.lock" }}-{{ arch }}

      - run:
          command: gem update --system && gem install bundler && bundle install
          working_directory: ios

      - save_cache:
          key: bundle-v1-{{ checksum "ios/Gemfile.lock" }}-{{ arch }}
          paths:
            - vendor/bundle

      ### TODO- get tests running with fastlane

      #- run:
      #    command: bundle exec fastlane test
      #    working_directory: ios

      #- run:
      #    name: set up test results
      #    working_directory: ios
      #    when: always
      #    command: |
      #      mkdir -p test-results/fastlane test-results/xcode
      #      mv fastlane/report.xml test-results/fastlane
      #      mv fastlane/test_output/report.junit test-results/xcode/junit.xml
      #- store_test_results:
      #    path: ios/test-results

      #- store_artifacts:
      #    path: ios/test-results

      - run: 
          name: Build release .ipa
          command: fastlane buildrelease
          working_directory: ios
          branches:
            only:
              - /stable-*/
              - /release-*/
              - test/circle-ci

      - run: 
          name: Upload to crashalytics 
          command: echo "TODO"
          working_directory: ios
          branches:
            only:
              - /release-*/

      - run:
          name: Upload to Testflight release
          command: fastlane testflight
          working_directory: ios
          branches:
            only:
              - /stable-*/
              - /release-*/
              - test/circle-ci

workflows:
  version: 2
  node-ios:
    jobs:
      - node
      - ios:
          requires:
            - node
+58 −47
Original line number Original line Diff line number Diff line
@@ -2,73 +2,84 @@
stages:
stages:
  - test
  - test
  - build
  - build
  - test_e2e
  - e2e
  - deploy


variables:
test:jest:
  GRADLE_USER_HOME: $CI_PROJECT_DIR/.gradle

test_spec:
 image: node:10.10.0
 image: node:10.10.0
 stage: test
 stage: test
 cache:
 cache:
   key: ${CI_COMMIT_REF_SLUG}
   paths:
   paths:
     - node_modules/
     - node_modules/
     - .jest/cache/
     - .jest/cache/
 script:
 script:
    - echo $CI_PROJECT_NAMESPACE
   - yarn install
   - yarn install
   - yarn test
   - yarn test
  tags:
    - docker


build:
build:android:
  image: reactnativecommunity/react-native-android
  image: circleci/android:api-28-node
  stage: build
  stage: build
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - .gradle/wrapper
      - .gradle/caches
      - node_modules/
  before_script:
  before_script:
    - echo 999999 > /proc/sys/fs/inotify/max_user_instances
    - sudo sysctl fs.inotify.max_user_watches=524288
    - echo 999999 > /proc/sys/fs/inotify/max_user_watches
    - sudo sysctl -p  
    - echo 999999 > /proc/sys/fs/inotify/max_queued_events
    - echo $ANDROID_KEYSTORE | base64 --decode > android/app/minds.keystore
    - echo "MYAPP_RELEASE_STORE_PASSWORD=${KEYSTORE_PASSWORD}" >> ./android/gradle.properties
    - echo "MYAPP_RELEASE_KEY_PASSWORD=${KEYSTORE_PASSWORD}" >> ./android/gradle.properties

  script:
  script:
    - yarn install
    - yarn install
    - cd android && chmod +x gradlew
    - cd android
    - ./gradlew assembleRelease
    - bundle install
    - cp app/build/outputs/apk/release/app-release.apk ../Minds.apk
    - fastlane assemble_build
    - cp app/build/outputs/apk/release/app-release.apk ../Minds-$CI_BUILD_REF_SLUG.apk
  artifacts:
  artifacts:
    name: "Minds APK"
    name: "Minds APK"
    paths:
    paths:
      - Minds.apk
      - Minds-$CI_BUILD_REF_SLUG.apk
    expire_in: 7 days
    expire_in: 7 days
    when: on_success
    when: on_success
  only:
    variables:
      - $CI_PROJECT_NAMESPACE == "minds"



test_e2e:
e2e:browserstacks:
  image: node:10.10.0
  image: node:10.10.0
  stage: test_e2e
  stage: e2e
  cache:
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
    paths:
      - node_modules/
      - node_modules/
      - .jest/cache/
  script:
  script:
    - yarn install
    - yarn install
    - export bsAPP=`curl -u "${bsUSER}:${bsKEY}" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@./Minds.apk"| grep -o 'bs\:\/\/.*"' | sed 's/.$//'`
    - export bsAPP=`curl -u "${bsUSER}:${bsKEY}" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@./Minds-$CI_BUILD_REF_SLUG.apk"| grep -o 'bs\:\/\/.*"' | sed 's/.$//'`
    - yarn e2e
    - yarn e2e
  tags:
  tags:
    - docker
    - docker
  dependencies:
  dependencies:
    - build
   - build:android
  only:
    refs:
      - /^stable-*/
      - /^release-*/
      - /^feat-*/
      - /^test-*/
  allow_failure: true

deploy:s3:
  image: minds/ci:latest
  stage: deploy
  script:
    - echo "Upload Minds-$CI_BUILD_REF_SLUG.apk"
    - aws s3 cp Minds-$CI_BUILD_REF_SLUG.apk s3://minds-repo/mobile/Minds-$CI_BUILD_REF_SLUG.apk
  dependencies:
   - build:android
  only:
    refs:
      - /^release-*/
      - /^test-*/

deploy:google_play:
  image: minds/ci:latest
  stage: deploy
  script:
    - echo "Upload Minds-$CI_BUILD_REF_SLUG.apk"
  dependencies:
    - build:android
  only:
  only:
    variables:
    refs:
      - $CI_PROJECT_NAMESPACE == "minds"
      - /^stable-*/
      - /^test-*/

App-test.js

0 → 100644
+74 −0
Original line number Original line Diff line number Diff line
//import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
import './global';
import './shim'
//import crypto from "crypto"; // DO NOT REMOVE!

import React, {
  Component
} from 'react';

import {
  createStackNavigator,
  NavigationActions
} from 'react-navigation';

import {
  BackHandler,
  Platform,
  AppState,
  Linking,
  Text,
  Alert,
  View,
} from 'react-native';

import NavigationStack from './src/navigation/NavigationStack';
import NavigationService from './src/navigation/NavigationService';

const Stack = createStackNavigator({});

/**
 * App
 */
export default class App extends Component {

  constructor(props) {
    super(props);
    this.state = {
      appState: AppState.currentState
    };
  }

  /**
   * Handle app state changes
   */
  handleAppStateChange = (nextState) => {
    // if the app turns active we check for shared
    if (this.state.appState.match(/inactive|background/) && nextState === 'active') {
      receiveShare.handle();
    }
    this.setState({appState: nextState})
  }

  /**
   * On component will mount
   */
  componentWillMount() {
    if (!Text.defaultProps) Text.defaultProps = {};
    Text.defaultProps.style = {
      fontFamily: 'Roboto',
      color: '#444',
    };
  }

  /**
   * Render
   */
  render() {
    const app = (
      <View></View>
    );

    return [ app ];
  }
}
+24 −1
Original line number Original line Diff line number Diff line
# Minds Mobile Apps
# Minds Mobile Apps


## Branch Structure

| Branch    |                                                                                                                                    |
|-----------|------------------------------------------------------------------------------------------------------------------------------------|
| master    | Approved code ready to merged into the next stable release. All tests should pass and be in a 'ready' state                        |
| stable/*  | Stable builds, inherited from `release/*` branches. Fastlane automatically deploys these builds.                                   |
| release/* | WIP builds. Run `fastlane run increment_version_number` upon creating the branch.                                                  |
| feat/*    | New branches should be made for each Gitlab issue. Merge requests should be opened pointing towards the respective release branch. |

## Increasing the version number

### Patch

`fastlane run increment_version_number bump_type:patch`

### Minor

`fastlane run increment_version_number bump_type:minor`

### Major

`fastlane run increment_version_number bump_type:major`

## Platforms
## Platforms


- iOS
- iOS

android/.gitignore

0 → 100644
+14 −0
Original line number Original line Diff line number Diff line
# fastlane specific
fastlane/report.xml

# deliver temporary files
fastlane/Preview.html

# snapshot generated screenshots
fastlane/screenshots

# scan temporary files
fastlane/test_output

# Fastlane builds
builds/*
Loading