Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/minor-version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Minor version bump check
on:
pull_request:

jobs:
minor-version-bump-check:
if: github.head_ref == '^v\d+\.\d+.*$' # Only runs on branches starting with vX.X (e.g., v1.2, v1.2.3, v1.2-main)
permissions: {}
runs-on: ubuntu-latest
steps:
- name: Minor version bump check
uses: awslabs/aws-kotlin-repo-tools/.github/actions/minor-version-bump@main
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import aws.sdk.kotlin.gradle.dsl.configureLinting
import aws.sdk.kotlin.gradle.dsl.configureMinorVersionStrategyRules
import aws.sdk.kotlin.gradle.dsl.configureNexus
import aws.sdk.kotlin.gradle.util.typedProp

Expand Down Expand Up @@ -106,3 +107,9 @@ val lintPaths = listOf(
)

configureLinting(lintPaths)
configureMinorVersionStrategyRules(lintPaths)

// Set SDK version from gradle.properties as a system property for 'configureMinorVersionStrategyRules' to use
tasks.withType<JavaExec> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be refined to only a single task using tasks.named("...")

systemProperty("sdkVersion", findProperty("sdkVersion") ?: throw Exception("sdkVersion not set"))
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jsoup-version = "1.20.1"

[libraries]
aws-kotlin-repo-tools-build-support = { module="aws.sdk.kotlin.gradle:build-support", version.ref = "aws-kotlin-repo-tools-version" }
aws-kotlin-repo-tools-ktlint-rules = { module = "aws.sdk.kotlin.gradle:ktlint-rules", version.ref = "aws-kotlin-repo-tools-version" }

kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-version" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin-version" }
Expand Down
18 changes: 18 additions & 0 deletions ktlint-rules/minor-version-strategy/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

plugins {
kotlin("jvm")
}

kotlin {
sourceSets {
main {
dependencies {
implementation(libs.aws.kotlin.repo.tools.ktlint.rules)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

package aws.sdk.kotlin.ktlintrules.minorversionstrategy

import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3
import com.pinterest.ktlint.rule.engine.core.api.RuleProvider
import com.pinterest.ktlint.rule.engine.core.api.RuleSetId
import software.aws.ktlint.rules.apisScheduledForRemovalRule

/**
* Ruleset provider for AWS SDK Kotlin minor-version-bump-specific Ktlint rules.
*/
class MinorVersionStrategyRuleSetProvider : RuleSetProviderV3(RuleSetId("minor-version-strategy-rules")) {
private val sdkVersion = System.getProperty("sdkVersion").split(".")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correctness: this looks at JVM system properties, not Gradle properties right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, I don't think we can access gradle.properties at runtime unless we explicitly read the file. We're setting the Gradle property as a system property here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I missed that, I'm not a fan of that approach but I'm not sure there's anything better

private val majorVersion = sdkVersion[0].toInt()
private val minorVersion = sdkVersion[1].toInt()

override fun getRuleProviders(): Set<RuleProvider> = setOf(
RuleProvider {
// Look for APIs that are scheduled for removal in upcoming minor version
apisScheduledForRemovalRule(majorVersion, minorVersion + 1)
},
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aws.sdk.kotlin.ktlintrules.minorversionstrategy.MinorVersionStrategyRuleSetProvider
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ include(":hll")
include(":hll:hll-codegen")
include(":hll:hll-mapping-core")
include(":services")
include("ktlint-rules:minor-version-strategy")

include(":tests")
include(":tests:codegen")
include(":tests:codegen:event-stream")
Expand Down
Loading