Skip to content

Commit

Permalink
Update macOS runner image for CI workflow in main branch (#257)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
aditi-s3 authored Mar 6, 2025
1 parent dc77bbc commit 0b7b9f4
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 66 deletions.
115 changes: 58 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
full-build:
runs-on: macos-12
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -17,7 +17,7 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/[email protected]
xcframework:
runs-on: macos-12
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions SplunkRumWorkspace/SplunkRum/SplunkRumTests/MiscTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
26 changes: 21 additions & 5 deletions fullbuild.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -12,17 +23,22 @@ 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
xcodebuild -workspace SplunkRumWorkspace/SplunkRumWorkspace.xcworkspace -scheme SplunkOtel -configuration Release build

# 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! ========="

0 comments on commit 0b7b9f4

Please sign in to comment.