From 006329b8767da33649b6939314656c771dffe4ca Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Sun, 31 Dec 2023 17:00:37 +0100 Subject: [PATCH] Write a script for merging test results from various platforms --- .github/workflows/ci.yml | 57 +++++++++++-------- Makefile | 5 +- Tests/IntegrationTests/Tests/FlareTests.swift | 6 +- scripts/merge_test_results.sh | 4 ++ 4 files changed, 46 insertions(+), 26 deletions(-) create mode 100755 scripts/merge_test_results.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e4d7f1e6..3fd382c65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,13 +49,11 @@ jobs: steps: - uses: actions/checkout@v3 - name: ${{ matrix.name }} - run: xcodebuild test -scheme "Flare" -destination "platform=macOS" clean -enableCodeCoverage YES -resultBundlePath "./macos.xcresult" || exit 1 - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3.1.0 + run: xcodebuild test -scheme "Flare" -destination "platform=macOS" clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 + - uses: actions/upload-artifact@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - xcode: true - xcode_archive_path: "./macos.xcresult" + name: ${{ matrix.name }} + path: test_output iOS: name: ${{ matrix.name }} @@ -82,13 +80,11 @@ jobs: - name: Generate project run: make generate - name: ${{ matrix.name }} - run: xcodebuild test -scheme "Flare" -destination "${{ matrix.destination }}" -testPlan AllTests clean -enableCodeCoverage YES -resultBundlePath "./iphonesimulator.xcresult" || exit 1 - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3.1.0 + run: xcodebuild test -scheme "Flare" -destination "${{ matrix.destination }}" -testPlan AllTests clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 + - uses: actions/upload-artifact@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - xcode: true - xcode_archive_path: "./iphonesimulator.xcresult" + name: ${{ matrix.name }} + path: test_output tvOS: name: ${{ matrix.name }} @@ -115,13 +111,11 @@ jobs: - name: Generate project run: make generate - name: ${{ matrix.name }} - run: xcodebuild test -scheme "Flare" -destination "${{ matrix.destination }}" -testPlan AllTests clean -enableCodeCoverage YES -resultBundlePath "./appletvsimulator.xcresult" || exit 1 - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3.1.0 + run: xcodebuild test -scheme "Flare" -destination "${{ matrix.destination }}" -testPlan AllTests clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 + - uses: actions/upload-artifact@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - xcode: true - xcode_archive_path: "./appletvsimulator.xcresult" + name: ${{ matrix.name }} + path: test_output watchOS: name: ${{ matrix.name }} @@ -152,13 +146,11 @@ jobs: - name: Generate project run: make generate - name: ${{ matrix.name }} - run: xcodebuild test -scheme "Flare" -destination "${{ matrix.destination }}" -testPlan UnitTests clean -enableCodeCoverage YES -resultBundlePath "./watchsimulator.xcresult" || exit 1 - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3.1.0 + run: xcodebuild test -scheme "Flare" -destination "${{ matrix.destination }}" -testPlan UnitTests clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 + - uses: actions/upload-artifact@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - xcode: true - xcode_archive_path: "./watchsimulator.xcresult" + name: ${{ matrix.name }} + path: test_output spm: name: ${{ matrix.name }} @@ -181,6 +173,23 @@ jobs: - name: ${{ matrix.name }} run: swift build -c release --target Flare + upload-to-codecov: + needs: [iOS, macOS, watchOS, tvOS] + runs-on: macos-13 + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: test_output + - run: make merge_test_results + # - run: xcrun xcresulttool merge test_output/**/*.xcresult --output-path test_output/final.xcresult + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3.1.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} + xcode: true + xcode_archive_path: test_output/final.xcresult + # Beta: # name: ${{ matrix.name }} # runs-on: firebreak diff --git a/Makefile b/Makefile index f11937816..0bb57cd21 100644 --- a/Makefile +++ b/Makefile @@ -22,4 +22,7 @@ generate: setup_build_tools: sh scripts/setup_build_tools.sh -.PHONY: all bootstrap hook mint lint fmt generate setup_build_tools \ No newline at end of file +merge_test_results: + sh scripts/merge_test_results.sh + +.PHONY: all bootstrap hook mint lint fmt generate setup_build_tools merge_test_results \ No newline at end of file diff --git a/Tests/IntegrationTests/Tests/FlareTests.swift b/Tests/IntegrationTests/Tests/FlareTests.swift index 6c7657ab1..c3ff08793 100644 --- a/Tests/IntegrationTests/Tests/FlareTests.swift +++ b/Tests/IntegrationTests/Tests/FlareTests.swift @@ -139,7 +139,11 @@ final class FlareTests: StoreSessionTestCase { } // then - wait(for: [expectation], timeout: .second) + #if swift(>=5.9) + await fulfillment(of: [expectation]) + #else + wait(for: [expectation], timeout: .second) + #endif } } diff --git a/scripts/merge_test_results.sh b/scripts/merge_test_results.sh new file mode 100755 index 000000000..6f6501355 --- /dev/null +++ b/scripts/merge_test_results.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +files=$(find . -name '*.xcresult') +xcrun xcresulttool merge $files --output-path final.xcresult \ No newline at end of file