nexo/apps/mattermost/.github/workflows/e2e-detox-pr.yml

248 lines
8.8 KiB
YAML

# E2E tests are triggered exclusively by Matterwick via workflow_dispatch.
# Matterwick provisions dedicated cloud servers and passes their URLs here.
# No static/permanent server fallback is used — if Matterwick doesn't dispatch
# this workflow, no E2E tests run.
name: E2E
on:
workflow_dispatch:
inputs:
MOBILE_VERSION:
description: "The mobile app commit SHA to test"
required: true
type: string
PLATFORM:
description: "Mobile platform to test: ios, android, or both"
required: false
default: "both"
type: choice
options:
- ios
- android
- both
SITE_1_URL:
description: "URL of the first Mattermost test server (provisioned by Matterwick)"
required: true
type: string
SITE_2_URL:
description: "URL of the second Mattermost test server (provisioned by Matterwick)"
required: false
type: string
SITE_3_URL:
description: "URL of the third Mattermost test server (provisioned by Matterwick)"
required: false
type: string
pr_number:
description: "PR number to remove E2E label from after tests complete"
required: false
type: string
run_type:
description: "Run type for test reporting (PR/RELEASE/NIGHTLY/MASTER). Defaults to PR."
required: false
default: "PR"
type: string
concurrency:
# Key on pr_number (or run_id for non-PR runs like nightly/push) so
# simultaneous dispatches for different PRs don't cancel each other.
group: "${{ github.workflow }}-${{ inputs.pr_number || github.run_id }}"
cancel-in-progress: true
env:
INTUNE_ENABLED: 'true'
jobs:
update-initial-status-ios:
if: inputs.PLATFORM == 'ios' || inputs.PLATFORM == 'both'
runs-on: ubuntu-22.04
steps:
- uses: mattermost/actions/delivery/update-commit-status@main
env:
GITHUB_TOKEN: ${{ github.token }}
with:
repository_full_name: ${{ github.repository }}
commit_sha: ${{ inputs.MOBILE_VERSION }}
context: e2e/detox-ios-tests
description: Detox iOS tests for mattermost mobile app have started ...
status: pending
update-initial-status-android:
if: inputs.PLATFORM == 'android' || inputs.PLATFORM == 'both'
runs-on: ubuntu-22.04
steps:
- uses: mattermost/actions/delivery/update-commit-status@main
env:
GITHUB_TOKEN: ${{ github.token }}
with:
repository_full_name: ${{ github.repository }}
commit_sha: ${{ inputs.MOBILE_VERSION }}
context: e2e/detox-android-tests
description: Detox Android tests for mattermost mobile app have started ...
status: pending
build-ios-simulator:
if: inputs.PLATFORM == 'ios' || inputs.PLATFORM == 'both'
runs-on: macos-26
needs:
- update-initial-status-ios
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.MOBILE_VERSION }}
- name: Prepare iOS Build
uses: ./.github/actions/prepare-ios-build
with:
intune-enabled: ${{ env.INTUNE_ENABLED }}
intune-ssh-private-key: ${{ secrets.MM_MOBILE_INTUNE_DEPLOY_KEY }}
- name: Set .env with RUNNING_E2E=true
run: echo "RUNNING_E2E=true" > .env
- name: Build iOS Simulator
env:
TAG: ${{ inputs.MOBILE_VERSION }}
GITHUB_TOKEN: ${{ secrets.MM_MOBILE_GITHUB_TOKEN }}
run: bundle exec fastlane ios simulator --env ios.simulator
working-directory: ./fastlane
- name: Upload iOS Simulator Build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ios-build-simulator-${{ github.run_id }}
path: Mattermost-simulator-*.app.zip
build-android-apk:
if: inputs.PLATFORM == 'android' || inputs.PLATFORM == 'both'
runs-on: ubuntu-latest-8-cores
needs:
- update-initial-status-android
env:
ORG_GRADLE_PROJECT_jvmargs: -Xmx8g
steps:
- name: Prune Docker to free up space
run: docker system prune -af
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.MOBILE_VERSION }}
- name: Prepare Android Build
uses: ./.github/actions/prepare-android-build
env:
STORE_FILE: ${{ secrets.MM_MOBILE_STORE_FILE }}
STORE_ALIAS: ${{ secrets.MM_MOBILE_STORE_ALIAS }}
STORE_PASSWORD: ${{ secrets.MM_MOBILE_STORE_PASSWORD }}
MATTERMOST_BUILD_GH_TOKEN: ${{ secrets.MATTERMOST_BUILD_GH_TOKEN }}
- name: Detox build
run: |
cd detox
npm ci --prefer-offline --no-audit --no-fund
npm install -g detox-cli
npm run e2e:android-inject-settings
npm run e2e:android-build
- name: Upload Android Build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: android-build-files-${{ github.run_id }}
path: "android/app/build/**/*"
run-ios-tests:
if: inputs.PLATFORM == 'ios' || inputs.PLATFORM == 'both'
name: iOS
needs:
- build-ios-simulator
uses: ./.github/workflows/e2e-ios-template.yml
with:
run-type: ${{ inputs.run_type || 'PR' }}
record_tests_in_zephyr: ${{ (inputs.run_type == 'RELEASE' || inputs.run_type == 'NIGHTLY' || inputs.run_type == 'MASTER') && 'true' || 'false' }}
MOBILE_VERSION: ${{ inputs.MOBILE_VERSION }}
MM_TEST_SERVER_URL: ${{ inputs.SITE_1_URL }}
MM_TEST_SERVER_URL_2: ${{ inputs.SITE_2_URL }}
MM_TEST_SERVER_URL_3: ${{ inputs.SITE_3_URL }}
secrets: inherit
run-android-tests:
if: inputs.PLATFORM == 'android' || inputs.PLATFORM == 'both'
name: Android
needs:
- build-android-apk
uses: ./.github/workflows/e2e-android-template.yml
with:
run-android-tests: true
run-type: ${{ inputs.run_type || 'PR' }}
record_tests_in_zephyr: ${{ (inputs.run_type == 'RELEASE' || inputs.run_type == 'NIGHTLY' || inputs.run_type == 'MASTER') && 'true' || 'false' }}
MOBILE_VERSION: ${{ inputs.MOBILE_VERSION }}
MM_TEST_SERVER_URL: ${{ inputs.SITE_1_URL }}
MM_TEST_SERVER_URL_2: ${{ inputs.SITE_2_URL }}
MM_TEST_SERVER_URL_3: ${{ inputs.SITE_3_URL }}
secrets: inherit
update-final-status-ios:
runs-on: ubuntu-22.04
if: always() && (inputs.PLATFORM == 'ios' || inputs.PLATFORM == 'both')
needs:
- run-ios-tests
steps:
- uses: mattermost/actions/delivery/update-commit-status@main
env:
GITHUB_TOKEN: ${{ github.token }}
with:
repository_full_name: ${{ github.repository }}
commit_sha: ${{ inputs.MOBILE_VERSION }}
context: e2e/detox-ios-tests
description: Completed with ${{ needs.run-ios-tests.outputs.FAILURES }} failures
status: ${{ needs.run-ios-tests.outputs.STATUS }}
target_url: ${{ needs.run-ios-tests.outputs.TARGET_URL }}
update-final-status-android:
runs-on: ubuntu-22.04
if: always() && (inputs.PLATFORM == 'android' || inputs.PLATFORM == 'both')
needs:
- run-android-tests
steps:
- uses: mattermost/actions/delivery/update-commit-status@main
env:
GITHUB_TOKEN: ${{ github.token }}
with:
repository_full_name: ${{ github.repository }}
commit_sha: ${{ inputs.MOBILE_VERSION }}
context: e2e/detox-android-tests
description: Completed with ${{ needs.run-android-tests.outputs.FAILURES }} failures
status: ${{ needs.run-android-tests.outputs.STATUS }}
target_url: ${{ needs.run-android-tests.outputs.TARGET_URL }}
e2e-remove-matterwick-label:
name: Remove Matterwick E2E label from PR
runs-on: ubuntu-22.04
needs:
- run-ios-tests
- run-android-tests
if: always() && inputs.pr_number != ''
steps:
- name: e2e/remove-label-from-pr
uses: actions/github-script@e7aeb8c663f696059ebb5f9ab1425ed2ef511bdb # v7.0.1
continue-on-error: true # Label might have been removed manually
with:
script: |
const prNumber = parseInt(process.env.PR_NUMBER);
if (!prNumber) return;
const labels = ['E2E/Run', 'E2E/Run-iOS', 'E2E/Run-Android'];
for (const label of labels) {
try {
await github.rest.issues.removeLabel({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
name: label,
});
} catch (_) {
// Label may not exist on this PR, ignore
}
}
env:
PR_NUMBER: ${{ inputs.pr_number }}