diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..8106f36d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,40 @@ +name: Run tests +on: [push] +# on: + # push: + # branches: [$default-branch] + # pull_request: + # branches: [$default-branch] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test_macOS: + name: Build and Test on macOS + runs-on: macos-15 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Test + run: | + make ci + xcodebuild test -scheme "Cuckoo-macOS" -workspace Cuckoo.xcworkspace + + test_iOS: + name: Build and Test on iOS simulator + runs-on: macos-15 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: List available Xcode versions + run: ls /Applications | grep Xcode + - name: Show current version of Xcode + run: xcodebuild -version + - name: Test + run: | + # xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) + device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"` + file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` + make ci + xcodebuild test -scheme "Cuckoo-iOS" -workspace Cuckoo.xcworkspace -destination "platform=iOS Simulator,name=$device" diff --git a/Makefile b/Makefile index 0e5fc67a..5690c6af 100644 --- a/Makefile +++ b/Makefile @@ -20,3 +20,13 @@ init: # Generate Cuckoo workspace. make dev + +ci: + # Install Tuist if not present. + if ! command -v tuist &> /dev/null; then curl -Ls https://install.tuist.io | bash; fi + + # Create generated mocks file which will be populated later. + touch "Tests/Swift/Generated/GeneratedMocks.swift" + + # Generate Cuckoo workspace. + make dev