Skip to content

Commit

Permalink
add script for test DemoWithPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
417-72KI committed Jul 2, 2024
1 parent c8a58b2 commit 40adda3
Showing 3 changed files with 70 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -99,6 +99,51 @@ jobs:
with:
name: BuildConfigDemo.xcresult
path: test_output/BuildConfigDemo.xcresult
test_demo_with_package:
name: Test package based demo app
needs: generate-matrix
runs-on: macOS-14
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@v4
env:
cache-name: swiftpm
with:
path: |
DemoWithPackage/.build
DemoWithPackage/Tools/.build
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/Package.swift') }}
restore-keys: |
${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-
${{ runner.os }}-${{ github.job }}-
${{ runner.os }}-
- name: Cache DerivedData
uses: actions/cache@v4
env:
cache-name: derived-data
with:
path: DemoWithPackage/DerivedData
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/Package.swift') }}
restore-keys: |
${{ 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
run: ./scripts/test_demo_package.sh
- name: upload test results
if: ${{ matrix.xcode_version == fromJson(needs.generate-matrix.outputs.matrix).xcode_version[0] && (success() || failure()) }}
uses: actions/upload-artifact@v4
with:
name: BuildConfigDemoPackage.xcresult
path: test_output/BuildConfigDemoPackage.xcresult
report:
name: Report
needs: [test, test_demo]
2 changes: 1 addition & 1 deletion scripts/test_demo.sh
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ fi
if [[ "$(find Demo -depth 1 -name '*.xcodeproj')" == '' ]]; then
echo '\e[33m`xcodeproj` in `Demo` not found, generating...\e[0m'
$(dirname $0)/copy-lint-config.sh
xcrun --sdk macosx swift run --package-path Demo/Tools xcodegen --spec Demo/project.yml
xcrun --sdk macosx swift run --package-path Tools xcodegen --spec Demo/project.yml
fi

PROJECT_PATH=$(find Demo -depth 1 -name '*.xcodeproj' | head -n 1)
24 changes: 24 additions & 0 deletions scripts/test_demo_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -o pipefail

XCRESULT_PATH="$(pwd)/test_output/BuildConfigDemoPackage.xcresult"

if [[ -e "$XCRESULT_PATH" ]]; then
rm -rf "$XCRESULT_PATH"
fi

cd DemoWithPackage
SCHEME="$(xcrun --sdk macosx xcodebuild -list -json | jq -rc '.workspace.schemes[] | select(. | contains("Demo"))')"

echo "\e[32mScheme: $SCHEME\e[0m"

xcrun --sdk macosx xcodebuild \
-skipPackagePluginValidation \
-enableCodeCoverage YES \
-scheme "${SCHEME}" \
-destination 'platform=iOS Simulator,name=iPhone 14 Pro' \
-derivedDataPath 'DerivedData' \
-clonedSourcePackagesDirPath '.build/SourcePackages' \
-resultBundlePath "$XCRESULT_PATH" \
clean test | xcpretty

0 comments on commit 40adda3

Please sign in to comment.