iOS end-to-end tests #782
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: iOS end-to-end tests | |
env: | |
JOB_OUTPUTS_DIRECTORY: ${{ github.workspace }}/job-outputs-${{ github.run_id }} | |
TEST_DEVICE_UDID: 00008130-0019181022F3803A | |
permissions: | |
contents: read | |
issues: write | |
pull-requests: write | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
paths: | |
- .github/workflows/ios-end-to-end-tests.yml | |
- ios/** | |
workflow_dispatch: | |
inputs: | |
# Optionally specify a test case or suite to run. | |
# Must be in the format MullvadVPNUITest/<test-suite-name>/<test-case-name> where test case name is optional. | |
user_supplied_test_name: | |
description: 'Only run test case/suite' | |
required: false | |
schedule: | |
# At midnight every day. | |
# Notifications for scheduled workflows are sent to the user who last modified the cron | |
# syntax in the workflow file. If you update this you must have notifications for | |
# Github Actions enabled, so these don't go unnoticed. | |
# https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/notifications-for-workflow-runs | |
- cron: '0 0 * * *' | |
jobs: | |
checkout-repository: | |
if: github.event.pull_request.merged || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' | |
name: Checkout repository | |
runs-on: [self-hosted, macOS, ios-test] | |
steps: | |
- name: Set up unique outputs directory | |
run: mkdir -p ${{ env.JOB_OUTPUTS_DIRECTORY }} | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
clean: true | |
# Define the set of tests to run based on the event type and input | |
define-test-suites-matrix: | |
if: github.event.pull_request.merged || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' | |
name: Define test suites matrix | |
runs-on: [self-hosted, macOS, ios-test] | |
needs: checkout-repository | |
steps: | |
- name: Test runs to JSON | |
id: test-runs-to-json | |
run: | | |
if [ -n "$TEST_NAME" ]; then | |
test_suites_json="['$TEST_NAME']" >> $GITHUB_ENV | |
else | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
test_suites_json=$(jq -r --compact-output .tests.pr-merge-to-main tests.json) | |
echo "test_suites_json=$test_suites_json" >> $GITHUB_ENV | |
elif [[ "${{ github.event_name }}" == "schedule" ]] | [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
test_suites_json=$(jq -r --compact-output .tests.all tests.json) | |
echo "test_suites_json=$test_suites_json" >> $GITHUB_ENV | |
# List test suites based on file names | |
#test_suites=$(find . -name "*Tests.swift" | sed 's/.*\///' | sed 's/\.swift//' | sed '/SettingsMigrationTests/d' | sort) | |
#test_suites_json=$(printf "$test_suites" | jq --compact-output --raw-input --slurp 'split("\n")') | |
#echo "test_suites_json=$test_suites_json" >> $GITHUB_ENV | |
fi | |
fi | |
working-directory: ios/MullvadVPNUITests | |
outputs: | |
test_suites_json: ${{ env.test_suites_json }} | |
# Build app and tests target | |
build: | |
if: github.event.pull_request.merged || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' | |
name: Build for end to end testing | |
runs-on: [self-hosted, macOS, ios-test] | |
needs: [checkout-repository] | |
timeout-minutes: 20 | |
steps: | |
- name: Configure Rust | |
uses: actions-rs/toolchain@v1.0.6 | |
with: | |
toolchain: stable | |
override: true | |
target: aarch64-apple-ios | |
- name: Build iOS end to end tests action | |
uses: ./.github/actions/build-ios-e2e-tests | |
with: | |
test_name: ${{ github.event.inputs.user_supplied_test_name }} | |
ios_device_pin_code: ${{ secrets.IOS_DEVICE_PIN_CODE }} | |
test_device_identifier_uuid: ${{ secrets.IOS_TEST_DEVICE_IDENTIFIER_UUID }} | |
has_time_account_number: ${{ secrets.IOS_HAS_TIME_ACCOUNT_NUMBER_PRODUCTION }} | |
no_time_account_number: ${{ secrets.IOS_NO_TIME_ACCOUNT_NUMBER_PRODUCTION }} | |
test_device_udid: ${{ env.TEST_DEVICE_UDID }} | |
partner_api_token: ${{ secrets.STAGEMOLE_PARTNER_AUTH }} | |
outputs_path: ${{ env.JOB_OUTPUTS_DIRECTORY }} | |
- name: Copy build output and project to output directory | |
run: | | |
mkdir -p ${{ env.JOB_OUTPUTS_DIRECTORY }}/derived-data | |
cp -R ios/derived-data ${{ env.JOB_OUTPUTS_DIRECTORY }} | |
cp -R . ${{ env.JOB_OUTPUTS_DIRECTORY }}/mullvadvpn-app | |
shell: bash | |
- name: Debug listing of files | |
run: | | |
echo "JOB_OUTPUTS_DIRECTORY:" | |
ls -lA ${{ env.JOB_OUTPUTS_DIRECTORY }} | |
echo "derived-data:" | |
ls -lA ${{ env.JOB_OUTPUTS_DIRECTORY}}/derived-data | |
echo "ios/" | |
ls -lA . | |
echo "derived-data" | |
ls -lA derived-data | |
echo "pwd" | |
pwd | |
echo "mullvadvpn-app" | |
ls -lA ${{ env.JOB_OUTPUTS_DIRECTORY }}/mullvadvpn-app | |
echo "Configurations" | |
ls -lA ${{ env.JOB_OUTPUTS_DIRECTORY }}/mullvadvpn-app/ios/Configurations | |
shell: bash | |
working-directory: ios/ | |
- name: Clean up | |
run: | | |
rm -rf ios/Configurations/*.xcconfig | |
rm -rf ios/derived-data | |
shell: bash | |
test: | |
if: github.event.pull_request.merged || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' | |
name: Run tests | |
runs-on: [self-hosted, macOS, ios-test] | |
needs: [build, define-test-suites-matrix] | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
matrix: | |
test_suite: ${{fromJson(needs.define-test-suites-matrix.outputs.test_suites_json)}} | |
steps: | |
- name: Run iOS end to end tests action | |
uses: ./.github/actions/run-ios-e2e-tests | |
with: | |
test_name: "MullvadVPNUITests/${{ matrix.test_suite }}" | |
test_device_udid: ${{ env.TEST_DEVICE_UDID }} | |
outputs_path: ${{ env.JOB_OUTPUTS_DIRECTORY }} | |
notify-on-failure: | |
if: failure() && github.event_name == 'pull_request' | |
name: Notify team on failure | |
runs-on: [self-hosted, macOS, ios-test] | |
needs: test | |
timeout-minutes: 5 | |
steps: | |
- name: Comment PR on test failure | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const issue_number = context.issue.number; | |
const run_id = context.runId; | |
const run_url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${run_id}`; | |
github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
body: `🚨 End to end tests failed. Please check the [failed workflow run](${run_url}).` | |
}); |