summaryrefslogtreecommitdiffhomepage
path: root/.github/actions/ios/run-ios-e2e-tests/action.yml
blob: 9e9b077c26997818a194c2209702bb51b9b37514 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: 'Run iOS end to end tests action'
description: 'Runs end to end tests on iOS device'
inputs:
  test_name:
    description: 'Test case/suite name. Will run all tests in the test plan if not provided.'
    required: false
  test_device_udid:
    description: 'Test Device UDID'
    required: true
  outputs_path:
    description: >
      Path to where outputs are stored - both build outputs and outputs from running tests.
      This should be unique for each job run in order to avoid concurrency issues.
    required: true

runs:
  using: 'composite'
  steps:
    # Set up a unique output directory
    - name: Set up outputs directory
      run: |
        # Forcing the filesystem buffers to be flushed to ensure the
        # directory tree is updated
        sync
        if [ -n "$TEST_NAME" ]; then
          # Strip slashes to avoid creating subdirectories
          test_name_sanitized=$(printf "$TEST_NAME" | sed 's/\//_/g')
          echo "Setting output directory tests-output-test-name-sanitized"
          echo "$test_name_sanitized"
          test_output_directory="${{ env.OUTPUTS_PATH }}/tests-output-$test_name_sanitized"
        else
          echo "Setting output directory output"
          test_output_directory="${{ env.OUTPUTS_PATH }}/tests-output"
        fi

        echo "TEST_OUTPUT_DIRECTORY=$test_output_directory" >> $GITHUB_ENV
        echo "TEST_NAME_SANITIZED=$test_name_sanitized" >> $GITHUB_ENV
      shell: bash
      env:
        TEST_NAME: ${{ inputs.test_name }}
        OUTPUTS_PATH: ${{ inputs.outputs_path }}

    - name: Uninstall app
      run: ios-deploy --id $TEST_DEVICE_UDID --uninstall_only --bundle_id net.mullvad.MullvadVPN
      shell: bash
      env:
        TEST_DEVICE_UDID: ${{ inputs.test_device_udid }}

    - name: Run end-to-end-tests
      run: |
        # Forcing the filesystem buffers to be flushed to ensure the
        # directory tree is updated
        sync
        if [ -n "$TEST_NAME" ]; then
          TEST_NAME_ARGUMENT=" -only-testing $TEST_NAME"
        else
          TEST_NAME_ARGUMENT=""
        fi
        set -o pipefail && env NSUnbufferedIO=YES xcodebuild \
          -project MullvadVPN.xcodeproj \
          -scheme MullvadVPNUITests \
          -testPlan MullvadVPNUITestsAll $TEST_NAME_ARGUMENT \
          -resultBundlePath ${{ env.TEST_OUTPUT_DIRECTORY }}/xcode-test-report \
          -derivedDataPath derived-data \
          -destination "platform=iOS,id=$TEST_DEVICE_UDID" \
          test-without-building 2>&1 | xcbeautify --report junit \
          --report-path ${{ env.TEST_OUTPUT_DIRECTORY }}/junit-test-report
      shell: bash
      working-directory: ${{ inputs.outputs_path }}/mullvadvpn-app/ios
      env:
        TEST_NAME: ${{ inputs.test_name }}
        TEST_DEVICE_UDID: ${{ inputs.test_device_udid }}

    - name: Store test report artifact
      if: always()
      uses: actions/upload-artifact@v4
      with:
        name: ${{ env.TEST_NAME_SANITIZED }}-test-results
        path: |
          ${{ env.TEST_OUTPUT_DIRECTORY }}/junit-test-report/junit.xml
          ${{ env.TEST_OUTPUT_DIRECTORY }}/xcode-test-report.xcresult
      env:
        TEST_NAME: ${{ inputs.test_name }}