summaryrefslogtreecommitdiffhomepage
path: root/.github/actions/ios/build-ios-e2e-tests/action.yml
blob: 4d65cfbe36826fa3e92685d3d6e3372ab3a76976 (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
84
85
name: 'Build iOS end to end tests action'
description: 'Prepares and builds end to end tests on iOS device'
inputs:
  ios_device_pin_code:
    description: 'iOS Device Pin Code'
    required: true
  test_device_identifier_uuid:
    description: 'Test Device Identifier UUID'
    required: true
  has_time_account_number:
    description: 'Has Time Account Number'
    required: true
  no_time_account_number:
    description: 'No Time Account Number'
    required: true
  test_device_udid:
    description: 'Test Device UDID'
    required: true
  partner_api_token:
    description: 'Partner API Token'
    required: true
  test_name:
    description: 'Test case/suite name. Will run all tests in the test plan if not provided.'
    required: false
  outputs_path:
    description: 'Path to store outputs. This should be unique for each job run in order to avoid concurrency issues.'
    required: true

runs:
  using: 'composite'
  steps:
    - name: Configure Xcode project
      run: |
        for file in *.xcconfig.template ; do cp $file ${file//.template/} ; done
          sed -i "" "/^HAS_TIME_ACCOUNT_NUMBER/d" UITests.xcconfig
          sed -i "" "/^NO_TIME_ACCOUNT_NUMBER/d" UITests.xcconfig
          sed -i "" \
            "/IOS_DEVICE_PIN_CODE =/ s/= .*/= $IOS_DEVICE_PIN_CODE/" \
            UITests.xcconfig
          sed -i "" \
            "/TEST_DEVICE_IDENTIFIER_UUID =/ s/= .*/= $TEST_DEVICE_IDENTIFIER_UUID/" \
            UITests.xcconfig
          sed -i "" \
            "s#^// PARTNER_API_TOKEN =#PARTNER_API_TOKEN =#" \
            UITests.xcconfig
          sed -i "" \
            "/PARTNER_API_TOKEN =/ s#= .*#= $PARTNER_API_TOKEN#" \
            UITests.xcconfig
          sed -i "" \
            "/ATTACH_APP_LOGS_ON_FAILURE =/ s#= .*#= 1#" \
            UITests.xcconfig
          sed -i "" \
            "/TEST_DEVICE_IS_IPAD =/ s#= .*#= 0#" \
            UITests.xcconfig
          sed -i "" \
            "/UNINSTALL_APP_IN_TEST_SUITE_TEAR_DOWN =/ s#= .*#= 0#" \
            UITests.xcconfig
      shell: bash
      working-directory: ios/Configurations
      env:
        IOS_DEVICE_PIN_CODE: ${{ inputs.ios_device_pin_code }}
        TEST_DEVICE_IDENTIFIER_UUID: ${{ inputs.test_device_identifier_uuid }}
        HAS_TIME_ACCOUNT_NUMBER: ${{ inputs.has_time_account_number }}
        NO_TIME_ACCOUNT_NUMBER: ${{ inputs.no_time_account_number }}
        PARTNER_API_TOKEN: ${{ inputs.partner_api_token }}

    - name: Build app and tests for testing
      run: |
        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 \
          -destination "platform=iOS,id=$TEST_DEVICE_UDID" \
          -derivedDataPath derived-data \
          clean build-for-testing 2>&1
      shell: bash
      working-directory: ios/
      env:
        TEST_DEVICE_UDID: ${{ inputs.test_device_udid }}
        TEST_NAME: ${{ inputs.test_name }}