summaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/ios.yml
blob: f8a7f88ff16f19a1e70f31d39475c7ffb984380b (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
86
87
88
89
90
91
92
93
94
95
96
---
name: iOS app
on:
  pull_request:
    paths:
      - .github/workflows/ios.yml
      - ios/.swiftformat
      - ios/**/*.swift
  workflow_dispatch:
jobs:
  check-formatting:
    name: Check formatting
    runs-on: macos-11
    steps:
      - name: Install SwiftFormat
        run: |
          brew update
          brew upgrade swiftformat

      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Check formatting
        run: |
          swiftformat --version
          swiftformat --lint .

  test:
    name: Unit tests
    runs-on: macos-11
    env:
      SOURCE_PACKAGES_PATH: .spm
    steps:
      - name: Install xcbeautify
        run: brew install xcbeautify

      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Configure cache
        uses: actions/cache@v3
        with:
          path: ios/${{ env.SOURCE_PACKAGES_PATH }}
          key: ${{ runner.os }}-spm-${{ hashFiles('ios/**/Package.resolved') }}
          restore-keys: |
            ${{ runner.os }}-spm-

      - name: Setup go-lang
        uses: actions/setup-go@v3
        with:
          go-version: 1.19.5

      - name: Prepare iOS simulator
        # yamllint disable rule:line-length
        run: |
          sudo mkdir -p /Library/Developer/CoreSimulator/Profiles/Runtimes
          sudo ln -s \
            /Applications/Xcode_11.7.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime \
            /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 13.7.simruntime
        # yamllint enable rule:line-length

      - name: Configure Xcode project
        run: |
          cp Base.xcconfig.template Base.xcconfig
          cp App.xcconfig.template App.xcconfig
          cp PacketTunnel.xcconfig.template PacketTunnel.xcconfig
          cp Screenshots.xcconfig.template Screenshots.xcconfig
        working-directory: ios/Configurations

      - name: Convert Package.resolved v2 -> v1
        run: |
          jq '{
            "object": {
              "pins": .pins | map({
                "package": .identity,
                "repositoryURL": .location,
                "state": .state
              })
            },
            "version": 1
          }' Package.resolved > Package.resolved.out
          mv Package.resolved.out Package.resolved
        working-directory: ios/MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm

      - name: Run tests
        run: |
          set -o pipefail && xcodebuild test \
              -project MullvadVPN.xcodeproj \
              -scheme MullvadVPN \
              -skip-testing:MullvadVPNScreenshots \
              -destination "platform=iOS Simulator,OS=13.7,name=iPhone 8" \
              -clonedSourcePackagesDirPath "${SOURCE_PACKAGES_PATH}" \
              CODE_SIGN_IDENTITY="" \
              CODE_SIGNING_REQUIRED=NO \
              ONLY_ACTIVE_ARCH=YES | xcbeautify
        working-directory: ios