CircleCI 連携
  • 22 Sep 2022
  • 1 分で読めます
  • 投稿者
  • ダーク
    ライト

CircleCI 連携

  • ダーク
    ライト

Article Summary

Autify ではお手持ちのCircleCI workflow から簡単にビルドをアップロードしたりテストプランを実行できる公式のCircleCI Orb を提供しています。

はじめてみよう

このドキュメントでは、皆さんのGit リポジトリでどのようにAutify のCircleCI 連携を利用するかを順に説明していきます。

前提条件

まず、すでにCircleCI workflow を使ってアプリケーションのビルドを行なっているものとします。そのビルドjob のすぐ後にAutify のテストを実行するjob を追加することで、新しくビルドされたアプリケーションがエンドツーエンドのユーザ体験を損ねていないことを確認できるようにします。

次に、Autify for Mobile でテストプランを作成する必要があります。テストプランまたはシナリオのURL (例: https://mobile-app.autify.com/projects/AAA/scenarios/BBB) をメモしておいてください、後ほど利用します。

さらに、パーソナルアクセストークンを生成する必要があります。後ほどEnvironment Variables (環境変数) に保存するために、生成されたトークンはどこかにメモしておいて下さい。

注: パーソナルアクセストークンは1人のユーザに紐づいてしまうので、CI/CD 連携のために組織にマシンユーザを作って、そのパーソナルアクセストークンを使うことをお勧めします。

パーソナルアクセストークンをEnvironment Variables に保存

上で生成したパーソナルアクセストークンをCircleCI のドキュメントに従って、Environment Variables (環境変数) に保存します。名前は任意ですが、AUTIFY_MOBILE_ACCESS_TOKEN と命名した場合はそれがデフォルトの名前なので後ほどこの名前を指定する必要がありません。ここではそうしたと仮定しておきます。

Autify for Mobile にビルドをアップロードしたりテストを実行するCircleCI job を追加

それでは、お手持ちのCircleCI workflow に新しいjob を追加しましょう。以下の例を参考にしてください。autify-test-url の値は、上でメモしたURL になります。


新しいビルドファイルをアップロードしてテストを開始する (テストの完了は待たない):

orbs:
  android: circleci/android@2.0
  autify-mobile: autify/autify-mobile@3

jobs:
  # Example build jobs. Needs to persist the build file to workspace.
  build-android:
    executor:
      name: android/android-machine
    steps:
      - ...
      - run: ./gradlew assembleRelease
      - persist_to_workspace:
          paths:
            - android-release.apk
          root: app/build/outputs/apk/release
  build-ios:
    macos:
      xcode: 13.4.1
    steps:
      - ...
      - run: xcodebuild -configuration Debug -target hello-world -arch x86_64 -sdk iphonesimulator
      - persist_to_workspace:
          paths:
            - hello-world.app
          root: build/Debug-iphonesimulator

workflows:
  test-run-andriod:
    jobs:
      - build-android
      - autify-mobile/test-run:
          requires:
            - build-android
          autify-test-url: 'https://mobile-app.autify.com/projects/AAA/test_plans/BBB'
          build-path: android-release.apk

  test-run-ios:
    jobs:
      - build-ios
      - autify-mobile/test-run:
          requires:
            - build-ios
          autify-test-url: 'https://mobile-app.autify.com/projects/AAA/test_plans/BBB'
          build-path: hello-world.app

もしテストが完了するか、タイムアウトするまで待つ場合:

    jobs:
      - autify-mobile/test-run:
          ...
          wait: true
          timeout: 300

警告: この設定はテスト完了を待っている間もCircleCI build の時間を消費します。タイムアウトを延長するときは注意してください。

新しいビルドファイルをアップロードするだけ (workspace-id は上でメモしたURL の/projects/ のすぐ後ろのid):

    # Android
    jobs:
      - build-android
      - autify-mobile/build-upload:
          requires:
            - build-android
          build-path: android-release.apk
          workspace-id: AAA
          
    ## iOS
    jobs:
      - build-ios
      - autify-mobile/build-upload:
          requires:
            - build-ios
          build-path: hello-world.app
         workspace-id: AAA

まとめ

Autify のCircleCI Orb を使うことで、ビルド後にテストプランの実行を自動化できるので、無駄な時間を使うことなくリグレッションをすぐに検知して適切な行動を取ることができるようになります。


この記事は役に立ちましたか?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.