From acfccb170fddb53a79d6f71552cb02526950bba0 Mon Sep 17 00:00:00 2001 From: yasserfaraazkhan Date: Fri, 29 Nov 2024 11:48:35 +0530 Subject: [PATCH] Fix: Env variabled to pick up right simulator device for tests (#8367) --- .github/workflows/e2e-detox-template.yml | 9 ++++----- detox/.detoxrc.json | 4 ++-- detox/utils/generate_detox_config_ci.js | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/e2e-detox-template.yml b/.github/workflows/e2e-detox-template.yml index 659f793e2..9465a2ef0 100644 --- a/.github/workflows/e2e-detox-template.yml +++ b/.github/workflows/e2e-detox-template.yml @@ -42,12 +42,12 @@ on: description: "iPhone simulator name" required: false type: string - default: "iPhone 14" + default: "iPhone 15 Pro" ios_device_os_name: description: "iPhone simulator OS version" required: false type: string - default: "iOS 17.0" + default: "iOS 17.4" low_bandwidth_mode: description: "Enable low bandwidth mode" required: false @@ -66,8 +66,8 @@ env: ADMIN_EMAIL: ${{ secrets.MM_MOBILE_E2E_ADMIN_EMAIL }} ADMIN_USERNAME: ${{ secrets.MM_MOBILE_E2E_ADMIN_USERNAME }} ADMIN_PASSWORD: ${{ secrets.MM_MOBILE_E2E_ADMIN_PASSWORD }} - # BRANCH: ${{ github.head_ref || github.ref_name }} - # COMMIT_HASH: ${{ github.sha }} + BRANCH: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} + COMMIT_HASH: ${{ github.sha }} DEVICE_NAME: ${{ inputs.ios_device_name }} DEVICE_OS_VERSION: ${{ inputs.ios_device_os_name }} DETOX_AWS_S3_BUCKET: "mattermost-detox-report" @@ -195,7 +195,6 @@ jobs: DETOX_OS_VERSION: ${{ env.DEVICE_OS_VERSION }} LOW_BANDWIDTH_MODE: ${{ inputs.low_bandwidth_mode }} - - name: reset network settings if: ${{ inputs.low_bandwidth_mode || failure() }} run: | diff --git a/detox/.detoxrc.json b/detox/.detoxrc.json index d57c9abda..a38b3f4fa 100644 --- a/detox/.detoxrc.json +++ b/detox/.detoxrc.json @@ -30,8 +30,8 @@ "ios.simulator": { "type": "ios.simulator", "device": { - "type": "__DEVICE_TYPE__", - "os": "__DEVICE_OS__" + "type": "__DEVICE_NAME__", + "os": "__DEVICE_OS_VERSION__" } }, "android.emulator": { diff --git a/detox/utils/generate_detox_config_ci.js b/detox/utils/generate_detox_config_ci.js index abf734230..e8d23bbe9 100644 --- a/detox/utils/generate_detox_config_ci.js +++ b/detox/utils/generate_detox_config_ci.js @@ -4,10 +4,10 @@ /* eslint-disable no-process-env */ /* eslint-disable no-console */ const fs = require('fs'); -const deviceType = process.env.DETOX_DEVICE_TYPE || 'iPhone 15 Pro'; -const deviceOS = process.env.DETOX_DEVICE_OS || 'iOS 17.4'; +const deviceName = process.env.DEVICE_NAME || 'iPhone 15 Pro'; +const deviceOSVersion = process.env.DEVICE_OS_VERSION || 'iOS 17.4'; const detoxConfigTemplate = fs.readFileSync('../.detoxrc.json', 'utf8'); -const detoxConfig = detoxConfigTemplate.replace('__DEVICE_TYPE__', deviceType).replace('__DEVICE_OS__', deviceOS); +const detoxConfig = detoxConfigTemplate.replace('__DEVICE_NAME__', deviceName).replace('__DEVICE_OS_VERSION__', deviceOSVersion); fs.writeFileSync('../.detoxrc.json', detoxConfig);