From 603db2425ec133d2b1656ea212e17cd40f8a245a Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Wed, 3 Apr 2024 17:32:57 -0300 Subject: [PATCH] ci: break into multiple workflows (#323) * ci: separate into multiple workflows * ci: run auth workflow if yml changes * ci: platform in quotes * ci: typo * ci: add test plan for all targets * ci: fix concurrency group * chore: run all tests --- .github/workflows/auth.yml | 42 +++++++++++ .github/workflows/ci.yml | 70 ------------------ .github/workflows/functions.yml | 42 +++++++++++ .github/workflows/integration-tests.yml | 29 ++++++++ .github/workflows/postgrest.yml | 42 +++++++++++ .github/workflows/realtime.yml | 42 +++++++++++ .github/workflows/storage.yml | 42 +++++++++++ .github/workflows/supabase.yml | 42 +++++++++++ .../xcshareddata/xcschemes/Auth.xcscheme | 72 +++++++++++++++++++ .../xcshareddata/xcschemes/Functions.xcscheme | 9 ++- .../xcshareddata/xcschemes/PostgREST.xcscheme | 9 ++- .../xcshareddata/xcschemes/Realtime.xcscheme | 9 ++- .../xcshareddata/xcschemes/Storage.xcscheme | 9 ++- .../xcshareddata/xcschemes/Supabase.xcscheme | 5 +- AllTests.xctestplan | 66 +++++++++++++++++ Auth.xctestplan | 24 +++++++ Functions.xctestplan | 23 ++++++ Makefile | 20 ++++-- PostgREST.xctestplan | 24 +++++++ Realtime.xctestplan | 24 +++++++ Storage.xctestplan | 24 +++++++ Supabase.xctestplan | 44 +----------- .../contents.xcworkspacedata | 17 ++++- 23 files changed, 601 insertions(+), 129 deletions(-) create mode 100644 .github/workflows/auth.yml delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/functions.yml create mode 100644 .github/workflows/integration-tests.yml create mode 100644 .github/workflows/postgrest.yml create mode 100644 .github/workflows/realtime.yml create mode 100644 .github/workflows/storage.yml create mode 100644 .github/workflows/supabase.yml create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/Auth.xcscheme create mode 100644 AllTests.xctestplan create mode 100644 Auth.xctestplan create mode 100644 Functions.xctestplan create mode 100644 PostgREST.xctestplan create mode 100644 Realtime.xctestplan create mode 100644 Storage.xctestplan diff --git a/.github/workflows/auth.yml b/.github/workflows/auth.yml new file mode 100644 index 00000000..89539307 --- /dev/null +++ b/.github/workflows/auth.yml @@ -0,0 +1,42 @@ +name: Auth + +on: + pull_request: + paths: + - "Sources/Auth/**" + - "Tests/Auth/**" + - ".github/workflows/auth.yml" + push: + branches: + - main + paths: + - "Sources/Auth/**" + - "Tests/Auth/**" + - ".github/workflows/auth.yml" + +concurrency: + group: auth-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Test Auth + strategy: + fail-fast: false + matrix: + platform: + - macOS + - macOS,variant=Mac Catalyst + - iOS Simulator,name=iPhone 15 Pro + - tvOS Simulator,name=Apple TV + - watchOS Simulator,name=Apple Watch Series 9 (41mm) + - visionOS Simulator,name=Any visionOS Simulator Device + runs-on: macos-14 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Select Xcode 15.3 + run: sudo xcode-select -s /Applications/Xcode_15.3.app + - name: Run tests + run: PLATFORM="${{ matrix.platform }}" SCHEME=Auth make test-library diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 815748d5..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: CI - -on: - push: - branches: - - main - pull_request: - branches: - - "*" - workflow_dispatch: - -concurrency: - group: ci-${{ github.ref }} - cancel-in-progress: true - -jobs: - library-darwin: - runs-on: macos-14 - name: Test Library (Darwin) - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Select Xcode 15.3 - run: sudo xcode-select -s /Applications/Xcode_15.3.app - - uses: actions/cache@v3 - with: - path: /tmp/derived-data - key: derived-data-cache- - - name: Run tests - run: make test-library - - library-evolution: - name: Library (evolution, Darwin) - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - - name: Select Xcode 15.3 - run: sudo xcode-select -s /Applications/Xcode_15.3.app - - name: Build for library evolution - run: make build-for-library-evolution - - integration-tests: - runs-on: macos-14 - name: Integration Tests - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Select Xcode 15.3 - run: sudo xcode-select -s /Applications/Xcode_15.3.app - - name: Run tests - run: make test-integration - env: - SUPABASE_URL: ${{ secrets.SUPABASE_URL }} - SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} - SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }} - - - examples: - runs-on: macos-14 - name: Build Examples - steps: - - uses: actions/checkout@v3 - - name: Select Xcode 15.3 - run: sudo xcode-select -s /Applications/Xcode_15.3.app - - name: Prepare Examples Project - run: cp Examples/Examples/_Secrets.swift Examples/Examples/Secrets.swift - - name: Build examples - run: make build-examples diff --git a/.github/workflows/functions.yml b/.github/workflows/functions.yml new file mode 100644 index 00000000..ce386d45 --- /dev/null +++ b/.github/workflows/functions.yml @@ -0,0 +1,42 @@ +name: Functions + +on: + pull_request: + paths: + - "Sources/Functions/**" + - "Tests/Functions/**" + - ".github/workflows/functions.yml" + push: + branches: + - main + paths: + - "Sources/Functions/**" + - "Tests/Functions/**" + - ".github/workflows/functions.yml" + +concurrency: + group: functions-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Test Functions + strategy: + fail-fast: false + matrix: + platform: + - macOS + - macOS,variant=Mac Catalyst + - iOS Simulator,name=iPhone 15 Pro + - tvOS Simulator,name=Apple TV + - watchOS Simulator,name=Apple Watch Series 9 (41mm) + - visionOS Simulator,name=Any visionOS Simulator Device + runs-on: macos-14 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Select Xcode 15.3 + run: sudo xcode-select -s /Applications/Xcode_15.3.app + - name: Run tests + run: PLATFORM="${{ matrix.platform }}" SCHEME=Functions make test-library diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 00000000..a8ee1893 --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,29 @@ +name: Integration Tests + +on: + push: + branches: + - main + - release/* + workflow_dispatch: + +concurrency: + group: integration-tests-${{ github.ref }} + cancel-in-progress: true + +jobs: + integration-tests: + runs-on: macos-14 + name: Integration Tests + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Select Xcode 15.3 + run: sudo xcode-select -s /Applications/Xcode_15.3.app + - name: Run tests + run: make test-integration + env: + SUPABASE_URL: ${{ secrets.SUPABASE_URL }} + SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} + SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }} diff --git a/.github/workflows/postgrest.yml b/.github/workflows/postgrest.yml new file mode 100644 index 00000000..0a545118 --- /dev/null +++ b/.github/workflows/postgrest.yml @@ -0,0 +1,42 @@ +name: PostgREST + +on: + pull_request: + paths: + - "Sources/PostgREST/**" + - "Tests/PostgREST/**" + - ".github/workflows/postgrest.yml" + push: + branches: + - main + paths: + - "Sources/PostgREST/**" + - "Tests/PostgREST/**" + - ".github/workflows/postgrest.yml" + +concurrency: + group: postgrest-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Test PostgREST + strategy: + fail-fast: false + matrix: + platform: + - macOS + - macOS,variant=Mac Catalyst + - iOS Simulator,name=iPhone 15 Pro + - tvOS Simulator,name=Apple TV + - watchOS Simulator,name=Apple Watch Series 9 (41mm) + - visionOS Simulator,name=Any visionOS Simulator Device + runs-on: macos-14 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Select Xcode 15.3 + run: sudo xcode-select -s /Applications/Xcode_15.3.app + - name: Run tests + run: PLATFORM="${{ matrix.platform }}" SCHEME=PostgREST make test-library diff --git a/.github/workflows/realtime.yml b/.github/workflows/realtime.yml new file mode 100644 index 00000000..86db56bd --- /dev/null +++ b/.github/workflows/realtime.yml @@ -0,0 +1,42 @@ +name: Realtime + +on: + pull_request: + paths: + - "Sources/Realtime/**" + - "Tests/Realtime/**" + - ".github/workflows/realtime.yml" + push: + branches: + - main + paths: + - "Sources/Realtime/**" + - "Tests/Realtime/**" + - ".github/workflows/realtime.yml" + +concurrency: + group: realtime-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Test Realtime + strategy: + fail-fast: false + matrix: + platform: + - macOS + - macOS,variant=Mac Catalyst + - iOS Simulator,name=iPhone 15 Pro + - tvOS Simulator,name=Apple TV + - watchOS Simulator,name=Apple Watch Series 9 (41mm) + - visionOS Simulator,name=Any visionOS Simulator Device + runs-on: macos-14 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Select Xcode 15.3 + run: sudo xcode-select -s /Applications/Xcode_15.3.app + - name: Run tests + run: PLATFORM="${{ matrix.platform }}" SCHEME=Realtime make test-library diff --git a/.github/workflows/storage.yml b/.github/workflows/storage.yml new file mode 100644 index 00000000..2c4a50db --- /dev/null +++ b/.github/workflows/storage.yml @@ -0,0 +1,42 @@ +name: Storage + +on: + pull_request: + paths: + - "Sources/Storage/**" + - "Tests/Storage/**" + - ".github/workflows/storage.yml" + push: + branches: + - main + paths: + - "Sources/Storage/**" + - "Tests/Storage/**" + - ".github/workflows/storage.yml" + +concurrency: + group: storage-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Test Storage + strategy: + fail-fast: false + matrix: + platform: + - macOS + - macOS,variant=Mac Catalyst + - iOS Simulator,name=iPhone 15 Pro + - tvOS Simulator,name=Apple TV + - watchOS Simulator,name=Apple Watch Series 9 (41mm) + - visionOS Simulator,name=Any visionOS Simulator Device + runs-on: macos-14 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Select Xcode 15.3 + run: sudo xcode-select -s /Applications/Xcode_15.3.app + - name: Run tests + run: PLATFORM="${{ matrix.platform }}" SCHEME=Storage make test-library diff --git a/.github/workflows/supabase.yml b/.github/workflows/supabase.yml new file mode 100644 index 00000000..bf40b097 --- /dev/null +++ b/.github/workflows/supabase.yml @@ -0,0 +1,42 @@ +name: Supabase + +on: + pull_request: + paths: + - "Sources/Supabase/**" + - "Tests/Supabase/**" + - ".github/workflows/supabase.yml" + push: + branches: + - main + paths: + - "Sources/Supabase/**" + - "Tests/Supabase/**" + - ".github/workflows/supabase.yml" + +concurrency: + group: supabase-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Test Supabase + strategy: + fail-fast: false + matrix: + platform: + - macOS + - macOS,variant=Mac Catalyst + - iOS Simulator,name=iPhone 15 Pro + - tvOS Simulator,name=Apple TV + - watchOS Simulator,name=Apple Watch Series 9 (41mm) + - visionOS Simulator,name=Any visionOS Simulator Device + runs-on: macos-14 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Select Xcode 15.3 + run: sudo xcode-select -s /Applications/Xcode_15.3.app + - name: Run tests + run: PLATFORM="${{ matrix.platform }}" SCHEME=Supabase make test-library diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Auth.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Auth.xcscheme new file mode 100644 index 00000000..8392cfcb --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/Auth.xcscheme @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Functions.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Functions.xcscheme index 59d7376a..f76d4c08 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/Functions.xcscheme +++ b/.swiftpm/xcode/xcshareddata/xcschemes/Functions.xcscheme @@ -26,8 +26,13 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES" - shouldAutocreateTestPlan = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES"> + + + + + shouldUseLaunchSchemeArgsEnv = "YES"> + + + + + shouldUseLaunchSchemeArgsEnv = "YES"> + + + + + shouldUseLaunchSchemeArgsEnv = "YES"> + + + + + + + reference = "container:AllTests.xctestplan"> diff --git a/AllTests.xctestplan b/AllTests.xctestplan new file mode 100644 index 00000000..adf11dd5 --- /dev/null +++ b/AllTests.xctestplan @@ -0,0 +1,66 @@ +{ + "configurations" : [ + { + "id" : "5F632059-FF26-463E-B598-A1902519AB3F", + "name" : "Configuration 1", + "options" : { + + } + } + ], + "defaultOptions" : { + + }, + "testTargets" : [ + { + "target" : { + "containerPath" : "container:", + "identifier" : "FunctionsTests", + "name" : "FunctionsTests" + } + }, + { + "target" : { + "containerPath" : "container:", + "identifier" : "PostgRESTTests", + "name" : "PostgRESTTests" + } + }, + { + "target" : { + "containerPath" : "container:", + "identifier" : "RealtimeTests", + "name" : "RealtimeTests" + } + }, + { + "target" : { + "containerPath" : "container:", + "identifier" : "StorageTests", + "name" : "StorageTests" + } + }, + { + "target" : { + "containerPath" : "container:", + "identifier" : "SupabaseTests", + "name" : "SupabaseTests" + } + }, + { + "target" : { + "containerPath" : "container:", + "identifier" : "AuthTests", + "name" : "AuthTests" + } + }, + { + "target" : { + "containerPath" : "container:", + "identifier" : "_HelpersTests", + "name" : "_HelpersTests" + } + } + ], + "version" : 1 +} diff --git a/Auth.xctestplan b/Auth.xctestplan new file mode 100644 index 00000000..be833ec2 --- /dev/null +++ b/Auth.xctestplan @@ -0,0 +1,24 @@ +{ + "configurations" : [ + { + "id" : "CB7AE2C5-B36E-4571-9927-9EE60FC5BB1A", + "name" : "Test Scheme Action", + "options" : { + + } + } + ], + "defaultOptions" : { + "codeCoverage" : false + }, + "testTargets" : [ + { + "target" : { + "containerPath" : "container:", + "identifier" : "AuthTests", + "name" : "AuthTests" + } + } + ], + "version" : 1 +} diff --git a/Functions.xctestplan b/Functions.xctestplan new file mode 100644 index 00000000..eb0bb4ab --- /dev/null +++ b/Functions.xctestplan @@ -0,0 +1,23 @@ +{ + "configurations" : [ + { + "id" : "C2968060-7062-4A69-B936-4DF46F4A933D", + "name" : "Test Scheme Action", + "options" : { + + } + } + ], + "defaultOptions" : { + }, + "testTargets" : [ + { + "target" : { + "containerPath" : "container:", + "identifier" : "FunctionsTests", + "name" : "FunctionsTests" + } + } + ], + "version" : 1 +} diff --git a/Makefile b/Makefile index cf4f1a0a..982af90e 100644 --- a/Makefile +++ b/Makefile @@ -4,21 +4,29 @@ PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst PLATFORM_TVOS = tvOS Simulator,name=Apple TV PLATFORM_WATCHOS = watchOS Simulator,name=Apple Watch Series 9 (41mm) +SCHEME ?= Supabase +PLATFORM ?= iOS Simulator,name=iPhone 15 Pro + set-env: @source scripts/setenv.sh > Tests/IntegrationTests/Environment.swift -test-all: test-library test-linux +test-all: set-env + set -o pipefail && \ + xcodebuild test \ + -skipMacroValidation \ + -workspace supabase-swift.xcworkspace \ + -scheme "$(SCHEME)" \ + -testPlan AllTests \ + -destination platform="$(PLATFORM)" | xcpretty test-library: set-env - for platform in "$(PLATFORM_IOS)" "$(PLATFORM_MACOS)" "$(PLATFORM_MAC_CATALYST)" "$(PLATFORM_TVOS)" "$(PLATFORM_WATCHOS)"; do \ - set -o pipefail && \ + set -o pipefail && \ xcodebuild test \ -skipMacroValidation \ -workspace supabase-swift.xcworkspace \ - -scheme Supabase \ + -scheme "$(SCHEME)" \ -derivedDataPath /tmp/derived-data \ - -destination platform="$$platform" | xcpretty; \ - done; + -destination platform="$(PLATFORM)" | xcpretty test-integration: set-env @set -o pipefail && \ diff --git a/PostgREST.xctestplan b/PostgREST.xctestplan new file mode 100644 index 00000000..efcfbfcd --- /dev/null +++ b/PostgREST.xctestplan @@ -0,0 +1,24 @@ +{ + "configurations" : [ + { + "id" : "B9D59B72-C47A-432C-80B7-898C5D95FC0D", + "name" : "Configuration 1", + "options" : { + + } + } + ], + "defaultOptions" : { + + }, + "testTargets" : [ + { + "target" : { + "containerPath" : "container:", + "identifier" : "PostgRESTTests", + "name" : "PostgRESTTests" + } + } + ], + "version" : 1 +} diff --git a/Realtime.xctestplan b/Realtime.xctestplan new file mode 100644 index 00000000..a4102cb9 --- /dev/null +++ b/Realtime.xctestplan @@ -0,0 +1,24 @@ +{ + "configurations" : [ + { + "id" : "6C13CD34-2158-4CD9-A3C5-F634B9026E15", + "name" : "Configuration 1", + "options" : { + + } + } + ], + "defaultOptions" : { + + }, + "testTargets" : [ + { + "target" : { + "containerPath" : "container:", + "identifier" : "RealtimeTests", + "name" : "RealtimeTests" + } + } + ], + "version" : 1 +} diff --git a/Storage.xctestplan b/Storage.xctestplan new file mode 100644 index 00000000..d821caea --- /dev/null +++ b/Storage.xctestplan @@ -0,0 +1,24 @@ +{ + "configurations" : [ + { + "id" : "79A4DDA5-0CB7-40BC-A6AF-39E351546C2B", + "name" : "Configuration 1", + "options" : { + + } + } + ], + "defaultOptions" : { + + }, + "testTargets" : [ + { + "target" : { + "containerPath" : "container:", + "identifier" : "StorageTests", + "name" : "StorageTests" + } + } + ], + "version" : 1 +} diff --git a/Supabase.xctestplan b/Supabase.xctestplan index adf11dd5..26944b6a 100644 --- a/Supabase.xctestplan +++ b/Supabase.xctestplan @@ -1,7 +1,7 @@ { "configurations" : [ { - "id" : "5F632059-FF26-463E-B598-A1902519AB3F", + "id" : "45505B3F-281D-4398-B92C-A63746C756E0", "name" : "Configuration 1", "options" : { @@ -12,54 +12,12 @@ }, "testTargets" : [ - { - "target" : { - "containerPath" : "container:", - "identifier" : "FunctionsTests", - "name" : "FunctionsTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "PostgRESTTests", - "name" : "PostgRESTTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "RealtimeTests", - "name" : "RealtimeTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "StorageTests", - "name" : "StorageTests" - } - }, { "target" : { "containerPath" : "container:", "identifier" : "SupabaseTests", "name" : "SupabaseTests" } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "AuthTests", - "name" : "AuthTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "_HelpersTests", - "name" : "_HelpersTests" - } } ], "version" : 1 diff --git a/supabase-swift.xcworkspace/contents.xcworkspacedata b/supabase-swift.xcworkspace/contents.xcworkspacedata index 2ee9fb56..fce89c57 100644 --- a/supabase-swift.xcworkspace/contents.xcworkspacedata +++ b/supabase-swift.xcworkspace/contents.xcworkspacedata @@ -8,9 +8,24 @@ location = "container:Examples/Examples.xcodeproj"> + location = "group:/Users/guilherme/src/github.com/supabase-community/supabase-swift/AllTests.xctestplan"> + + + + + + + + + +