LoginSignup
3
0

More than 1 year has passed since last update.

Autify for Web の GitHub Actions を作って Marketplace にリリースしました

Posted at

Autify アドベントカレンダー2021 の25日目の記事です。

今回は Autify for Web 上のテストプランを簡単に実行することができる GitHub Actions を作り Marketplace に公開したので利用方法、利用例についてご紹介します。

使用方法

前提条件

  1. Autify for Web アカウント
  2. パーソナルアクセストークン (発行方法)
  3. テストプラン ID

Autify for Web Run Test Plan を使う

まず Autify for Web のテストプランを実行したい GitHub Actions のワークフローを持つレポジトリを選択してください。レポジトリの Settings > SecretsAUTIFY_FOR_WEB_API_TOKEN という名前でパーソナルアクセストークンを保存してください。

そしたらテストプランを実行したいワークフローに以下のステップを追加してください:

- name: Funtional test
  id: functional-test
  uses: autifyhq/web-run-test-plan-action@v1.0.0
  with:
    autify_for_web_api_token: ${{ secrets.AUTIFY_FOR_WEB_API_TOKEN }}
    test_plan_id: 123 # 実行したいテストプランの ID を指定

これでこのステップが実行される際に、Autify for Web 上でテストプラン(ID : 123)が実行されます。

利用例

現在 Autify では CircleCI を利用しているのでそこで行っていることを GitHub Actions 版にして紹介します。Cicle CIでの利用方法を説明した別記事(Advent Calendar駆動開発でAutifyのCircleCI Orbを作りました)があるのでまずそれを引用します。

  1. 開発者が、フィーチャーブランチあるいはdevelopブランチをビルドしステージングにデプロイするジョブを開始(CircleCIのtype: approvalジョブを使い、手動で承認した場合にのみこの処理を行う一連のジョブが走る仕組み)
  2. ビルド
  3. デプロイ
  4. Autify for WebのAPIをcurlで叩きリグレッションテストのテストプランを起動(この部分をOrbに置き換え)
  5. その際のレスポンスにテスト結果のURLが含まれるので、これをパースした上でSlackに投稿
jobs:
  build-and-test:
    runs-on: ubuntu-latest
      - uses: actions/checkout@v2

      # Autify for Webでテストプランを実行
      # ここで steps.functional-test.outputs.response に API レスポンスが保存される
      - name: Run funtional test
        id: functional-test
        uses: autifyhq/web-run-test-plan-action@v1.0.0
        with:
          autify_for_web_api_token: ${{ secrets.AUTIFY_FOR_WEB_API_TOKEN }}
          test_plan_id: 123

      # 前のステップで保存されたファイルからテスト結果のIDを取得し、URLを組み立て
      - name: Get the test plan result URL
        id: get-test-plan-result-url
        run: >
          AUTIFY_TEST_PLAN_BASE_URL=https://app.autify.com/projects/xyz/results/

          test_plan_result_id=$(echo ${{ steps.functional-test.outputs.response }} | jq -r .data.id)
          test_plan_result_url="${AUTIFY_TEST_PLAN_BASE_URL}${test_plan_result_id}"
          echo '::set-output name=value::${test_plan_result_url}'

      - name: Post to a Slack channel
        id: slack
        uses: slackapi/slack-github-action@v1.16.0
        with:
          channel-id: 'CHANNEL_ID'  # Slack channel id or user id to post message. 
          slack-message: "Regression tests: ${{ steps.get-test-plan-result-url.outputs.value }}" 
        env:
          SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

最後に

今回の Action でより簡単にCI/CDのパイプラインに Autify を導入できそれぞれのポイントで自動でテストを実行し、自信をもってアプリケーションを開発・運用することをお手伝いができればと思います。引き続きこの Action の改善と Autify for Mobile の方でも Action を公開します。

リポジトリは公開していますのでいつでも Pull Request お待ちしております。
- https://github.com/autifyhq/web-run-test-plan-action

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0