|
| 1 | +name: macOS |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches-ignore: |
| 5 | + - '*WIP' |
| 6 | +env: |
| 7 | + PACKAGE_NAME: AviaryInsights |
| 8 | +jobs: |
| 9 | + build-ubuntu: |
| 10 | + name: Build on Ubuntu |
| 11 | + env: |
| 12 | + SWIFT_VER: ${{ matrix.swift-version }} |
| 13 | + runs-on: ${{ matrix.runs-on }} |
| 14 | + if: "!contains(github.event.head_commit.message, 'ci skip')" |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + runs-on: [ubuntu-20.04, ubuntu-22.04] |
| 18 | + swift-version: ["5.9", "5.9.2", "5.10"] |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - name: Set Ubuntu Release DOT |
| 22 | + run: echo "RELEASE_DOT=$(lsb_release -sr)" >> $GITHUB_ENV |
| 23 | + - name: Set Ubuntu Release NUM |
| 24 | + run: echo "RELEASE_NUM=${RELEASE_DOT//[-._]/}" >> $GITHUB_ENV |
| 25 | + - name: Set Ubuntu Codename |
| 26 | + run: echo "RELEASE_NAME=$(lsb_release -sc)" >> $GITHUB_ENV |
| 27 | + - name: Cache swift package modules |
| 28 | + id: cache-spm-linux |
| 29 | + uses: actions/cache@v4 |
| 30 | + env: |
| 31 | + cache-name: cache-spm |
| 32 | + with: |
| 33 | + path: .build |
| 34 | + key: ${{ runner.os }}-${{ env.RELEASE_DOT }}-${{ env.cache-name }}-${{ matrix.swift-version }}-${{ hashFiles('Package.resolved') }} |
| 35 | + restore-keys: | |
| 36 | + ${{ runner.os }}-${{ env.RELEASE_DOT }}-${{ env.cache-name }}-${{ matrix.swift-version }}- |
| 37 | + ${{ runner.os }}-${{ env.RELEASE_DOT }}-${{ env.cache-name }}- |
| 38 | + - name: Cache swift |
| 39 | + id: cache-swift-linux |
| 40 | + uses: actions/cache@v4 |
| 41 | + env: |
| 42 | + cache-name: cache-swift |
| 43 | + with: |
| 44 | + path: swift-${{ env.SWIFT_VER }}-RELEASE-ubuntu${{ env.RELEASE_DOT }} |
| 45 | + key: ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.swift-version }}-${{ env.RELEASE_DOT }} |
| 46 | + restore-keys: | |
| 47 | + ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.swift-version }}- |
| 48 | + - name: Download Swift |
| 49 | + if: steps.cache-swift-linux.outputs.cache-hit != 'true' |
| 50 | + run: curl -O https://download.swift.org/swift-${SWIFT_VER}-release/ubuntu${RELEASE_NUM}/swift-${SWIFT_VER}-RELEASE/swift-${SWIFT_VER}-RELEASE-ubuntu${RELEASE_DOT}.tar.gz |
| 51 | + - name: Extract Swift |
| 52 | + if: steps.cache-swift-linux.outputs.cache-hit != 'true' |
| 53 | + run: tar xzf swift-${SWIFT_VER}-RELEASE-ubuntu${RELEASE_DOT}.tar.gz |
| 54 | + - name: Add Path |
| 55 | + run: echo "$GITHUB_WORKSPACE/swift-${SWIFT_VER}-RELEASE-ubuntu${RELEASE_DOT}/usr/bin" >> $GITHUB_PATH |
| 56 | + - name: Test |
| 57 | + run: swift test --enable-code-coverage |
| 58 | + - uses: sersoft-gmbh/swift-coverage-action@v4 |
| 59 | + id: coverage-files |
| 60 | + with: |
| 61 | + fail-on-empty-output: true |
| 62 | + - name: Upload coverage to Codecov |
| 63 | + uses: codecov/codecov-action@v4 |
| 64 | + with: |
| 65 | + fail_ci_if_error: true |
| 66 | + flags: swift-${{ matrix.swift-version }},ubuntu-${{ matrix.RELEASE_DOT }} |
| 67 | + verbose: true |
| 68 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 69 | + files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }} |
| 70 | + build-macos: |
| 71 | + name: Build on macOS |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + if: "!contains(github.event.head_commit.message, 'ci skip')" |
| 74 | + strategy: |
| 75 | + matrix: |
| 76 | + include: |
| 77 | + - xcode: "/Applications/Xcode_15.0.1.app" |
| 78 | + os: macos-13 |
| 79 | + iOSVersion: "17.0.1" |
| 80 | + watchOSVersion: "10.0" |
| 81 | + watchName: "Apple Watch Series 9 (41mm)" |
| 82 | + iPhoneName: "iPhone 15" |
| 83 | + - xcode: "/Applications/Xcode_15.1.app" |
| 84 | + os: macos-13 |
| 85 | + iOSVersion: "17.2" |
| 86 | + watchOSVersion: "10.2" |
| 87 | + watchName: "Apple Watch Series 9 (45mm)" |
| 88 | + iPhoneName: "iPhone 15 Plus" |
| 89 | + - xcode: "/Applications/Xcode_15.2.app" |
| 90 | + os: macos-14 |
| 91 | + iOSVersion: "17.2" |
| 92 | + watchOSVersion: "10.2" |
| 93 | + watchName: "Apple Watch Ultra (49mm)" |
| 94 | + iPhoneName: "iPhone 15 Pro" |
| 95 | + - xcode: "/Applications/Xcode_15.3.app" |
| 96 | + os: macos-14 |
| 97 | + iOSVersion: "17.4" |
| 98 | + watchOSVersion: "10.4" |
| 99 | + watchName: "Apple Watch Ultra 2 (49mm)" |
| 100 | + iPhoneName: "iPhone 15 Pro Max" |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@v4 |
| 103 | + - name: Cache swift package modules |
| 104 | + id: cache-spm-macos |
| 105 | + uses: actions/cache@v4 |
| 106 | + env: |
| 107 | + cache-name: cache-spm |
| 108 | + with: |
| 109 | + path: .build |
| 110 | + key: ${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.xcode }}-${{ hashFiles('Package.resolved') }} |
| 111 | + restore-keys: | |
| 112 | + ${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.xcode }}- |
| 113 | + - name: Cache mint |
| 114 | + if: startsWith(matrix.xcode,'/Applications/Xcode_15.3') |
| 115 | + id: cache-mint |
| 116 | + uses: actions/cache@v4 |
| 117 | + env: |
| 118 | + cache-name: cache-mint |
| 119 | + with: |
| 120 | + path: .mint |
| 121 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Mintfile') }} |
| 122 | + restore-keys: | |
| 123 | + ${{ runner.os }}-build-${{ env.cache-name }}- |
| 124 | + ${{ runner.os }}-build- |
| 125 | + ${{ runner.os }}- |
| 126 | + - name: Set Xcode Name |
| 127 | + run: echo "XCODE_NAME=$(basename -- ${{ matrix.xcode }} | sed 's/\.[^.]*$//' | cut -d'_' -f2)" >> $GITHUB_ENV |
| 128 | + - name: Setup Xcode |
| 129 | + run: sudo xcode-select -s ${{ matrix.xcode }}/Contents/Developer |
| 130 | + - name: Install mint |
| 131 | + if: startsWith(matrix.xcode,'/Applications/Xcode_15.3') |
| 132 | + run: | |
| 133 | + brew update |
| 134 | + brew install mint |
| 135 | + - name: Build |
| 136 | + run: swift build |
| 137 | + - name: Run Swift Package tests |
| 138 | + run: swift test --enable-code-coverage |
| 139 | + - uses: sersoft-gmbh/swift-coverage-action@v4 |
| 140 | + id: coverage-files-spm |
| 141 | + with: |
| 142 | + fail-on-empty-output: true |
| 143 | + - name: Upload coverage reports to Codecov |
| 144 | + uses: codecov/codecov-action@v4 |
| 145 | + with: |
| 146 | + files: ${{ join(fromJSON(steps.coverage-files-spm.outputs.files), ',') }} |
| 147 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 148 | + flags: macOS,${{ env.XCODE_NAME }},${{ matrix.runs-on }} |
| 149 | + - name: Clean up spm build directory |
| 150 | + run: rm -rf .build |
| 151 | + - name: Lint |
| 152 | + run: ./scripts/lint.sh |
| 153 | + if: startsWith(matrix.xcode,'/Applications/Xcode_15.3') |
| 154 | + - name: Run iOS target tests |
| 155 | + run: xcodebuild test -scheme ${{ env.PACKAGE_NAME }} -sdk "iphonesimulator" -destination 'platform=iOS Simulator,name=${{ matrix.iPhoneName }},OS=${{ matrix.iOSVersion }}' -enableCodeCoverage YES build test |
| 156 | + - uses: sersoft-gmbh/swift-coverage-action@v4 |
| 157 | + id: coverage-files-iOS |
| 158 | + with: |
| 159 | + fail-on-empty-output: true |
| 160 | + - name: Upload coverage to Codecov |
| 161 | + uses: codecov/codecov-action@v4 |
| 162 | + with: |
| 163 | + fail_ci_if_error: true |
| 164 | + verbose: true |
| 165 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 166 | + files: ${{ join(fromJSON(steps.coverage-files-iOS.outputs.files), ',') }} |
| 167 | + flags: iOS,iOS${{ matrix.iOSVersion }},macOS,${{ env.XCODE_NAME }} |
| 168 | + - name: Run watchOS target tests |
| 169 | + run: xcodebuild test -scheme ${{ env.PACKAGE_NAME }} -sdk "watchsimulator" -destination 'platform=watchOS Simulator,name=${{ matrix.watchName }},OS=${{ matrix.watchOSVersion }}' -enableCodeCoverage YES build test |
| 170 | + - uses: sersoft-gmbh/swift-coverage-action@v4 |
| 171 | + id: coverage-files-watchOS |
| 172 | + with: |
| 173 | + fail-on-empty-output: true |
| 174 | + - name: Upload coverage to Codecov |
| 175 | + uses: codecov/codecov-action@v4 |
| 176 | + with: |
| 177 | + fail_ci_if_error: true |
| 178 | + verbose: true |
| 179 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 180 | + files: ${{ join(fromJSON(steps.coverage-files-watchOS.outputs.files), ',') }} |
| 181 | + flags: watchOS,watchOS${{ matrix.watchOSVersion }},macOS,${{ env.XCODE_NAME }} |
| 182 | + build-self: |
| 183 | + name: Build on Self-Hosting macOS |
| 184 | + runs-on: [self-hosted, macOS] |
| 185 | + if: github.event.repository.owner.login == github.event.organization.login && !contains(github.event.head_commit.message, 'ci skip') |
| 186 | + steps: |
| 187 | + - uses: actions/checkout@v4 |
| 188 | + - name: Cache swift package modules |
| 189 | + id: cache-spm-macos |
| 190 | + uses: actions/cache@v4 |
| 191 | + env: |
| 192 | + cache-name: cache-spm |
| 193 | + with: |
| 194 | + path: .build |
| 195 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Package.resolved') }} |
| 196 | + restore-keys: | |
| 197 | + ${{ runner.os }}-build-${{ env.cache-name }}- |
| 198 | + ${{ runner.os }}-build- |
| 199 | + ${{ runner.os }}- |
| 200 | + - name: Cache mint |
| 201 | + id: cache-mint |
| 202 | + uses: actions/cache@v4 |
| 203 | + env: |
| 204 | + cache-name: cache-mint |
| 205 | + with: |
| 206 | + path: .mint |
| 207 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Mintfile') }} |
| 208 | + restore-keys: | |
| 209 | + ${{ runner.os }}-build-${{ env.cache-name }}- |
| 210 | + ${{ runner.os }}-build- |
| 211 | + ${{ runner.os }}- |
| 212 | + - name: Build |
| 213 | + run: swift build |
| 214 | + - name: Run Swift Package tests |
| 215 | + run: swift test --enable-code-coverage |
| 216 | + - uses: sersoft-gmbh/swift-coverage-action@v4 |
| 217 | + with: |
| 218 | + fail-on-empty-output: true |
| 219 | + - name: Upload coverage reports to Codecov |
| 220 | + uses: codecov/codecov-action@v4 |
| 221 | + with: |
| 222 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 223 | + flags: macOS,${{ env.XCODE_NAME }} |
| 224 | + - name: Clean up spm build directory |
| 225 | + run: rm -rf .build |
| 226 | + - name: Lint |
| 227 | + run: ./scripts/lint.sh |
0 commit comments