Skip to content

Commit

Permalink
Write a script for merging test results from various platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
ns-vasilev committed Jan 2, 2024
1 parent 0154406 commit 006329b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 26 deletions.
57 changes: 33 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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 }}
Expand All @@ -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/[email protected]
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 }}
Expand All @@ -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/[email protected]
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 }}
Expand Down Expand Up @@ -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/[email protected]
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 }}
Expand All @@ -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/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
xcode: true
xcode_archive_path: test_output/final.xcresult

# Beta:
# name: ${{ matrix.name }}
# runs-on: firebreak
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
merge_test_results:
sh scripts/merge_test_results.sh

.PHONY: all bootstrap hook mint lint fmt generate setup_build_tools merge_test_results
6 changes: 5 additions & 1 deletion Tests/IntegrationTests/Tests/FlareTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
4 changes: 4 additions & 0 deletions scripts/merge_test_results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

files=$(find . -name '*.xcresult')
xcrun xcresulttool merge $files --output-path final.xcresult

0 comments on commit 006329b

Please sign in to comment.