|
1 | | -name: CI |
| 1 | +name: CI/CD Pipeline |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [ "main", "master" ] |
| 5 | + branches: [ main, develop ] |
6 | 6 | pull_request: |
7 | | - branches: [ "main", "master" ] |
| 7 | + branches: [ main ] |
| 8 | + release: |
| 9 | + types: [ created ] |
| 10 | + |
| 11 | +env: |
| 12 | + SWIFT_VERSION: '5.9' |
| 13 | + XCODE_VERSION: '15.0' |
| 14 | + IOS_DEPLOYMENT_TARGET: '16.0' |
8 | 15 |
|
9 | 16 | jobs: |
10 | | - noop: |
| 17 | + # Lint and Format Check |
| 18 | + lint: |
| 19 | + name: SwiftLint |
| 20 | + runs-on: macos-13 |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Install SwiftLint |
| 25 | + run: brew install swiftlint |
| 26 | + |
| 27 | + - name: Run SwiftLint |
| 28 | + run: swiftlint --strict --reporter github-actions-logging |
| 29 | + |
| 30 | + # Unit Tests |
| 31 | + test: |
| 32 | + name: Unit Tests |
| 33 | + runs-on: macos-13 |
| 34 | + strategy: |
| 35 | + matrix: |
| 36 | + destination: |
| 37 | + - 'platform=iOS Simulator,OS=17.0,name=iPhone 15 Pro' |
| 38 | + - 'platform=iOS Simulator,OS=16.0,name=iPhone 14' |
| 39 | + - 'platform=iOS Simulator,OS=16.0,name=iPad Pro (12.9-inch) (6th generation)' |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Select Xcode |
| 44 | + run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app |
| 45 | + |
| 46 | + - name: Build and Test |
| 47 | + run: | |
| 48 | + xcodebuild clean test \ |
| 49 | + -scheme WidgetDevelopmentKit \ |
| 50 | + -destination '${{ matrix.destination }}' \ |
| 51 | + -enableCodeCoverage YES \ |
| 52 | + -resultBundlePath TestResults \ |
| 53 | + | xcpretty --test --color |
| 54 | + |
| 55 | + - name: Upload Test Results |
| 56 | + uses: actions/upload-artifact@v3 |
| 57 | + if: failure() |
| 58 | + with: |
| 59 | + name: test-results |
| 60 | + path: TestResults |
| 61 | + |
| 62 | + # Code Coverage |
| 63 | + coverage: |
| 64 | + name: Code Coverage |
| 65 | + runs-on: macos-13 |
| 66 | + needs: test |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Select Xcode |
| 71 | + run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app |
| 72 | + |
| 73 | + - name: Build for Testing |
| 74 | + run: | |
| 75 | + xcodebuild build-for-testing \ |
| 76 | + -scheme WidgetDevelopmentKit \ |
| 77 | + -destination 'platform=iOS Simulator,OS=17.0,name=iPhone 15 Pro' \ |
| 78 | + -enableCodeCoverage YES |
| 79 | + |
| 80 | + - name: Run Tests with Coverage |
| 81 | + run: | |
| 82 | + xcodebuild test-without-building \ |
| 83 | + -scheme WidgetDevelopmentKit \ |
| 84 | + -destination 'platform=iOS Simulator,OS=17.0,name=iPhone 15 Pro' \ |
| 85 | + -enableCodeCoverage YES |
| 86 | + |
| 87 | + - name: Generate Coverage Report |
| 88 | + run: | |
| 89 | + xcrun llvm-cov export \ |
| 90 | + -format="lcov" \ |
| 91 | + -instr-profile=$(find . -name "*.profdata") \ |
| 92 | + $(find . -name "*.app") > coverage.lcov |
| 93 | + |
| 94 | + - name: Upload Coverage to Codecov |
| 95 | + uses: codecov/codecov-action@v3 |
| 96 | + with: |
| 97 | + file: ./coverage.lcov |
| 98 | + flags: unittests |
| 99 | + name: codecov-umbrella |
| 100 | + |
| 101 | + # Security Scan |
| 102 | + security: |
| 103 | + name: Security Scan |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + |
| 108 | + - name: Run Trivy Security Scanner |
| 109 | + uses: aquasecurity/trivy-action@master |
| 110 | + with: |
| 111 | + scan-type: 'fs' |
| 112 | + scan-ref: '.' |
| 113 | + format: 'sarif' |
| 114 | + output: 'trivy-results.sarif' |
| 115 | + |
| 116 | + - name: Upload Trivy Results |
| 117 | + uses: github/codeql-action/upload-sarif@v2 |
| 118 | + with: |
| 119 | + sarif_file: 'trivy-results.sarif' |
| 120 | + |
| 121 | + # Build Framework |
| 122 | + build: |
| 123 | + name: Build Framework |
| 124 | + runs-on: macos-13 |
| 125 | + needs: [lint, test] |
| 126 | + strategy: |
| 127 | + matrix: |
| 128 | + configuration: [Debug, Release] |
| 129 | + steps: |
| 130 | + - uses: actions/checkout@v4 |
| 131 | + |
| 132 | + - name: Select Xcode |
| 133 | + run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app |
| 134 | + |
| 135 | + - name: Build Framework |
| 136 | + run: | |
| 137 | + xcodebuild build \ |
| 138 | + -scheme WidgetDevelopmentKit \ |
| 139 | + -configuration ${{ matrix.configuration }} \ |
| 140 | + -destination 'generic/platform=iOS' \ |
| 141 | + -archivePath build/WidgetDevelopmentKit.xcarchive \ |
| 142 | + archive |
| 143 | + |
| 144 | + - name: Create XCFramework |
| 145 | + if: matrix.configuration == 'Release' |
| 146 | + run: | |
| 147 | + xcodebuild -create-xcframework \ |
| 148 | + -archive build/WidgetDevelopmentKit.xcarchive \ |
| 149 | + -framework WidgetDevelopmentKit.framework \ |
| 150 | + -output build/WidgetDevelopmentKit.xcframework |
| 151 | + |
| 152 | + - name: Upload XCFramework |
| 153 | + if: matrix.configuration == 'Release' |
| 154 | + uses: actions/upload-artifact@v3 |
| 155 | + with: |
| 156 | + name: WidgetDevelopmentKit.xcframework |
| 157 | + path: build/WidgetDevelopmentKit.xcframework |
| 158 | + |
| 159 | + # Documentation |
| 160 | + documentation: |
| 161 | + name: Generate Documentation |
| 162 | + runs-on: macos-13 |
| 163 | + needs: build |
| 164 | + steps: |
| 165 | + - uses: actions/checkout@v4 |
| 166 | + |
| 167 | + - name: Select Xcode |
| 168 | + run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app |
| 169 | + |
| 170 | + - name: Build Documentation |
| 171 | + run: | |
| 172 | + xcodebuild docbuild \ |
| 173 | + -scheme WidgetDevelopmentKit \ |
| 174 | + -destination 'generic/platform=iOS' \ |
| 175 | + -derivedDataPath build |
| 176 | + |
| 177 | + - name: Process Documentation |
| 178 | + run: | |
| 179 | + $(xcrun --find docc) process-archive \ |
| 180 | + transform-for-static-hosting \ |
| 181 | + build/Build/Products/Debug-iphoneos/WidgetDevelopmentKit.doccarchive \ |
| 182 | + --output-path docs \ |
| 183 | + --hosting-base-path iOS-Widget-Development-Kit |
| 184 | + |
| 185 | + - name: Upload Documentation |
| 186 | + uses: actions/upload-artifact@v3 |
| 187 | + with: |
| 188 | + name: documentation |
| 189 | + path: docs |
| 190 | + |
| 191 | + # SwiftPM Validation |
| 192 | + swiftpm: |
| 193 | + name: SwiftPM Validation |
| 194 | + runs-on: macos-13 |
| 195 | + steps: |
| 196 | + - uses: actions/checkout@v4 |
| 197 | + |
| 198 | + - name: Select Xcode |
| 199 | + run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app |
| 200 | + |
| 201 | + - name: Resolve Dependencies |
| 202 | + run: swift package resolve |
| 203 | + |
| 204 | + - name: Build Package |
| 205 | + run: swift build -c release |
| 206 | + |
| 207 | + - name: Run Package Tests |
| 208 | + run: swift test |
| 209 | + |
| 210 | + # Performance Benchmarks |
| 211 | + benchmark: |
| 212 | + name: Performance Benchmarks |
| 213 | + runs-on: macos-13 |
| 214 | + needs: build |
| 215 | + steps: |
| 216 | + - uses: actions/checkout@v4 |
| 217 | + |
| 218 | + - name: Select Xcode |
| 219 | + run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app |
| 220 | + |
| 221 | + - name: Run Benchmarks |
| 222 | + run: | |
| 223 | + xcodebuild test \ |
| 224 | + -scheme WidgetDevelopmentKit-Benchmarks \ |
| 225 | + -destination 'platform=iOS Simulator,OS=17.0,name=iPhone 15 Pro' \ |
| 226 | + -only-testing:WidgetDevelopmentKitBenchmarks |
| 227 | + |
| 228 | + - name: Upload Benchmark Results |
| 229 | + uses: actions/upload-artifact@v3 |
| 230 | + with: |
| 231 | + name: benchmark-results |
| 232 | + path: BenchmarkResults |
| 233 | + |
| 234 | + # Release |
| 235 | + release: |
| 236 | + name: Release |
| 237 | + runs-on: macos-13 |
| 238 | + needs: [build, documentation, security] |
| 239 | + if: github.event_name == 'release' |
| 240 | + steps: |
| 241 | + - uses: actions/checkout@v4 |
| 242 | + |
| 243 | + - name: Download XCFramework |
| 244 | + uses: actions/download-artifact@v3 |
| 245 | + with: |
| 246 | + name: WidgetDevelopmentKit.xcframework |
| 247 | + path: build |
| 248 | + |
| 249 | + - name: Create Release Archive |
| 250 | + run: | |
| 251 | + zip -r WidgetDevelopmentKit-${{ github.event.release.tag_name }}.xcframework.zip build/WidgetDevelopmentKit.xcframework |
| 252 | + |
| 253 | + - name: Upload Release Asset |
| 254 | + uses: actions/upload-release-asset@v1 |
| 255 | + env: |
| 256 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 257 | + with: |
| 258 | + upload_url: ${{ github.event.release.upload_url }} |
| 259 | + asset_path: ./WidgetDevelopmentKit-${{ github.event.release.tag_name }}.xcframework.zip |
| 260 | + asset_name: WidgetDevelopmentKit-${{ github.event.release.tag_name }}.xcframework.zip |
| 261 | + asset_content_type: application/zip |
| 262 | + |
| 263 | + # Deploy Documentation |
| 264 | + deploy-docs: |
| 265 | + name: Deploy Documentation |
11 | 266 | runs-on: ubuntu-latest |
| 267 | + needs: documentation |
| 268 | + if: github.ref == 'refs/heads/main' |
12 | 269 | steps: |
13 | | - - run: echo "Build temporarily disabled per repository policy" |
| 270 | + - uses: actions/checkout@v4 |
| 271 | + |
| 272 | + - name: Download Documentation |
| 273 | + uses: actions/download-artifact@v3 |
| 274 | + with: |
| 275 | + name: documentation |
| 276 | + path: docs |
| 277 | + |
| 278 | + - name: Deploy to GitHub Pages |
| 279 | + uses: peaceiris/actions-gh-pages@v3 |
| 280 | + with: |
| 281 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 282 | + publish_dir: ./docs |
| 283 | + cname: widgets.yourdomain.com |
0 commit comments