From 3adc5af7a2e94000ae5e0e0caf2fc5166f8f36b3 Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Thu, 5 Oct 2023 00:26:10 +0900 Subject: [PATCH 1/9] cache DerivedData --- .github/workflows/ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2a1227..2619dc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,17 @@ jobs: ${{ runner.os }}-spm-${{ env.cache-name }}- ${{ runner.os }}-spm- ${{ runner.os }}- + - name: Cache DerivedData + uses: actions/cache@v3 + with: + path: | + DerivedData + Demo/DerivedData + key: ${{ runner.os }}-xcode-derived-data-${{ hashFiles('**/Package.swift') }} + restore-keys: | + ${{ runner.os }}-xcode-derived-data-${{ env.cache-name }}- + ${{ runner.os }}-xcode-derived-data- + ${{ runner.os }}- - name: Disable SwiftLint Plugin run: sed -i -e 's/.*SwiftLint.*//g' Package.swift - name: test via SwiftPM @@ -56,6 +67,7 @@ jobs: -enableCodeCoverage YES \ -scheme "$(xcrun --sdk macosx xcodebuild -list -json | jq -rc '.workspace.schemes[] | select(. | startswith("BuildConfig"))')" \ -destination "platform=macOS" \ + -derivedDataPath 'DerivedData' \ -clonedSourcePackagesDirPath '.build/SourcePackages' \ -resultBundlePath 'test_output/BuildConfig.swift.xcresult' \ clean test | xcpretty @@ -71,6 +83,7 @@ jobs: -project "${PROJECT_PATH}" \ -scheme "$(xcrun --sdk macosx xcodebuild -project "${PROJECT_PATH}" -list -json | jq -rc '.project.schemes[] | select(. | contains("Demo"))')" \ -destination 'platform=iOS Simulator,name=iPhone 14 Pro' \ + -derivedDataPath 'Demo/DerivedData' \ -clonedSourcePackagesDirPath 'Demo/.build/SourcePackages' \ -resultBundlePath 'test_output/BuildConfigDemo.xcresult' \ clean test | xcpretty From 2c0db0234eb3212c75f9052a6fd6a59730a38e82 Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Thu, 5 Oct 2023 01:04:14 +0900 Subject: [PATCH 2/9] extract commands to shell scripts --- .github/workflows/ci.yml | 26 ++------------------------ Makefile | 20 ++++++++++++-------- scripts/test.sh | 20 ++++++++++++++++++++ scripts/test_demo.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 32 deletions(-) create mode 100755 scripts/test.sh create mode 100755 scripts/test_demo.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2619dc5..33d826d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,32 +61,10 @@ jobs: - name: test via SwiftPM run: set -o pipefail && swift test - name: test via xcodebuild - run: | - set -o pipefail && \ - xcrun --sdk macosx xcodebuild \ - -enableCodeCoverage YES \ - -scheme "$(xcrun --sdk macosx xcodebuild -list -json | jq -rc '.workspace.schemes[] | select(. | startswith("BuildConfig"))')" \ - -destination "platform=macOS" \ - -derivedDataPath 'DerivedData' \ - -clonedSourcePackagesDirPath '.build/SourcePackages' \ - -resultBundlePath 'test_output/BuildConfig.swift.xcresult' \ - clean test | xcpretty + run: ./scripts/test.sh - name: test DemoApp if: success() || failure() - run: | - set -o pipefail && \ - xcrun --sdk macosx swift run --package-path Demo/Tools xcodegen --spec Demo/project.yml && \ - PROJECT_PATH=$(find Demo -depth 1 -name '*.xcodeproj' | head -n 1) && \ - xcrun --sdk macosx xcodebuild \ - -skipPackagePluginValidation \ - -enableCodeCoverage YES \ - -project "${PROJECT_PATH}" \ - -scheme "$(xcrun --sdk macosx xcodebuild -project "${PROJECT_PATH}" -list -json | jq -rc '.project.schemes[] | select(. | contains("Demo"))')" \ - -destination 'platform=iOS Simulator,name=iPhone 14 Pro' \ - -derivedDataPath 'Demo/DerivedData' \ - -clonedSourcePackagesDirPath 'Demo/.build/SourcePackages' \ - -resultBundlePath 'test_output/BuildConfigDemo.xcresult' \ - clean test | xcpretty + run: ./scripts/test_demo.sh - uses: kishikawakatsumi/xcresulttool@v1 with: path: | diff --git a/Makefile b/Makefile index aa1c26c..0f93b6d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ executable_name = buildconfigswift -.PHONY: clean build test release lint format +.SILENT: + +.PHONY: clean build test release lint format demo_app_init demo_test demo default: clean build @@ -15,22 +17,24 @@ build: swift build test: - swift test + ./scripts/test.sh release: - @scripts/release.sh $(executable_name) + scripts/release.sh $(executable_name) lint: - @swift run swiftlint + swift run swiftlint format: - @swift run swiftlint --fix + swift run swiftlint --fix demo_app_init: - @scripts/copy-lint-config.sh && \ + scripts/copy-lint-config.sh && \ cd Demo && \ xcrun --sdk macosx swift run -c release --package-path Tools xcodegen -.PHONY: demo demo: demo_app_init - @xed Demo/BuildConfigSwiftDemo.xcodeproj + xed Demo/BuildConfigSwiftDemo.xcodeproj + +demo_test: + ./scripts/test_demo.sh diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..d8607e0 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -o pipefail + +XCRESULT_PATH='test_output/BuildConfig.swift.xcresult' + +if [[ -e "$XCRESULT_PATH" ]]; then + rm -rf "$XCRESULT_PATH" +fi + +SCHEME="$(xcrun --sdk macosx xcodebuild -list -json | jq -rc '.workspace.schemes[] | select(. | startswith("BuildConfig"))')" + +xcrun --sdk macosx xcodebuild \ + -enableCodeCoverage YES \ + -scheme "${SCHEME}" \ + -destination "platform=macOS" \ + -derivedDataPath 'DerivedData' \ + -clonedSourcePackagesDirPath '.build/SourcePackages' \ + -resultBundlePath "$XCRESULT_PATH" \ + clean test | xcpretty diff --git a/scripts/test_demo.sh b/scripts/test_demo.sh new file mode 100755 index 0000000..dc714c0 --- /dev/null +++ b/scripts/test_demo.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -o pipefail + +XCRESULT_PATH='test_output/BuildConfigDemo.xcresult' + +if [[ -e "$XCRESULT_PATH" ]]; then + rm -rf "$XCRESULT_PATH" +fi + +if [[ "$(find Demo -depth 1 -name '*.xcodeproj')" == '' ]]; then + $(dirname $0)/copy-lint-config.sh + xcrun --sdk macosx swift run --package-path Demo/Tools xcodegen --spec Demo/project.yml +fi + +PROJECT_PATH=$(find Demo -depth 1 -name '*.xcodeproj' | head -n 1) +SCHEME="$(xcrun --sdk macosx xcodebuild -project "${PROJECT_PATH}" -list -json | jq -rc '.project.schemes[] | select(. | contains("Demo"))')" +xcrun --sdk macosx xcodebuild \ + -skipPackagePluginValidation \ + -enableCodeCoverage YES \ + -project "${PROJECT_PATH}" \ + -scheme "${SCHEME}" \ + -destination 'platform=iOS Simulator,name=iPhone 14 Pro' \ + -derivedDataPath 'Demo/DerivedData' \ + -clonedSourcePackagesDirPath 'Demo/.build/SourcePackages' \ + -resultBundlePath "$XCRESULT_PATH" \ + clean test | xcpretty From 33305549cf697eb836e04bbcd228d5f47c1cfaf3 Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Thu, 5 Oct 2023 01:20:38 +0900 Subject: [PATCH 3/9] split test jobs --- .github/workflows/ci.yml | 78 ++++++++++++++++++++++++++++++++-------- scripts/test.sh | 2 ++ scripts/test_demo.sh | 3 ++ 3 files changed, 68 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33d826d..9cc50f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,10 +36,7 @@ jobs: - name: Cache SPM build directory uses: actions/cache@v3 with: - path: | - .build - Demo/.build - Demo/Tools/.build + path: .build key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.swift') }} restore-keys: | ${{ runner.os }}-spm-${{ env.cache-name }}- @@ -48,9 +45,7 @@ jobs: - name: Cache DerivedData uses: actions/cache@v3 with: - path: | - DerivedData - Demo/DerivedData + path: DerivedData key: ${{ runner.os }}-xcode-derived-data-${{ hashFiles('**/Package.swift') }} restore-keys: | ${{ runner.os }}-xcode-derived-data-${{ env.cache-name }}- @@ -62,17 +57,70 @@ jobs: run: set -o pipefail && swift test - name: test via xcodebuild run: ./scripts/test.sh - - name: test DemoApp - if: success() || failure() - run: ./scripts/test_demo.sh - - uses: kishikawakatsumi/xcresulttool@v1 + - name: upload test results + if: ${{ matrix.xcode_version == fromJson(needs.generate-matrix.outputs.matrix).xcode_version[0] && (success() || failure()) }} + uses: actions/upload-artifact@v3 + with: + name: BuildConfig.swift.xcresult + path: test_output/BuildConfig.swift.xcresult + test_demo: + name: Test demo app + needs: generate-matrix + runs-on: macOS-12 + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} + env: + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer + steps: + - uses: actions/checkout@v4 + - name: Cache SPM build directory + uses: actions/cache@v3 with: path: | - test_output/BuildConfig.swift.xcresult - test_output/BuildConfigDemo.xcresult - show-passed-tests: false - show-code-coverage: false + Demo/.build + Demo/Tools/.build + key: ${{ runner.os }}-demo-spm-${{ hashFiles('**/Package.swift') }} + restore-keys: | + ${{ runner.os }}-demo-spm-${{ env.cache-name }}- + ${{ runner.os }}-demo-spm- + ${{ runner.os }}-demo- + - name: Cache DerivedData + uses: actions/cache@v3 + with: + path: Demo/DerivedData + key: ${{ runner.os }}-demo-xcode-derived-data-${{ hashFiles('**/Package.swift') }} + restore-keys: | + ${{ runner.os }}-demo-xcode-derived-data-${{ env.cache-name }}- + ${{ runner.os }}-demo-xcode-derived-data- + ${{ runner.os }}-demo- + - name: Disable SwiftLint Plugin + run: sed -i -e 's/.*SwiftLint.*//g' Package.swift + - name: test + run: ./scripts/test_demo.sh + - name: upload test results if: ${{ matrix.xcode_version == fromJson(needs.generate-matrix.outputs.matrix).xcode_version[0] && (success() || failure()) }} + uses: actions/upload-artifact@v3 + with: + name: BuildConfigDemo.xcresult + path: test_output/BuildConfigDemo.xcresult + report: + name: Report + needs: [test, test_demo] + runs-on: macOS-12 + if: ${{ (success() || failure()) }} + steps: + - uses: actions/download-artifact@v3 + with: + path: test_output + - run: ls -la test_output + # - uses: kishikawakatsumi/xcresulttool@v1 + # with: + # path: | + # test_output/BuildConfig.swift.xcresult + # test_output/BuildConfigDemo.xcresult + # show-passed-tests: false + # show-code-coverage: false danger: name: Danger if: ${{ github.event_name == 'pull_request' }} diff --git a/scripts/test.sh b/scripts/test.sh index d8607e0..77cf656 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -10,6 +10,8 @@ fi SCHEME="$(xcrun --sdk macosx xcodebuild -list -json | jq -rc '.workspace.schemes[] | select(. | startswith("BuildConfig"))')" +echo "Scheme: $SCHEME" + xcrun --sdk macosx xcodebuild \ -enableCodeCoverage YES \ -scheme "${SCHEME}" \ diff --git a/scripts/test_demo.sh b/scripts/test_demo.sh index dc714c0..65a170d 100755 --- a/scripts/test_demo.sh +++ b/scripts/test_demo.sh @@ -15,6 +15,9 @@ fi PROJECT_PATH=$(find Demo -depth 1 -name '*.xcodeproj' | head -n 1) SCHEME="$(xcrun --sdk macosx xcodebuild -project "${PROJECT_PATH}" -list -json | jq -rc '.project.schemes[] | select(. | contains("Demo"))')" + +echo "Scheme: $SCHEME" + xcrun --sdk macosx xcodebuild \ -skipPackagePluginValidation \ -enableCodeCoverage YES \ From bc56196d7b32f76c92e22f5771460949ad3e4d60 Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Thu, 5 Oct 2023 02:09:37 +0900 Subject: [PATCH 4/9] save scheme --- .gitignore | 52 +----- .../xcschemes/BuildConfig.swift.xcscheme | 151 ++++++++++++++++++ 2 files changed, 159 insertions(+), 44 deletions(-) create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/BuildConfig.swift.xcscheme diff --git a/.gitignore b/.gitignore index 566209f..8df226d 100644 --- a/.gitignore +++ b/.gitignore @@ -38,55 +38,19 @@ timeline.xctimeline playground.xcworkspace # Swift Package Manager -# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. -# Packages/ -# Package.pins +Packages +Package.pins Package.resolved .build/ -# Add this line if you want to avoid checking in Xcode SPM integration. -.swiftpm/xcode - -# CocoaPods -# We recommend against adding the Pods directory to your .gitignore. However -# you should judge for yourself, the pros and cons are mentioned at: -# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control -# Pods/ -# Add this line if you want to avoid checking in source code from the Xcode workspace -# *.xcworkspace - -# Carthage -# Add this line if you want to avoid checking in source code from Carthage dependencies. -# Carthage/Checkouts - -Carthage/Build - -# Accio dependency management -Dependencies/ -.accio/ - -# fastlane -# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the -# screenshots whenever they are needed. -# For more information about the recommended setup visit: -# https://docs.fastlane.tools/best-practices/source-control/#source-control - -fastlane/report.xml -fastlane/Preview.html -fastlane/screenshots/**/*.png -fastlane/test_output - -# Code Injection -# After new code Injection tools there's a generated folder /iOSInjectionProject -# https://github.com/johnno1962/injectionforxcode - -iOSInjectionProject/ - -### SwiftPM ### -Packages +.swiftpm/xcode/* +!.swiftpm/xcode/xcshareddata +.swiftpm/xcode/xcshareddata/* +!.swiftpm/xcode/xcshareddata/xcschemes +.swiftpm/xcode/xcshareddata/xcschemes/* +!.swiftpm/xcode/xcshareddata/xcschemes/*.xcscheme xcuserdata *.xcodeproj - # End of https://www.gitignore.io/api/swift,swiftpm test_output diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/BuildConfig.swift.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/BuildConfig.swift.xcscheme new file mode 100644 index 0000000..2d73860 --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/BuildConfig.swift.xcscheme @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 73b4f284b1504e27cc19a0ad450ad2344e0f7b4e Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Thu, 5 Oct 2023 02:25:56 +0900 Subject: [PATCH 5/9] avoid execute `swift test` --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cc50f1..ec6cad9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,11 +53,9 @@ jobs: ${{ runner.os }}- - name: Disable SwiftLint Plugin run: sed -i -e 's/.*SwiftLint.*//g' Package.swift - - name: test via SwiftPM - run: set -o pipefail && swift test - - name: test via xcodebuild + - name: Test run: ./scripts/test.sh - - name: upload test results + - name: Upload test results if: ${{ matrix.xcode_version == fromJson(needs.generate-matrix.outputs.matrix).xcode_version[0] && (success() || failure()) }} uses: actions/upload-artifact@v3 with: From 25a6ca58f430c5652a531aabfcc81a962c8fce5d Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Thu, 5 Oct 2023 02:39:42 +0900 Subject: [PATCH 6/9] Revert "save scheme" This reverts commit 512c5f9c7c0c3f5e0eadc49e505faf76ab616f19. --- .gitignore | 52 +++++- .../xcschemes/BuildConfig.swift.xcscheme | 151 ------------------ 2 files changed, 44 insertions(+), 159 deletions(-) delete mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/BuildConfig.swift.xcscheme diff --git a/.gitignore b/.gitignore index 8df226d..566209f 100644 --- a/.gitignore +++ b/.gitignore @@ -38,19 +38,55 @@ timeline.xctimeline playground.xcworkspace # Swift Package Manager -Packages -Package.pins +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins Package.resolved .build/ -.swiftpm/xcode/* -!.swiftpm/xcode/xcshareddata -.swiftpm/xcode/xcshareddata/* -!.swiftpm/xcode/xcshareddata/xcschemes -.swiftpm/xcode/xcshareddata/xcschemes/* -!.swiftpm/xcode/xcshareddata/xcschemes/*.xcscheme +# Add this line if you want to avoid checking in Xcode SPM integration. +.swiftpm/xcode + +# CocoaPods +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# Pods/ +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# Accio dependency management +Dependencies/ +.accio/ + +# fastlane +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ + +### SwiftPM ### +Packages xcuserdata *.xcodeproj + # End of https://www.gitignore.io/api/swift,swiftpm test_output diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/BuildConfig.swift.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/BuildConfig.swift.xcscheme deleted file mode 100644 index 2d73860..0000000 --- a/.swiftpm/xcode/xcshareddata/xcschemes/BuildConfig.swift.xcscheme +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 9d79fda39740396b657bddf96f9af5401a6c95f8 Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Thu, 5 Oct 2023 08:15:21 +0900 Subject: [PATCH 7/9] uncomment reporting --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec6cad9..0a3d535 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,13 +112,13 @@ jobs: with: path: test_output - run: ls -la test_output - # - uses: kishikawakatsumi/xcresulttool@v1 - # with: - # path: | - # test_output/BuildConfig.swift.xcresult - # test_output/BuildConfigDemo.xcresult - # show-passed-tests: false - # show-code-coverage: false + - uses: kishikawakatsumi/xcresulttool@v1 + with: + path: | + test_output/BuildConfig.swift.xcresult + test_output/BuildConfigDemo.xcresult + show-passed-tests: false + show-code-coverage: false danger: name: Danger if: ${{ github.event_name == 'pull_request' }} From 3316a6ec106b82e4a0b3e4d404ff8139a158d4b9 Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Thu, 5 Oct 2023 08:52:41 +0900 Subject: [PATCH 8/9] unuse cache on main app --- .github/workflows/ci.yml | 11 ++--------- scripts/test.sh | 1 - 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a3d535..1b948b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer + cache-name: 'test' steps: - uses: actions/checkout@v4 - name: Cache SPM build directory @@ -42,15 +43,6 @@ jobs: ${{ runner.os }}-spm-${{ env.cache-name }}- ${{ runner.os }}-spm- ${{ runner.os }}- - - name: Cache DerivedData - uses: actions/cache@v3 - with: - path: DerivedData - key: ${{ runner.os }}-xcode-derived-data-${{ hashFiles('**/Package.swift') }} - restore-keys: | - ${{ runner.os }}-xcode-derived-data-${{ env.cache-name }}- - ${{ runner.os }}-xcode-derived-data- - ${{ runner.os }}- - name: Disable SwiftLint Plugin run: sed -i -e 's/.*SwiftLint.*//g' Package.swift - name: Test @@ -70,6 +62,7 @@ jobs: matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer + cache-name: 'test-demo' steps: - uses: actions/checkout@v4 - name: Cache SPM build directory diff --git a/scripts/test.sh b/scripts/test.sh index 77cf656..acc8bd9 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -16,7 +16,6 @@ xcrun --sdk macosx xcodebuild \ -enableCodeCoverage YES \ -scheme "${SCHEME}" \ -destination "platform=macOS" \ - -derivedDataPath 'DerivedData' \ -clonedSourcePackagesDirPath '.build/SourcePackages' \ -resultBundlePath "$XCRESULT_PATH" \ clean test | xcpretty From 5ee899c01c598f75b2ba5610172aa04a1e749d13 Mon Sep 17 00:00:00 2001 From: 417-72KI <417.72ki@gmail.com> Date: Thu, 5 Oct 2023 09:15:20 +0900 Subject: [PATCH 9/9] refine cache-key --- .github/workflows/ci.yml | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b948b5..229b30e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,17 +31,18 @@ jobs: matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer - cache-name: 'test' steps: - uses: actions/checkout@v4 - name: Cache SPM build directory uses: actions/cache@v3 + env: + cache-name: swiftpm with: path: .build - key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.swift') }} + key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/Package.swift') }} restore-keys: | - ${{ runner.os }}-spm-${{ env.cache-name }}- - ${{ runner.os }}-spm- + ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}- + ${{ runner.os }}-${{ github.job }}- ${{ runner.os }}- - name: Disable SwiftLint Plugin run: sed -i -e 's/.*SwiftLint.*//g' Package.swift @@ -62,29 +63,32 @@ jobs: matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer - cache-name: 'test-demo' steps: - uses: actions/checkout@v4 - name: Cache SPM build directory uses: actions/cache@v3 + env: + cache-name: swiftpm with: path: | Demo/.build Demo/Tools/.build - key: ${{ runner.os }}-demo-spm-${{ hashFiles('**/Package.swift') }} + key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/Package.swift') }} restore-keys: | - ${{ runner.os }}-demo-spm-${{ env.cache-name }}- - ${{ runner.os }}-demo-spm- - ${{ runner.os }}-demo- + ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}- + ${{ runner.os }}-${{ github.job }}- + ${{ runner.os }}- - name: Cache DerivedData uses: actions/cache@v3 + env: + cache-name: derived-data with: path: Demo/DerivedData - key: ${{ runner.os }}-demo-xcode-derived-data-${{ hashFiles('**/Package.swift') }} + key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/Package.swift') }} restore-keys: | - ${{ runner.os }}-demo-xcode-derived-data-${{ env.cache-name }}- - ${{ runner.os }}-demo-xcode-derived-data- - ${{ runner.os }}-demo- + ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}- + ${{ runner.os }}-${{ github.job }}- + ${{ runner.os }}- - name: Disable SwiftLint Plugin run: sed -i -e 's/.*SwiftLint.*//g' Package.swift - name: test