Skip to content

Commit

Permalink
Rework the installation examples
Browse files Browse the repository at this point in the history
The installation examples were originally created when there was just iOS and
macOS and cross-platform Apps weren't a thing, and the approach that worked
then has turned into a giant mess. Consolidating (almost) all the installation
tests into a single codebase with separate project files per installation
method cuts the amount of code involved by 90% and makes adding more platforms
relatively painles cuts the amount of code involved by 90% and makes adding
more platforms relatively painless.

Separate obj-c and Swift tests have not proven to have any value. We've never
had any bugs caught specifically by the obj-c test which wasn't also caught by
the swift test other than ones specifically related to the obj-c release zip,
so now everything except for the obj-c only iOS static framework is tested only
via Swift.

Some of the tests ended up just plain being redundant; we had separate
XCFramework and fat framework tests, but then the fat framework tests had to be
ported to use XCFrameworks.

Running the smoke tests in the simulator has never actually caught a bug and
doubles the amount of things to build (and adds the requirement to reset the
simulators, which takes a while), so ditch that and only test archiving the app
for device.

The CocoaPods transitive dependency test is now done as part of the normal
cocoapods tests rather than a separate one.

All platforms are now tested via Xcode SPM rather than only iOS. tvOS is now
tested for all installation methods (previously it was not tested at all due to
how much of a hassle adding platforms was).

visionOS is now tested when using Xcode 15 (i.e. it still isn't actually tested
on CI).
  • Loading branch information
tgoyne committed Jul 4, 2023
1 parent b591e0f commit 679e0ab
Show file tree
Hide file tree
Showing 362 changed files with 2,095 additions and 34,432 deletions.
26 changes: 21 additions & 5 deletions .jenkins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target:
- swiftpm-debug
- swiftpm-address
- swiftpm-thread
- swiftpm-ios
- ios-xcode-spm
- ios-static
- ios-dynamic
- watchos
Expand All @@ -34,8 +34,9 @@ target:
- cocoapods-osx
- cocoapods-ios
- cocoapods-ios-dynamic
- cocoapods-ios-subdependency
- cocoapods-watchos
- cocoapods-tvos
- cocoapods-catalyst
- swiftui-ios
- swiftui-server-osx
configuration:
Expand Down Expand Up @@ -127,20 +128,35 @@ exclude:
- xcode_version: 14.2
target: xcframework

- xcode_version: 14.1
target: cocoapods-ios

- xcode_version: 14.2
target: cocoapods-ios

- xcode_version: 14.1
target: cocoapods-ios-dynamic

- xcode_version: 14.2
target: cocoapods-ios-dynamic

- xcode_version: 14.1
target: cocoapods-ios-subdependency
target: cocoapods-watchos

- xcode_version: 14.2
target: cocoapods-ios-subdependency
target: cocoapods-watchos

- xcode_version: 14.1
target: cocoapods-tvos

- xcode_version: 14.2
target: cocoapods-watchos
target: cocoapods-tvos

- xcode_version: 14.1
target: cocoapods-catalyst

- xcode_version: 14.2
target: cocoapods-catalyst

- xcode_version: 14.1
target: swiftui-ios
Expand Down
83 changes: 19 additions & 64 deletions Jenkinsfile.releasability
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,23 @@ platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tv
carthageXcodeVersion = '14.3.1'
docsSwiftVersion = '5.8.1'

