From 16d82a89a4d2a1a4dec54caee4cdd9e9ecf1f3a7 Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Sun, 7 Dec 2025 13:53:27 +0400 Subject: [PATCH] chore(ci): update workflow to run tests and build project --- .github/workflows/ci.yml | 209 ++++++++++++--------------------------- 1 file changed, 63 insertions(+), 146 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a607172..4198d8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,15 @@ -name: network-layer +name: "network-layer" on: push: branches: - main - - dev + paths: + - '.swiftlint.yml' + - ".github/workflows/**" + - "Package.swift" + - "Source/**" + - "Tests/**" pull_request: paths: - '.swiftlint.yml' @@ -13,8 +18,18 @@ on: - "Source/**" - "Tests/**" +permissions: + contents: read + +concurrency: + group: network-layer-${{ github.head_ref }} + cancel-in-progress: true + +env: + SCHEME_NAME: "NetworkLayer" + jobs: - macOS: + test-apple-platforms: name: ${{ matrix.name }} runs-on: ${{ matrix.runsOn }} env: @@ -24,141 +39,45 @@ jobs: fail-fast: false matrix: include: - - xcode: "Xcode_16.1" - runsOn: macOS-14 - name: "macOS 14, Xcode 16.1, Swift 6.0.2" - - xcode: "Xcode_15.4" - runsOn: macOS-14 - name: "macOS 14, Xcode 15.4, Swift 5.10" - - xcode: "Xcode_15.0" - runsOn: macos-13 - name: "macOS 13, Xcode 15.0, Swift 5.9.0" - - xcode: "Xcode_14.3.1" - runsOn: macos-13 - name: "macOS 13, Xcode 14.3.1, Swift 5.8.0" - steps: - - uses: actions/checkout@v4 - - name: ${{ matrix.name }} - run: xcodebuild test -scheme "NetworkLayer" -destination "platform=macOS" clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 - - name: Upload test coverage reports to Codecov - uses: space-code/oss-common-actions/.github/actions/upload_test_coverage_report@main - with: - scheme_name: NetworkLayer - filename: ${{ matrix.name }} - token: ${{ secrets.CODECOV_TOKEN }} + # macOS + - { platform: macOS, name: "macOS 26, Xcode 26.0, Swift 6.2.0", xcode: "Xcode_26.0.1", runsOn: macOS-26, destination: "platform=macOS" } + - { platform: macOS, name: "macOS 14, Xcode 16.1, Swift 6.0.2", xcode: "Xcode_16.1", runsOn: macOS-14, destination: "platform=macOS" } + - { platform: macOS, name: "macOS 14, Xcode 15.4, Swift 5.10", xcode: "Xcode_15.4", runsOn: macOS-14, destination: "platform=macOS" } - iOS: - name: ${{ matrix.name }} - runs-on: ${{ matrix.runsOn }} - env: - DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}.app/Contents/Developer" - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - include: - - destination: "OS=18.1,name=iPhone 16 Pro" - name: "iOS 18.1" - xcode: "Xcode_16.1" - runsOn: macOS-14 - - destination: "OS=17.5,name=iPhone 15 Pro" - name: "iOS 17.5" - xcode: "Xcode_15.4" - runsOn: macOS-14 - - destination: "OS=17.0.1,name=iPhone 14 Pro" - name: "iOS 17.0.1" - xcode: "Xcode_15.0" - runsOn: macos-13 - - destination: "OS=16.4,name=iPhone 14 Pro" - name: "iOS 16.4" - xcode: "Xcode_14.3.1" - runsOn: macos-13 - steps: - - uses: actions/checkout@v4 - - name: ${{ matrix.name }} - run: xcodebuild test -scheme "NetworkLayer" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 - - name: Upload test coverage reports to Codecov - uses: space-code/oss-common-actions/.github/actions/upload_test_coverage_report@main - with: - scheme_name: NetworkLayer - filename: ${{ matrix.name }} - token: ${{ secrets.CODECOV_TOKEN }} + # iOS + - { platform: iOS, name: "iOS 26.0, Xcode 26.0, Swift 6.2.0", xcode: "Xcode_26.0.1", runsOn: macOS-26, destination: "OS=26.0.1,name=iPhone 17 Pro" } + - { platform: iOS, name: "iOS 18.1", xcode: "Xcode_16.1", runsOn: macOS-14, destination: "OS=18.1,name=iPhone 16 Pro" } + - { platform: iOS, name: "iOS 17.4", xcode: "Xcode_15.3", runsOn: macOS-14, destination: "OS=17.4,name=iPhone 15 Pro" } - tvOS: - name: ${{ matrix.name }} - runs-on: ${{ matrix.runsOn }} - env: - DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}.app/Contents/Developer" - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - include: - - destination: "OS=18.1,name=Apple TV" - name: "tvOS 18.1" - xcode: "Xcode_16.1" - runsOn: macOS-14 - - destination: "OS=17.5,name=Apple TV" - name: "tvOS 17.5" - xcode: "Xcode_15.4" - runsOn: macOS-14 - - destination: "OS=17.0,name=Apple TV" - name: "tvOS 17.0" - xcode: "Xcode_15.0" - runsOn: macos-13 - - destination: "OS=16.4,name=Apple TV" - name: "tvOS 16.4" - xcode: "Xcode_14.3.1" - runsOn: macos-13 - steps: - - uses: actions/checkout@v4 - - name: ${{ matrix.name }} - run: xcodebuild test -scheme "NetworkLayer" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 - - name: Upload test coverage report to Codecov - uses: space-code/oss-common-actions/.github/actions/upload_test_coverage_report@main - with: - scheme_name: NetworkLayer - filename: ${{ matrix.name }} - token: ${{ secrets.CODECOV_TOKEN }} + # tvOS + - { platform: tvOS, name: "tvOS 26.0", xcode: "Xcode_26.0.1", runsOn: macOS-26, destination: "OS=26.0,name=Apple TV" } + - { platform: tvOS, name: "tvOS 18.1", xcode: "Xcode_16.1", runsOn: macOS-14, destination: "OS=18.1,name=Apple TV" } + - { platform: tvOS, name: "tvOS 17.4", xcode: "Xcode_15.3", runsOn: macOS-14, destination: "OS=17.4,name=Apple TV" } - watchOS: - name: ${{ matrix.name }} - runs-on: ${{ matrix.runsOn }} - env: - DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}.app/Contents/Developer" - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - include: - - destination: "OS=11.1,name=Apple Watch Series 10 (46mm)" - name: "watchOS 11.1" - xcode: "Xcode_16.1" - runsOn: macOS-14 - - destination: "OS=10.5,name=Apple Watch Series 9 (45mm)" - name: "watchOS 10.5" - xcode: "Xcode_15.4" - runsOn: macOS-14 - - destination: "OS=10.0,name=Apple Watch Series 9 (45mm)" - name: "watchOS 10.0" - xcode: "Xcode_15.0" - runsOn: macos-13 - - destination: "OS=9.4,name=Apple Watch Series 8 (45mm)" - name: "watchOS 9.4" - xcode: "Xcode_14.3.1" - runsOn: macos-13 + # watchOS + - { platform: watchOS, name: "watchOS 26.0", xcode: "Xcode_26.0.1", runsOn: macOS-26, destination: "OS=26.0,name=Apple Watch Ultra 3 (49mm)" } + - { platform: watchOS, name: "watchOS 11.1", xcode: "Xcode_16.1", runsOn: macOS-14, destination: "OS=11.1,name=Apple Watch Series 10 (46mm)" } + - { platform: watchOS, name: "watchOS 10.5", xcode: "Xcode_15.3", runsOn: macOS-14, destination: "OS=10.5,name=Apple Watch Series 9 (45mm)" } + - { platform: watchOS, name: "watchOS 10.4", xcode: "Xcode_15.3", runsOn: macOS-14, destination: "OS=10.4,name=Apple Watch Series 9 (45mm)" } steps: - - uses: actions/checkout@v4 - - name: ${{ matrix.name }} - run: xcodebuild test -scheme "NetworkLayer" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 - - name: Upload test coverage reports to Codecov + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests - ${{ matrix.name }} + run: | + xcodebuild test \ + -scheme "${{ env.SCHEME_NAME }}" \ + -destination "${{ matrix.destination }}" \ + -enableCodeCoverage YES \ + -resultBundlePath "test_output/${{ matrix.name }}.xcresult" \ + clean || exit 1 + - name: Upload test coverage to Codecov uses: space-code/oss-common-actions/.github/actions/upload_test_coverage_report@main with: - scheme_name: NetworkLayer + scheme_name: ${{ env.SCHEME_NAME }} filename: ${{ matrix.name }} token: ${{ secrets.CODECOV_TOKEN }} - spm: + spm-build: name: ${{ matrix.name }} runs-on: ${{ matrix.runsOn }} env: @@ -168,22 +87,18 @@ jobs: fail-fast: false matrix: include: - - name: "macOS 14, SPM 6.0.2 Test" - xcode: "Xcode_16.1" - runsOn: macOS-14 - - name: "macOS 14, SPM 5.9.0 Test" - xcode: "Xcode_15.0" - runsOn: macos-14 - - name: "macOS 13, SPM 5.8.1 Test" - xcode: "Xcode_14.3.1" - runsOn: macos-13 + - { name: "macOS 26, SPM 6.2.0", xcode: "Xcode_26.0.1", runsOn: macOS-26 } + - { name: "macOS 15, SPM 6.0.2", xcode: "Xcode_16.0", runsOn: macOS-15 } + - { name: "macOS 14, SPM 6.0.2", xcode: "Xcode_16.1", runsOn: macOS-14 } + - { name: "macOS 14, SPM 5.10.0", xcode: "Xcode_15.3", runsOn: macOS-14 } steps: - - uses: actions/checkout@v4 - - name: ${{ matrix.name }} + - name: Checkout code + uses: actions/checkout@v4 + - name: Build with Swift Package Manager - ${{ matrix.name }} run: swift build -c release --target NetworkLayer merge-test-reports: - needs: [iOS, macOS, watchOS, tvOS] + needs: test-apple-platforms runs-on: macos-13 steps: - name: Download artifacts @@ -191,22 +106,24 @@ jobs: with: path: test_output - run: xcrun xcresulttool merge test_output/**/*.xcresult --output-path test_output/final/final.xcresult - - name: Upload Merged Artifact + - name: Upload merged test results uses: actions/upload-artifact@v4 with: - name: MergedResult + name: MergedTestResults path: test_output/final + retention-days: 30 discover-typos: name: Discover Typos - runs-on: macOS-13 + runs-on: macos-13 env: DEVELOPER_DIR: /Applications/Xcode_14.1.app/Contents/Developer steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - name: Discover typos run: | export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.11/bin" python3 -m pip install --upgrade pip python3 -m pip install codespell - codespell --ignore-words-list="hart,inout,msdos,sur" --skip="./.build/*,./.git/*" + codespell --ignore-words-list="hart,inout,msdos,sur" --skip="./.build/*,./.git/*" \ No newline at end of file