diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index e7c64f25..eee332f2 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -7,7 +7,15 @@ on: branches: [ main ] jobs: + cancel_previous: + runs-on: ubuntu-latest + steps: + - uses: styfle/cancel-workflow-action@0.9.1 + with: + workflow_id: ${{ github.event.workflow.id }} + build_and_test_spm_mac: + needs: cancel_previous runs-on: macos-11 steps: - uses: maxim-lobanov/setup-xcode@v1 @@ -25,6 +33,7 @@ jobs: run: swift test build_and_test_spm_linux: + needs: cancel_previous runs-on: ubuntu-latest steps: - uses: fwal/setup-swift@v1 @@ -42,6 +51,7 @@ jobs: run: swift test --enable-test-discovery build_and_test_ios: + needs: cancel_previous runs-on: macos-11 steps: - uses: maxim-lobanov/setup-xcode@v1 @@ -50,12 +60,20 @@ jobs: - uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/cache@v2 + with: + path: /Users/runner/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts + key: ${{ runner.os }}-spm-ios-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm-ios - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - run: xcodebuild -scheme Segment-Package test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' + build_and_test_tvos: + needs: cancel_previous runs-on: macos-11 steps: - uses: maxim-lobanov/setup-xcode@v1 @@ -64,12 +82,19 @@ jobs: - uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/cache@v2 + with: + path: /Users/runner/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts + key: ${{ runner.os }}-spm-tvos-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm-tvos - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - run: xcodebuild -scheme Segment-Package test -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' build_and_test_watchos: + needs: cancel_previous runs-on: macos-11 steps: - uses: maxim-lobanov/setup-xcode@v1 @@ -78,12 +103,19 @@ jobs: - uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/cache@v2 + with: + path: /Users/runner/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts + key: ${{ runner.os }}-spm-watchos-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm-watchos - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - run: xcodebuild -scheme Segment-Package test -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm' - build_examples: + build_and_test_examples: + needs: cancel_previous runs-on: macos-11 steps: - uses: maxim-lobanov/setup-xcode@v1 @@ -92,6 +124,12 @@ jobs: - uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/cache@v2 + with: + path: /Users/runner/Library/Developer/Xcode/DerivedData + key: ${{ runner.os }}-spm-examples-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm-examples - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} @@ -99,10 +137,6 @@ jobs: run: | cd Examples/apps/BasicExample xcodebuild -workspace "BasicExample.xcworkspace" -scheme "BasicExample" -sdk iphonesimulator - - name: build for ios simulator - run: | - cd Examples/apps/DestinationsExample - xcodebuild -workspace "DestinationsExample.xcworkspace" -scheme "DestinationsExample" -sdk iphonesimulator - name: build for ios simulator run: | cd Examples/apps/ObjCExample @@ -115,3 +149,28 @@ jobs: run: | cd Examples/apps/SegmentUIKitExample xcodebuild -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -destination 'platform=macOS,variant=Mac Catalyst' + + + build_and_test_dest_examples: + needs: cancel_previous + runs-on: macos-11 + steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '13.0' + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/cache@v2 + with: + path: /Users/runner/Library/Developer/Xcode/DerivedData + key: ${{ runner.os }}-spm-dest-example-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm-dest-example + - uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} + - name: build for ios simulator + run: | + cd Examples/apps/DestinationsExample + xcodebuild -workspace "DestinationsExample.xcworkspace" -scheme "DestinationsExample" -sdk iphonesimulator