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