Skip to content

Commit

Permalink
Add check for SNAPSHOT dependencies in PRs to staging
Browse files Browse the repository at this point in the history
  • Loading branch information
Duy Phạm authored and Duy Phạm committed Nov 8, 2024
1 parent ec12b4e commit 5ab3b7c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/BuildTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- 'bug/**'
- 'fix/**'
- 'epic/**'
pull_request:
branches:
- 'staging'

jobs:
build_test:
Expand All @@ -31,6 +34,10 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Check for SNAPSHOT dependencies
if: github.event_name == 'pull_request' && github.base_ref == 'staging'
run: ./gradlew :lib:checkSnapshotDependencies

- name: Setup Android SDK
uses: android-actions/setup-android@v3

Expand Down
22 changes: 22 additions & 0 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@ dependencies {
androidTestImplementation("com.google.mlkit:text-recognition-korean:16.0.1")
}

tasks.register("checkSnapshotDependencies") {
doLast {
val snapshotDependencies = allprojects.flatMap { project ->
project.configurations
.asSequence()
.filter { it.isCanBeResolved }
.flatMap { it.allDependencies }
.filter { it.version?.contains("SNAPSHOT", ignoreCase = true) == true }
.map { "${project.name}:${it.group}:${it.name}:${it.version}" }
.distinct()
.toList()
}

if (snapshotDependencies.isNotEmpty()) {
snapshotDependencies.forEach { println("SNAPSHOT dependency found: $it") }
throw GradleException("SNAPSHOT dependencies found. Remove them before merging to staging.")
} else {
println("No SNAPSHOT dependencies found.")
}
}
}

//region publishing

val ossrhUsername = findProperty("OSSRH_USERNAME") as String?
Expand Down

0 comments on commit 5ab3b7c

Please sign in to comment.