def installationTest(platform, test, language) {
def installationTest(platform, test, xcode, language = 'swift', linkage = 'dynamic') {
return {
node('osx') {
deleteDir()
unstash 'source'

if (test == "dynamic" || test == "static") {
if (test == "xcframework") {
unstash "${language}-packaged"
sh "mv *.zip examples/installation"
}

sh """
hostname
export REALM_XCODE_VERSION=${carthageXcodeVersion}
archive=\$(echo \$PWD/realm-${language}-*.zip)

export REALM_XCODE_VERSION='${xcode}'
export REALM_TEST_BRANCH='${sha}'
cd examples/installation
if [[ -f \$archive ]]; then
mv \$archive .
unzip realm-${language}-*.zip
rm realm-${language}-*.zip
mv realm-${language}-* realm-${language}-latest
fi

./build.sh test-${platform}-${language}-${test}
./build.rb ${platform} ${test} ${linkage}
"""
}
}
Expand All @@ -50,22 +43,6 @@ def xcframeworkEvolutionTest() {
}
}

def spmInstallationTest(platform) {
return {
node('osx') {
deleteDir()
unstash 'source'

sh """
hostname
export REALM_XCODE_VERSION=${carthageXcodeVersion}
cd examples/installation
./build.sh test-${platform}-spm
"""
}
}
}

def doBuild() {
stage('prepare') {
node('docker') {
Expand All @@ -82,6 +59,7 @@ def doBuild() {
)

stash includes: '**', name: 'source'
stash includes: 'build.sh,scripts/*', name: 'build-scripts'
}
}

Expand Down Expand Up @@ -257,17 +235,10 @@ def doBuild() {
deleteDir()

unstash 'objc-packaged'
unstash 'build-scripts'

def sha = params.sha
sh """
hostname
curl -O https://raw.githubusercontent.com/realm/realm-swift/${sha}/build.sh
mkdir -p scripts
curl https://raw.githubusercontent.com/realm/realm-swift/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
curl https://raw.githubusercontent.com/realm/realm-swift/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
curl https://raw.githubusercontent.com/realm/realm-swift/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
chmod +x scripts/reset-simulators.rb

sh build.sh package-test-examples-objc
"""
}
Expand All @@ -278,17 +249,10 @@ def doBuild() {
deleteDir()

unstash 'swift-packaged'
unstash 'build-scripts'

def sha = params.sha
sh """
hostname
curl -O https://raw.githubusercontent.com/realm/realm-swift/${sha}/build.sh
mkdir -p scripts
curl https://raw.githubusercontent.com/realm/realm-swift/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
curl https://raw.githubusercontent.com/realm/realm-swift/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
curl https://raw.githubusercontent.com/realm/realm-swift/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
chmod +x scripts/reset-simulators.rb

sh build.sh package-test-examples-swift
"""
}
Expand Down Expand Up @@ -316,30 +280,21 @@ def doBuild() {
}
]

for (def platform in ["osx", "ios", "watchos"]) {
for (def platform in ['osx', 'ios', 'watchos', 'tvos', 'catalyst']) {
def platformName = platformNames[platform]
for (def test in ["dynamic", "cocoapods", "carthage"]) {
parallelBuilds["Installation - ${platformName} Obj-C ${test}"] = installationTest(platform, test, 'objc')
for (def test in ['xcframework', 'cocoapods', 'carthage', 'spm']) {
if (platform != 'catalyst' || test != 'carthage') {
parallelBuilds["Installation - ${platformName} ${test}"] = installationTest(platform, test, carthageXcodeVersion)
}
}
parallelBuilds["Installation - ${platformName} CocoaPods static"] = installationTest(platform, 'cocoapods', carthageXcodeVersion, 'swift', 'static')
}

parallelBuilds["Installation - iOS Obj-C static"] = installationTest('ios', 'static', 'objc')
parallelBuilds["Installation - iOS Obj-C CocoaPods dynamic"] = installationTest('ios', 'cocoapods-dynamic', 'objc')
parallelBuilds["Installation - iOS Swift Package Manager"] = spmInstallationTest('ios')

parallelBuilds["Installation - Mac Catalyst Obj-C CocoaPods"] = installationTest('catalyst', 'cocoapods', 'objc')
parallelBuilds["Installation - Mac Catalyst Obj-C CocoaPods dynamic"] = installationTest('catalyst', 'cocoapods-dynamic', 'objc')

for (def platform in ["osx", "ios", "watchos"]) {
def platformName = platformNames[platform]
for (def test in ["dynamic", "cocoapods", "carthage"]) {
parallelBuilds["Installation - ${platformName} Swift ${test}"] = installationTest(platform, test, 'swift')
}
parallelBuilds['Installation - iOS Static'] = installationTest('ios', 'xcframework', carthageXcodeVersion, 'objc', 'static')
parallelBuilds['Installation - XCFramework Evolution'] = xcframeworkEvolutionTest()
for (def version in xcodeVersions) {
parallelBuilds["Installation - Xcode ${version}"] = installationTest('osx', 'xcframework', version)
}

parallelBuilds["Installation - Mac Catalyst Swift CocoaPods"] = installationTest('catalyst', 'cocoapods', 'swift')
parallelBuilds["Installation - XCFramework Evolution"] = xcframeworkEvolutionTest()

parallel parallelBuilds
}
}
Expand Down
Loading

0 comments on commit 679e0ab

Please sign in to comment.