From 0b7b9f49765686e49dbcdbc51dddcbc2b6a2be4b Mon Sep 17 00:00:00 2001 From: Aditi Sharma Date: Thu, 6 Mar 2025 13:29:35 -0800 Subject: [PATCH] Update macOS runner image for CI workflow in main branch (#257) * Update macOS runner image for CI workflow in main branch * Update script to find Swiftlint in path * Add correct Swiftlint in PATH * Update script to install swiftlint if not present * cleanup script for swiftlint * cleanup script for swiftlint, fix span limit test * Update script to build swift packages for iOS target versions available on runner image * Use macOS-14 runner image for full build --- .github/workflows/ci.yml | 115 +++++++++--------- .../SplunkRum/SplunkRumTests/MiscTests.swift | 8 +- fullbuild.sh | 26 +++- 3 files changed, 83 insertions(+), 66 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86c27207..5bdf5c41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: jobs: full-build: - runs-on: macos-12 + runs-on: macos-14 steps: - name: Checkout uses: actions/checkout@v4 @@ -17,7 +17,7 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v4.4.1 xcframework: - runs-on: macos-12 + runs-on: macos-14 steps: - name: Checkout uses: actions/checkout@v4 @@ -31,62 +31,63 @@ jobs: with: name: SplunkOtel.xcframework path: ./SplunkRumWorkspace/SplunkRum/xcframeworks/SplunkOtel.xcframework - saucelabs-prepare: - runs-on: macOS-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.8' - - name: Build for Sauce Labs - run: | - BUILD_FOLDER="work/splunk-otel-ios/splunk-otel-ios/SauceLabsTests" - BUILD_PATH="Build/Products/Debug-iphonesimulator" - xcodebuild -showsdks + # Commented until Saucelabs licensing is fixed + # saucelabs-prepare: + # runs-on: macOS-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # - name: Setup Python + # uses: actions/setup-python@v5 + # with: + # python-version: '3.8' + # - name: Build for Sauce Labs + # run: | + # BUILD_FOLDER="work/splunk-otel-ios/splunk-otel-ios/SauceLabsTests" + # BUILD_PATH="Build/Products/Debug-iphonesimulator" + # xcodebuild -showsdks - xcodebuild -workspace SplunkRumWorkspace/SplunkRumWorkspace.xcworkspace \ - -scheme SauceLabsTestApp \ - -configuration Debug \ - -sdk iphonesimulator \ - -derivedDataPath SauceLabsTests - zip ${GITHUB_WORKSPACE}/SauceLabsTestApp.zip $(find ~/$BUILD_FOLDER/$BUILD_PATH/SauceLabsTestApp.app -type f) - - name: Upload test app to Sauce Labs - id: sl-upload - run: | - cd /Users/runner/work/splunk-otel-ios/splunk-otel-ios/ - item_id=$(curl -u "${{secrets.SAUCELABS_USER}}:${{secrets.SAUCELABS_KEY}}" --location \ - --request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' \ - --form 'payload=@"SauceLabsTestApp.zip"' \ - --form 'name="SauceLabsTestApp.zip"' \ - --form 'description="'"$GITHUB_SHA"'"' | jq -r .item.id) - echo "sl_file_id=$item_id" >> $GITHUB_OUTPUT - outputs: - sl_file_id: ${{ steps.sl-upload.outputs.sl_file_id }} - saucelabs-tests: - runs-on: macOS-latest - needs: saucelabs-prepare - strategy: - fail-fast: false - matrix: - os: ['14', '15', '16'] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.8' - - name: Run Sauce Labs test cases - working-directory: SplunkRumWorkspace - env: - SAUCELABS_USER: ${{ secrets.SAUCELABS_USER }} - SAUCELABS_KEY: ${{ secrets.SAUCELABS_KEY }} - run: | - cd SauceLabsTestApp/ - python3 -m pip install Appium-Python-Client==2.11.1 - python3 sl_tests.py ${{ matrix.os }} ${{ needs.saucelabs-prepare.outputs.sl_file_id }} + # xcodebuild -workspace SplunkRumWorkspace/SplunkRumWorkspace.xcworkspace \ + # -scheme SauceLabsTestApp \ + # -configuration Debug \ + # -sdk iphonesimulator \ + # -derivedDataPath SauceLabsTests + # zip ${GITHUB_WORKSPACE}/SauceLabsTestApp.zip $(find ~/$BUILD_FOLDER/$BUILD_PATH/SauceLabsTestApp.app -type f) + # - name: Upload test app to Sauce Labs + # id: sl-upload + # run: | + # cd /Users/runner/work/splunk-otel-ios/splunk-otel-ios/ + # item_id=$(curl -u "${{secrets.SAUCELABS_USER}}:${{secrets.SAUCELABS_KEY}}" --location \ + # --request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' \ + # --form 'payload=@"SauceLabsTestApp.zip"' \ + # --form 'name="SauceLabsTestApp.zip"' \ + # --form 'description="'"$GITHUB_SHA"'"' | jq -r .item.id) + # echo "sl_file_id=$item_id" >> $GITHUB_OUTPUT + # outputs: + # sl_file_id: ${{ steps.sl-upload.outputs.sl_file_id }} + # saucelabs-tests: + # runs-on: macOS-latest + # needs: saucelabs-prepare + # strategy: + # fail-fast: false + # matrix: + # os: ['14', '15', '16'] + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # - name: Setup Python + # uses: actions/setup-python@v5 + # with: + # python-version: '3.8' + # - name: Run Sauce Labs test cases + # working-directory: SplunkRumWorkspace + # env: + # SAUCELABS_USER: ${{ secrets.SAUCELABS_USER }} + # SAUCELABS_KEY: ${{ secrets.SAUCELABS_KEY }} + # run: | + # cd SauceLabsTestApp/ + # python3 -m pip install Appium-Python-Client==2.11.1 + # python3 sl_tests.py ${{ matrix.os }} ${{ needs.saucelabs-prepare.outputs.sl_file_id }} check_links: runs-on: ubuntu-22.04 steps: diff --git a/SplunkRumWorkspace/SplunkRum/SplunkRumTests/MiscTests.swift b/SplunkRumWorkspace/SplunkRum/SplunkRumTests/MiscTests.swift index cc8fda23..c1752ea8 100644 --- a/SplunkRumWorkspace/SplunkRum/SplunkRumTests/MiscTests.swift +++ b/SplunkRumWorkspace/SplunkRum/SplunkRumTests/MiscTests.swift @@ -43,25 +43,25 @@ class MiscTests: XCTestCase { func testLengthLimitingExporter() throws { // This test is shaped kinda funny since we can't construct SpanData() directly let span = buildTracer().spanBuilder(spanName: "limitTest").startSpan() - var longString = "0123456789abcdef" + var longString = "0123456789abcdefghijklmnopqurstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789abcde" var i = 0 while i < 9 { longString += longString i += 1 } - XCTAssertTrue(longString.count > 4096) + XCTAssertTrue(longString.count > 32768) span.setAttribute(key: "longString", value: longString) span.setAttribute(key: "normalString", value: "normal") span.setAttribute(key: "normalInt", value: 7) span.end() XCTAssertEqual(1, localSpans.count) let rawSpans = localSpans - XCTAssertTrue(rawSpans[0].attributes["longString"]?.description.count ?? 0 > 4096) + XCTAssertTrue(rawSpans[0].attributes["longString"]?.description.count ?? 0 > 32768) localSpans.removeAll() let le = LimitingExporter(proxy: TestSpanExporter(), spanFilter: nil) // rewrites into localSpans; yes, this is weird _ = le.export(spans: rawSpans) XCTAssertEqual(1, localSpans.count) - XCTAssertTrue(localSpans[0].attributes["longString"]?.description.count ?? 4097 <= 4096) + XCTAssertTrue(localSpans[0].attributes["longString"]?.description.count ?? 32767 <= 32768) XCTAssertEqual("normal", localSpans[0].attributes["normalString"]?.description ?? nil) XCTAssertEqual("7", localSpans[0].attributes["normalInt"]?.description ?? nil) } diff --git a/fullbuild.sh b/fullbuild.sh index e6b1a7b5..4f8be7f6 100755 --- a/fullbuild.sh +++ b/fullbuild.sh @@ -1,6 +1,17 @@ #!/bin/bash set -ex -swiftlint --strict + +# on arm64 macOS, homebrew is custom build into /opt/homebrew +PATH=${PATH}:/opt/homebrew/bin/ + +if which swiftlint >/dev/null; then + echo "Swiftlint installation found" +else + echo "warning: SwiftLint not installed, installing via Homebrew" + brew install swiftlint +fi + +swiftlint # Make sure the version numbers on the podspec and SplunkRum.swift match echo "Checking that version numbers match" @@ -12,7 +23,7 @@ if [ $podVer != $rumVer ]; then fi # Check the podspec is valid -pod lib lint SplunkOtel.podspec +pod lib lint SplunkOtel.podspec --allow-warnings xcodebuild -workspace SplunkRumWorkspace/SplunkRumWorkspace.xcworkspace -scheme SplunkOtel -configuration Debug build xcodebuild -workspace SplunkRumWorkspace/SplunkRumWorkspace.xcworkspace -scheme SplunkOtel -configuration Debug test @@ -20,9 +31,14 @@ xcodebuild -workspace SplunkRumWorkspace/SplunkRumWorkspace.xcworkspace -scheme # Now try to do a swift build to ensure that the package dependencies are properly in synch rm -rf ./.build -swift build -v -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios11.0-simulator" -rm -rf ./.build +SIMULATOR_SDK="$(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk" +SIMULATOR_TARGET="arm64-apple-ios17-simulator" +swift build -v --sdk "$SIMULATOR_SDK" --triple "$SIMULATOR_TARGET" --scratch-path "./.build/$SIMULATOR_TARGET" + # repeat targeting a real device -swift build -v -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphoneos --show-sdk-path`" -Xswiftc "-target" -Xswiftc "arm64-apple-ios14.0" +rm -rf ./.build +DEVICE_SDK="$(xcode-select -p)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" +DEVICE_TARGET="arm64-apple-ios18.2" +swift build -v --sdk "$DEVICE_SDK" --triple "$DEVICE_TARGET" --scratch-path "./.build/$DEVICE_TARGET" echo "========= Congratulations! ========="