From e6ba1ba8240c35ed59cb87716e0c29d8781213fc Mon Sep 17 00:00:00 2001 From: Andrew Alexander Date: Fri, 19 Jan 2024 14:42:02 -0500 Subject: [PATCH] Copy CI publish auto-release from Misk --- .github/workflows/Build.yml | 82 +++++++ .github/workflows/Docs.yaml | 12 - build.gradle.kts | 227 +++++++++--------- gradle-mvn-publish.gradle.old | 28 --- gradle.properties | 5 - gradle/libs.versions.toml | 13 +- .../tempest2/guides/java/Transaction.java | 5 + 7 files changed, 204 insertions(+), 168 deletions(-) create mode 100644 .github/workflows/Build.yml delete mode 100644 .github/workflows/Docs.yaml delete mode 100644 gradle-mvn-publish.gradle.old diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml new file mode 100644 index 000000000..a7f7f1fed --- /dev/null +++ b/.github/workflows/Build.yml @@ -0,0 +1,82 @@ +name: Build + +on: + pull_request: + paths-ignore: + - "docs/**" + - "*.md" + push: + branches: + - master + +env: + ENVIRONMENT: TESTING + JVM_OPTS: -Xmx1024M + GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=3 -Xmx4096m -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" + TERM: dumb + +jobs: + jvm: + name: Test JVM + runs-on: [ubuntu-latest] + + strategy: + matrix: + cmd: + - gradle check -i --scan --parallel + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Hermit + run: ./bin/hermit env -r >> $GITHUB_ENV + + - name: Test + run: ${{ matrix.cmd }} + + - name: Publish Test Report + if: ${{ always() }} + uses: mikepenz/action-junit-report@v3 + with: + check_name: Test Report - ${{ matrix.cmd }} + report_paths: '**/build/test-results/test/TEST-*.xml' + github_token: ${{ secrets.GITHUB_TOKEN }} + + publish: + name: Publish + if: ${{ github.ref == 'refs/heads/master' && github.repository == 'cashapp/tempest' }} + needs: [js, jvm] + runs-on: [ubuntu-latest] + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Hermit + run: ./bin/hermit env -r >> $GITHUB_ENV + + - name: Assign a version + id: assign_version + run: | + # Set a version name like "2023.05.26.091805-c1fcb3a". + # Note the use of %ct which gets the timestamp in UTC, in seconds since UNIX epoch to + # avoid time zone differences leading to non-linear versioning. + VERSION="$(TZ=UTC0 git show --quiet --date='format-local:%Y.%m.%d.%H%M%S' --format='%cd')-$(git rev-parse --short=7 HEAD)" + echo "VERSION_NAME=$VERSION" >> gradle.properties + cat gradle.properties + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Publish the artifacts + run: | + gradle clean publish --stacktrace + + - name: Tag Tempest repo + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_tag: ${{ steps.assign_version.outputs.version }} diff --git a/.github/workflows/Docs.yaml b/.github/workflows/Docs.yaml deleted file mode 100644 index 79e2ea651..000000000 --- a/.github/workflows/Docs.yaml +++ /dev/null @@ -1,12 +0,0 @@ -name: Docs -on: - pull_request: - paths: - - 'docs/**' - - '*.md' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - run: 'echo "No build required for docs"' diff --git a/build.gradle.kts b/build.gradle.kts index 179815a24..989f8bb59 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,148 +2,141 @@ import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.jetbrains.dokka.gradle.DokkaTask -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.net.URL buildscript { - repositories { - mavenCentral() - maven(url = "https://plugins.gradle.org/m2/") - } - - dependencies { - classpath(libs.dokkaGradlePlugin) - classpath(libs.junitGradlePlugin) - classpath(libs.kotlinGradlePlugin) - classpath(libs.mavenPublishGradlePlugin) - classpath(libs.wireGradlePlugin) - } + repositories { + mavenCentral() + gradlePluginPortal() + } + + dependencies { + classpath(libs.dokkaGradlePlugin) + classpath(libs.junitGradlePlugin) + classpath(libs.kotlinGradlePlugin) + classpath(libs.mavenPublishGradlePlugin) + classpath(libs.wireGradlePlugin) + } } apply(plugin = "com.vanniktech.maven.publish.base") allprojects { - group = project.property("GROUP") as String - version = project.property("VERSION_NAME") as String -} - -subprojects { - if (project.name == "tempest-bom") return@subprojects - - apply(plugin = "org.jetbrains.dokka") - - repositories { - mavenCentral() - maven(url = "https://s3-us-west-2.amazonaws.com/dynamodb-local/release") - } - - // Only apply if the project has the kotlin plugin added: - plugins.withType { - val compileKotlin by tasks.getting(KotlinCompile::class) { - kotlinOptions { - jvmTarget = "1.8" - allWarningsAsErrors = false - freeCompilerArgs = listOf("-Xjvm-default=all") - } + group = "app.cash.tempest" + version = project.findProperty("VERSION_NAME") as? String ?: "0.0-SNAPSHOT" + + plugins.withId("com.vanniktech.maven.publish.base") { + configure { + publishToMavenCentral(SonatypeHost.DEFAULT, automaticRelease = true) + signAllPublications() + pom { + description.set("Typesafe DynamoDB in Kotlin") + name.set(project.name) + url.set("https://github.com/cashapp/tempest/") + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } } - val compileTestKotlin by tasks.getting(KotlinCompile::class) { - kotlinOptions { - jvmTarget = "1.8" - allWarningsAsErrors = false - } + scm { + url.set("https://github.com/cashapp/tempest/") + connection.set("scm:git:git://github.com/cashapp/tempest.git") + developerConnection.set("scm:git:ssh://git@github.com/cashapp/tempest.git") } - - dependencies { - // add("api", project(":tempest-bom")) - add("api", platform(libs.nettyBom)) + developers { + developer { + id.set("square") + name.set("Square, Inc.") + } } + } + } + } +} + +subprojects { + if (project.name == "tempest-bom") return@subprojects + + apply(plugin = "org.jetbrains.dokka") + + repositories { + mavenCentral() + maven(url = "https://s3-us-west-2.amazonaws.com/dynamodb-local/release") + } + + // Only apply if the project has the kotlin plugin added: + plugins.withType { + tasks.withType { + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + // dependsOn("spotlessKotlinApply") } tasks.withType { - sourceCompatibility = JavaVersion.VERSION_1_8.toString() - targetCompatibility = JavaVersion.VERSION_1_8.toString() + sourceCompatibility = JavaVersion.VERSION_1_8.toString() + targetCompatibility = JavaVersion.VERSION_1_8.toString() } - tasks.withType { - useJUnitPlatform() - testLogging { - events("started", "passed", "skipped", "failed") - exceptionFormat = TestExceptionFormat.FULL - showExceptions = true - showStackTraces = true - } - jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") + dependencies { + // add("api", project(":tempest-bom")) + add("api", platform(libs.nettyBom)) } + } + + tasks.withType { + useJUnitPlatform() + testLogging { + events("started", "passed", "skipped", "failed") + exceptionFormat = TestExceptionFormat.FULL + showExceptions = true + showStackTraces = true + } + jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") + } + // We have to set the dokka configuration after evaluation since the com.vanniktech.maven.publish + // plugin overwrites our dokka configuration on projects where it's applied. + afterEvaluate { tasks.withType().configureEach { - dokkaSourceSets.configureEach { - reportUndocumented.set(false) - skipDeprecated.set(true) - jdkVersion.set(8) - if (name == "dokkaGfm" || name == "dokkaHtml") { - outputDirectory.set(project.file("$rootDir/docs/1.x")) - } + val dokkaTask = this + dokkaSourceSets.configureEach { + reportUndocumented.set(false) + skipDeprecated.set(true) + jdkVersion.set(8) externalDocumentationLink { - url.set(URL("https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/")) - packageListUrl.set(URL("https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/package-list")) - + url.set(URL("https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/")) + packageListUrl.set( + URL("https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/package-list") + ) } - // externalDocumentationLink { - // url.set(URL("https://sdk.amazonaws.com/java/api/latest/")) - // } + if (dokkaTask.name == "dokkaGfm") { + outputDirectory.set(project.file("$rootDir/docs/0.x")) } + } } - // SLF4J uses the classpath to decide which logger to use! Banish the Log4J to prevent this: - // org.apache.logging.slf4j.Log4jLogger cannot be cast to class ch.qos.logback.classic.Logger - configurations.all { - exclude(group = "org.apache.logging.log4j", module = "log4j-slf4j-impl") - } - - // Workaround the Gradle bug resolving multiplatform dependencies. - // https://github.com/square/okio/issues/647 - configurations.all { - if (name.contains("kapt") || name.contains("wire") || name.contains("proto")) { - attributes.attribute( - Usage.USAGE_ATTRIBUTE, - this@subprojects.objects.named(Usage::class, Usage.JAVA_RUNTIME) - ) - } + } + + // SLF4J uses the classpath to decide which logger to use! Banish the Log4J to prevent this: + // org.apache.logging.slf4j.Log4jLogger cannot be cast to class ch.qos.logback.classic.Logger + configurations.all { + exclude(group = "org.apache.logging.log4j", module = "log4j-slf4j-impl") + } + + // Workaround the Gradle bug resolving multiplatform dependencies. + // https://github.com/square/okio/issues/647 + configurations.all { + if (name.contains("kapt") || name.contains("wire") || name.contains("proto")) { + attributes.attribute( + Usage.USAGE_ATTRIBUTE, + this@subprojects.objects.named(Usage::class, Usage.JAVA_RUNTIME) + ) } + } } - -allprojects { - plugins.withId("com.vanniktech.maven.publish.base") { - val publishingExtension = extensions.getByType(PublishingExtension::class.java) - configure { - publishToMavenCentral(SonatypeHost.DEFAULT, automaticRelease = true) - signAllPublications() - pom { - description.set("Typesafe DynamoDB in Kotlin") - name.set(project.name) - url.set("https://github.com/cashapp/tempest/") - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") - } - } - scm { - url.set("https://github.com/cashapp/tempest/") - connection.set("scm:git:git://github.com/cashapp/tempest.git") - developerConnection.set("scm:git:ssh://git@github.com/cashapp/tempest.git") - } - developers { - developer { - id.set("square") - name.set("Square, Inc.") - } - } - } - } - } -} - diff --git a/gradle-mvn-publish.gradle.old b/gradle-mvn-publish.gradle.old deleted file mode 100644 index 54138a3ab..000000000 --- a/gradle-mvn-publish.gradle.old +++ /dev/null @@ -1,28 +0,0 @@ -apply plugin: "com.vanniktech.maven.publish" - -plugins.withId("com.vanniktech.maven.publish") { - mavenPublish { - releaseSigningEnabled = !getGpgKey().isEmpty() - } -} - -publishing { - repositories { - maven { - def releasesRepoUrl = "$buildDir/localMaven" - def snapshotsRepoUrl = "$buildDir/localMaven" - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - } - } -} - -def getGpgKey() { - return hasProperty('signingKey') ? signingKey : "" -} - -signing { - def signingKey = getGpgKey() - if (!signingKey.isEmpty()) { - useInMemoryPgpKeys(signingKey, "") - } -} diff --git a/gradle.properties b/gradle.properties index 447291c33..445699286 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,5 @@ kotlin.code.style=official -GROUP=app.cash.tempest -VERSION_NAME=1.10.3 - -#org.gradle.jvmargs=-Xmx2024m - org.gradle.caching=true org.gradle.parallel=true org.gradle.vfs.watch=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0c974d7c4..f973c055b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,6 @@ [versions] ktlint = "0.40.0" +kotlin = "1.7.10" [libraries] assertj = { module = "org.assertj:assertj-core", version = "3.23.1" } @@ -17,15 +18,15 @@ junit4Api = { module = "junit:junit", version = "4.13.2" } junitApi = { module = "org.junit.jupiter:junit-jupiter-api", version = "5.8.2" } junitEngine = { module = "org.junit.jupiter:junit-jupiter-engine", version = "5.8.2" } junitGradlePlugin = { module = "org.junit.platform:junit-platform-gradle-plugin", version = "1.2.0" } -kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version = "1.7.10" } -kotlinReflection = { module = "org.jetbrains.kotlin:kotlin-reflect", version = "1.7.10" } -kotlinStdLib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version = "1.7.10" } +kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +kotlinReflection = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } +kotlinStdLib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } kotlinxCoroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.4" } kotlinxCoroutinesJdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8", version = "1.6.4" } kotlinxCoroutinesReactive = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactive", version = "1.6.4" } log4jCore = { module = "org.apache.logging.log4j:log4j-core", version = "2.17.1" } loggingApi = { module = "io.github.microutils:kotlin-logging", version = "2.0.10" } -mavenPublishGradlePlugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.25.1" } +mavenPublishGradlePlugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.25.2" } nettyBom = { module = "io.netty:netty-bom", version = "4.1.79.Final" } -okio = { module = "com.squareup.okio:okio", version = "3.2.0" } -wireGradlePlugin = { module = "com.squareup.wire:wire-gradle-plugin", version = "4.4.0" } +okio = { module = "com.squareup.okio:okio", version = "3.4.0" } +wireGradlePlugin = { module = "com.squareup.wire:wire-gradle-plugin", version = "4.8.1" } diff --git a/samples/guides2/src/main/java/app/cash/tempest2/guides/java/Transaction.java b/samples/guides2/src/main/java/app/cash/tempest2/guides/java/Transaction.java index 84b35b75e..9678c2437 100644 --- a/samples/guides2/src/main/java/app/cash/tempest2/guides/java/Transaction.java +++ b/samples/guides2/src/main/java/app/cash/tempest2/guides/java/Transaction.java @@ -28,6 +28,7 @@ import java.util.Map; import kotlin.Unit; import kotlin.jvm.functions.Function0; +import org.jetbrains.annotations.NotNull; import software.amazon.awssdk.enhanced.dynamodb.Expression; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -155,4 +156,8 @@ class AlbumTrackWritingPagerHandler implements WritingPager.Handler