From 9c0f32819e157e3fb40a8558f8cfeb8b2d6d72b3 Mon Sep 17 00:00:00 2001 From: Andrew Watt Date: Tue, 18 Jun 2024 22:47:59 -0700 Subject: [PATCH] loop over test schemes --- .github/workflows/swift.yaml | 31 ++----------------------- .github/workflows/test.sh | 44 ++++++++++++++++++++++++++++++++++++ project.yml | 22 ------------------ 3 files changed, 46 insertions(+), 51 deletions(-) create mode 100755 .github/workflows/test.sh diff --git a/.github/workflows/swift.yaml b/.github/workflows/swift.yaml index a9181a0f..3f433cac 100644 --- a/.github/workflows/swift.yaml +++ b/.github/workflows/swift.yaml @@ -85,35 +85,8 @@ jobs: - name: Switch Xcode run: sudo xcode-select -s /Applications/Xcode_${XCODE_VERSION}.app - - name: Install XcodeGen - run: brew install xcodegen - - - name: Generate Xcode project - run: xcodegen generate - - # Macros are only built for the compiler platform, so we cannot run macro tests on iOS. Instead - # we target the "Tests" scheme from project.yml which selectively includes all the other tests. - - name: Tests - iOS - run: | - xcodebuild \ - -project Workflow.xcodeproj \ - -scheme "Tests" \ - -destination "$IOS_DESTINATION" \ - -skipMacroValidation \ - test - - - name: Dump schemes - run: xcodebuild -list -project Workflow.xcodeproj - - # On macOS we can run all tests, including macro tests. - - name: Tests - macOS - run: | - xcodebuild \ - -project Workflow.xcodeproj \ - -scheme "Workflow-Package" \ - -destination "platform=macOS" \ - -skipMacroValidation \ - test + - name: Run Tests + run: .github/workflows/test.sh tutorial: runs-on: macos-latest diff --git a/.github/workflows/test.sh b/.github/workflows/test.sh new file mode 100755 index 00000000..e8613206 --- /dev/null +++ b/.github/workflows/test.sh @@ -0,0 +1,44 @@ +!#/bin/bash + +set -eux -o pipefail + +echo Dumping package information +swift package describe --type json > package.json +cat package.json + +echo Extracting test schemes +cat package.json | jq -r '.targets[] | select(.type == "test") | .name' > test_schemes.txt +cat test_schemes.txt + +echo loading vars +ALL_TEST_SCHEMES=$(cat test_schemes.txt) +echo $ALL_TEST_SCHEMES + +echo loading ios +which grep +grep --version +grep foo test_schemes.txt +grep Reactive test_schemes.txt +grep -v Macro test_schemes.txt + +echo now into the var +IOS_TEST_SCHEMES=$(grep -v Macro test_schemes.txt) +echo done + +# Macros are only built for the compiler platform, so we cannot run macro tests on iOS. +for TEST_SCHEME in $IOS_TEST_SCHEMES; do + xcodebuild \ + -scheme $TEST_SCHEME \ + -destination "$IOS_DESTINATION" \ + -skipMacroValidation \ + test +done + +# On macOS we can run all tests, including macro tests. +for TEST_SCHEME in $ALL_TEST_SCHEMES; do + xcodebuild \ + -scheme $TEST_SCHEME \ + -destination "platform=macOS" \ + -skipMacroValidation \ + test +done diff --git a/project.yml b/project.yml index 2e710b9d..bf06e088 100644 --- a/project.yml +++ b/project.yml @@ -22,28 +22,6 @@ targets: UILaunchScreen: UIColorName: "" - # This is a scheme for all tests except for macros. - Tests: - platform: iOS - type: bundle.unit-test - info: - path: TestingSupport/AppHost/App/Info.plist - scheme: - testTargets: - - package: Workflow/WorkflowCombineTestingTests - - package: Workflow/WorkflowCombineTests - - package: Workflow/WorkflowConcurrencyTestingTests - - package: Workflow/WorkflowConcurrencyTests - - package: Workflow/WorkflowReactiveSwiftTestingTests - - package: Workflow/WorkflowReactiveSwiftTests - - package: Workflow/WorkflowRxSwiftTestingTests - - package: Workflow/WorkflowRxSwiftTests - - package: Workflow/WorkflowSwiftUIExperimentalTests - - package: Workflow/WorkflowSwiftUITests - - package: Workflow/WorkflowTestingTests - - package: Workflow/WorkflowTests - - package: Workflow/WorkflowUITests - # to add app-hosted test targets: # ViewEnvironmentUI-Tests: