自動テスト結果を QualityForward の自動テスト安定性レポートに連携します。
必須項目 Quality Forward のプロジェクト API キーを設定してください。
必ず、GitHub Actions でのシークレットの使用を利用して、設定してください。
API キーの設定方法は QualityForward API のAPI キーの発行手順をご確認ください。
必須項目 自動テストの実行結果を格納したファイルパスを設定してください。ワイルドカードで指定可能です。
必須項目 使用したテストフレームワークを設定してください。
設定できるテストフレームワーク
| テストフレームワーク | ファイル拡張子 |
|---|---|
| junit | xml |
| pytest | xml |
| nodejs-playwright | xml |
| pytest-playwright | xml |
| magicpod | json |
| mabl-deploy-event | json |
※ mabl-deploy-event:デプロイ結果のサマリー取得のデータ(詳細は mabl ヘルプページ - デプロイイベントを参照のこと)
※ 上記以外のテストフレームワークでも、junit-xml 形式のファイルで出力できるものはjunitを設定してください
連携する自動テストスイート名を設定してください。
設定しない場合の自動テストスイート名
| テストフレームワーク | 自動テストスイート名 |
|---|---|
| junit,nodejs-playwright | testsuite 要素の name 属性 |
| pytest,pytest-playwright | testcase 要素の classname 属性 最後のドット以降を取得 (例)test.testSuite の場合、”testSuite”を取得 |
| magicpod | テスト一括実行設定名 |
| mabl-deploy-event | テストプラン id |
連携する自動テストサイクル名を設定してください。
設定しない場合の自動テストサイクル名
| テストフレームワーク | 自動テストサイクル名 | 例 |
|---|---|---|
| junit,mabl-deploy-event | アクション実行日時 | 9/26/2024, 4:10:10 AM |
| pytest,nodejs-playwright,pytest-playwright | testsuite 要素の timestamp 属性 | 2024-08-28T15:12:57.311996+09:00 |
| magicpod | テスト一括実行終了日時 | 2024-05-09T02:44:32Z |
連携する自動テスト実施環境名を設定してください。
設定しない場合の自動テスト実施環境名
| テストフレームワーク | 自動テスト実施環境名 |
|---|---|
| junit,pytest,magicpod | 標準環境 |
| nodejs-playwright | testsuite 要素の hostname 属性 |
| pytest-playwright | testcase 要素の name 属性から取得 (例)test_sample[chromium-data-driven]の場合、”chromium”を取得 |
| mabl-deploy-event | 各 journey_executions の browser_type 属性 browser_type 属性がない場合は標準環境 |
事前にテストを実行し、xml or json ファイルを出力した後で本アクションを使用します。
steps:
- name: Checkout repository
uses: actions/checkout@v4
# 事前に自動テストを実行する(必要に応じて、自動テスト結果をxml/jsonで出力する設定を行う)
- name: Run tests
run: pytest tests/ --junitxml=result.xml
# 出力したファイルをもとに本アクションを使用する
- name: link Automated Test Results
uses: QualityForward/test-stability-report-sync@v1.2.0
with:
file-path: result.xml
test-framework: pytest-playwright
api-key: ${{ secrets.API_KEY }}
auto_test_suite_external_key: testSuites
auto_test_cycle_name: testCycleName
auto_execution_device_external_key: sampleDevice※同じテストフレームワークに限ります
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests
run: pytest tests/ --junitxml=result.xml
- name: link Automated Test Results
uses: QualityForward/test-stability-report-sync@v1.2.0
with:
file-path: results/*.xml # ワイルドカードで指定
test-framework: junit
api-key: ${{ secrets.API_KEY }}
auto_execution_device_external_key: chromeOSS のテストフレームワークと同じく、事前にテストを実行した後に本アクションを使用します。
※実行方法は各有償ツールのヘルプページを参照のこと
magicpod-api-client を使用して、一括実行する
jobs:
RunMagicPod:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install Packages
run: |
sudo apt-get update
sudo apt-get install -y unzip
# MagicPodの一括実行
- name: Batch Run Test
env:
MAGICPOD_API_TOKEN: ${{ secrets.MAGICPOD_API_TOKEN }}
run: |
OS=linux
FILENAME=magicpod-api-client
# magicpod-api-clientのインストール
curl -L "https://app.magicpod.com/api/v1.0/magicpod-clients/api/${OS}/latest/" -H "Authorization: Token ${MAGICPOD_API_TOKEN}" --output ${FILENAME}.zip
# magicpod-api-clientの解凍
unzip -q "${FILENAME}.zip" &
UNZIP_PID=$!
wait $UNZIP_PID
# MagicPodで使う各種環境変数を設定
MAGICPOD_ORGANIZATION=Organization_Name
MAGICPOD_PROJECT=Project_Name
# テスト一括実行
./magicpod-api-client.exe batch-run -t ${MAGICPOD_API_TOKEN} -o ${MAGICPOD_ORGANIZATION} -p ${MAGICPOD_PROJECT} -S Test_Settings_Number
# 一括実行したテストNoを取得
BATCH_RUN_NUMBER=$(./magicpod-api-client latest-batch-run-no -t ${MAGICPOD_API_TOKEN} -o ${MAGICPOD_ORGANIZATION} -p ${MAGICPOD_PROJECT})
# 一括実行結果をjsonに出力
./magicpod-api-client get-batch-run -t ${MAGICPOD_API_TOKEN} -o ${MAGICPOD_ORGANIZATION} -p ${MAGICPOD_PROJECT} -b ${BATCH_RUN_NUMBER} > results/batch_run_results.json
# アクションを使って、自動テスト結果を連携する
- name: link automated test results
uses: QualityForward/test-stability-report-sync@v1.2.0
with:
file-path: results/batch_run_results.json
test-framework: magicpod
api-key: ${{ secrets.API_KEY }}
auto_execution_device_external_key: Chromemabl cli を使用して、デプロイイベントを実行後、結果を連携する
jobs:
RunMablDeployEvent:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MABL_API_TOKEN: ${{ secrets.MABL_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install node.js
uses: actions/setup-node@v4
with:
node-version: "20"
# mabl cliのインストール
- name: Install and setup mabl-cli
run: |
npm install -g @mablhq/mabl-cli@latest
mabl auth activate-key ${MABL_API_TOKEN}
# mablのデプロイイベントの実行
- name: Batch Run Test
env:
APPLICATION_ID: applicationのID
ENVIRONMENT_ID: environmentのid
LABEL: ラベル名
run: |
set -euxo pipefail
# MEMO: テストが失敗した時、処理が止まるため一時的に無効にする
set +e
mabl deployments create --application-id ${APPLICATION_ID} --environment-id ${ENVIRONMENT_ID} --labels ${LABEL} --await-completion -o json > results/mabl_result.json
set -e
# アクションを使って、自動テスト結果を連携する
- name: link automated test results
uses: QualityForward/test-stability-report-sync@v1.2.0
with:
file-path: results/mabl_result.json
test-framework: mabl-deploy-event
api-key: ${{ secrets.API_KEY }}