Skip to content

Commit

Permalink
Build scripts (#49)
Browse files Browse the repository at this point in the history
* Build cleanup
* Selectively disable targets
* CI build fixes
* Fix flaky test
  • Loading branch information
wkal-pubnub authored Aug 5, 2024
1 parent d2d5dec commit 273aa09
Show file tree
Hide file tree
Showing 25 changed files with 227 additions and 422 deletions.
1 change: 1 addition & 0 deletions .github/workflows/commands-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
submodules: recursive
- name: Checkout release actions
if: steps.user-check.outputs.expected-user == 'true'
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
with:
# This should be the same as the one specified for on.pull_request.branches
ref: master
submodules: recursive
- name: Checkout actions
uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release/chat-maven-build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
echo "Build Chat SDK module artifacts"
./gradlew jar --no-configuration-cache
./gradlew jar
2 changes: 1 addition & 1 deletion .github/workflows/release/chat-maven-publish.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./gradlew publishToSonatype closeSonatypeStagingRepository --no-configuration-cache
./gradlew publishToSonatype closeSonatypeStagingRepository
2 changes: 1 addition & 1 deletion .github/workflows/release/pre-github-pages-publish.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./gradlew :dokkaGfmMultiModule --no-configuration-cache
./gradlew :dokkaGfmMultiModule
8 changes: 8 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout actions
uses: actions/checkout@v4
with:
Expand All @@ -31,6 +33,12 @@ jobs:
- name: Build and run tests
run: |
./gradlew check
env:
SDK_PUB_KEY: ${{ secrets.SDK_PUB_KEY }}
SDK_SUB_KEY: ${{ secrets.SDK_SUB_KEY }}
SDK_PAM_SUB_KEY: ${{ secrets.SDK_PAM_SUB_KEY }}
SDK_PAM_PUB_KEY: ${{ secrets.SDK_PAM_PUB_KEY }}
SDK_PAM_SEC_KEY: ${{ secrets.SDK_PAM_SEC_KEY }}
- name: Cancel workflow runs for commit on error
if: failure()
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/run-validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout validator action
uses: actions/checkout@v4
with:
Expand All @@ -39,6 +41,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache
uses: actions/cache@v4
with:
Expand All @@ -49,7 +53,7 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Validate clean build
run: ./gradlew build
run: ./gradlew apiCheck ktlintFormat publishAllPublicationsToRepoRepository -PRELEASE_SIGNING_ENABLED=false
- name: Cancel workflow runs for commit on error
if: failure()
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
Expand Down
137 changes: 25 additions & 112 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,82 +1,23 @@
import com.pubnub.gradle.enableAnyIosTarget
import com.pubnub.gradle.tasks.GenerateVersionTask
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension

plugins {
kotlin("multiplatform") version "2.0.0"
kotlin("plugin.serialization") version "2.0.0"
kotlin("native.cocoapods") version "2.0.0"
id("dev.mokkery") version "2.0.0"
kotlin("multiplatform") version "2.0.0" apply false
kotlin("plugin.serialization") version "2.0.0" apply false
kotlin("native.cocoapods") version "2.0.0" apply false
id("org.jlleitschuh.gradle.ktlint") version "12.1.0" apply false
id("org.jetbrains.kotlin.plugin.atomicfu") version "2.0.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
id("pubnub.dokka") apply false
id("com.vanniktech.maven.publish") version "0.29.0" apply false
id("org.jetbrains.dokka") version "1.9.20" apply false

id("pubnub.shared")
id("pubnub.dokka")
id("pubnub.multiplatform")
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.16.2"
}

group = "com.pubnub"
version = "1.0-SNAPSHOT"

ktlint {
outputToConsole.set(true)
verbose.set(true)
additionalEditorconfig.set(
mapOf(
"ij_kotlin_imports_layout" to "*,java.**,javax.**,kotlin.**,^",
"indent_size" to "4",
"ktlint_standard_multiline-expression-wrapping" to "disabled",
"ktlint_standard_string-template-indent" to "disabled",
"ktlint_standard_max-line-length" to "disabled",
"ktlint_standard_if-else-wrapping" to "disabled",
"ktlint_standard_discouraged-comment-location" to "disabled",
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
"ktlint_standard_trailing-comma-on-call-site" to "disabled",
"ktlint_standard_function-signature" to "disabled",
"ktlint_standard_filename" to "disabled",
"ktlint_standard_function-naming" to "disabled",
)
)
}

kotlin {
jvmToolchain(8)
js {
useEsModules()
// browser {
// testTask {
// // useMocha {
// // timeout = "30s"
// // }
// useKarma {
// useChrome()
// }
// }
// }
nodejs {
testTask {
useMocha {
timeout = "20s"
}
}
}
}
jvm()

listOf(
// iosArm64(),
iosSimulatorArm64(),
).forEach {
// it.binaries {
// framework {
// baseName = "PubNubChat"
// isStatic = true
// }
// }
}

applyDefaultHierarchyTemplate()

sourceSets {
val commonMain by getting {
dependencies {
Expand All @@ -85,9 +26,11 @@ kotlin {
}
}

val iosMain by getting {
dependencies {
api(project(":pubnub-chat-impl"))
if (enableAnyIosTarget) {
val iosMain by getting {
dependencies {
api(project(":pubnub-chat-impl"))
}
}
}

Expand All @@ -99,50 +42,20 @@ kotlin {
}
}

cocoapods {
ios.deploymentTarget = "14"

// Required properties
// Specify the required Pod version here. Otherwise, the Gradle project version is used.
version = "1.0"
summary = "Some description for a Kotlin/Native module"
homepage = "Link to a Kotlin/Native module homepage"

// Maps custom Xcode configuration to NativeBuildType
xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG
xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE

// podfile = project.file(project.file("Sample Chat app/Podfile"))
if (enableAnyIosTarget) {
(this as ExtensionAware).extensions.configure<CocoapodsExtension> {
summary = "Some description for a Kotlin/Native module"
homepage = "Link to a Kotlin/Native module homepage"

framework {
// Required properties
// Framework name configuration. Use this property instead of deprecated 'frameworkName'
baseName = "PubNubChat"
// Optional properties
// Specify the framework linking type. It's dynamic by default.
isStatic = true
export(project(":pubnub-chat-api"))
export(project(":pubnub-chat-impl"))
transitiveExport = true
}

pod("PubNubSwift") {
// source = git("https://github.com/pubnub/swift") {
// branch = "feat/kmp"
// }
// headers = "PubNub/PubNub.h"
source = path(rootProject.file("pubnub-kotlin/swift"))
// version = "7.1.0"

moduleName = "PubNub"
extraOpts += listOf("-compiler-option", "-fmodules")
framework {
baseName = "PubNubChat"
export(project(":pubnub-chat-api"))
export(project(":pubnub-chat-impl"))
}
}
}
}

yarn.yarnLockMismatchReport = YarnLockMismatchReport.WARNING
yarn.yarnLockAutoReplace = true

val generateVersion =
tasks.register<GenerateVersionTask>("generateVersion") {
fileName.set("ChatVersion")
Expand Down
36 changes: 31 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
kotlin.code.style=official
org.gradle.configuration-cache=true
org.gradle.caching=true
org.gradle.parallel=true
kotlin.mpp.applyDefaultHierarchyTemplate=false
#kotlin.mpp.import.enableKgpDependencyResolution=true

#kotlin.native.cacheKind.iosSimulatorArm64=none
#kotlin.native.cacheKind.iosArm64=none

org.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

RELEASE_SIGNING_ENABLED=true
SONATYPE_HOST=DEFAULT
SONATYPE_AUTOMATIC_RELEASE=false
GROUP=com.pubnub
POM_PACKAGING=jar
VERSION_NAME=0.8.0-DEV

POM_NAME=PubNub Chat SDK
POM_DESCRIPTION=This SDK offers a set of handy methods to create your own feature-rich chat or add a chat to your existing application.
POM_INCEPTION_YEAR=2024
POM_URL=https://github.com/pubnub/kmp-chat

POM_LICENSE_NAME=PubNub Software Development Kit License
POM_LICENSE_URL=https://github.com/pubnub/kotlin/blob/master/LICENSE
POM_LICENSE_DIST=repo

POM_SCM_URL=https://github.com/pubnub/kmp-chat
POM_SCM_CONNECTION=scm:git:git://github.com/pubnub/kmp-chat
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/pubnub/kmp-chat

POM_DEVELOPER_ID=PubNub
POM_DEVELOPER_NAME=PubNub
POM_DEVELOPER_URL[email protected]

IOS_SIMULATOR_ID=iPhone 15 Pro
SWIFT_PATH=pubnub-kotlin/swift

ENABLE_TARGET_JS=false
ENABLE_TARGET_IOS=false
ENABLE_TARGET_IOS_SIMULATOR=false
76 changes: 3 additions & 73 deletions pubnub-chat-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,75 +1,12 @@
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn

plugins {
kotlin("multiplatform") version "2.0.0"
kotlin("plugin.serialization") version "2.0.0"
id("org.jetbrains.kotlin.plugin.atomicfu") version "2.0.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
}

group = "com.pubnub"
version = "1.0-SNAPSHOT"

ktlint {
outputToConsole.set(true)
verbose.set(true)
additionalEditorconfig.set(
mapOf(
"ij_kotlin_imports_layout" to "*,java.**,javax.**,kotlin.**,^",
"indent_size" to "4",
"ktlint_standard_multiline-expression-wrapping" to "disabled",
"ktlint_standard_string-template-indent" to "disabled",
"ktlint_standard_max-line-length" to "disabled",
"ktlint_standard_if-else-wrapping" to "disabled",
"ktlint_standard_discouraged-comment-location" to "disabled",
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
"ktlint_standard_trailing-comma-on-call-site" to "disabled",
"ktlint_standard_function-signature" to "disabled",
"ktlint_standard_filename" to "disabled",
"ktlint_standard_function-naming" to "disabled",
)
)
id("pubnub.shared")
id("pubnub.dokka")
id("pubnub.multiplatform")
}

kotlin {
jvmToolchain(8)
js {
useEsModules()
// browser {
// testTask {
// // useMocha {
// // timeout = "30s"
// // }
// useKarma {
// useChrome()
// }
// }
// }
nodejs {
testTask {
useMocha {
timeout = "20s"
}
}
}
}
jvm()

listOf(
// iosArm64(),
iosSimulatorArm64(),
).forEach {
// it.binaries {
// framework {
// baseName = "PubNubChat"
// isStatic = true
// }
// }
}

applyDefaultHierarchyTemplate()

sourceSets {
val commonMain by getting {
dependencies {
Expand All @@ -78,12 +15,5 @@ kotlin {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.0-RC")
}
}

val nonJvm by creating {
dependsOn(commonMain)
}
}
}

yarn.yarnLockMismatchReport = YarnLockMismatchReport.WARNING
yarn.yarnLockAutoReplace = true
Loading

0 comments on commit 273aa09

Please sign in to comment.