Skip to content

Commit 8606930

Browse files
igorwojdarenovate[bot]nataliapeterwas10-nyguiguegon
authored
Merge main to develop (#834)
* Upgrade version to 0.13.0 * Update check kttx snippets * Update check kttx snippets * Update check kttx snippets * Update version * Update scripts * Update scripts * Update dev readme * Release `v0.13.0` (#688) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Igor Wojda <igor.wojda@gmail.com> Co-authored-by: NataliaPeterwas <111683562+nataliapeterwas@users.noreply.github.com> Co-authored-by: Jony Sarco <jfe.sarco@gmail.com> * Revert "Release `v0.13.0`" (#689) * Update Konsist in starter projects to Konsist `v0.13.0` (#697) * Update Kotest Snippets (#701) * Replace REGEX to allow using .. as wildcard again (#720) * Update README.md (#771) * Fixed broken link to the getting started guide. (#827) * Fix wrong detection of Git root project dir (#831) Detection never worked before because Git creates directory called '.git', while code was checking 'git'. * Fix test * Disable KMP starter projects --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: NataliaPeterwas <111683562+nataliapeterwas@users.noreply.github.com> Co-authored-by: Jony Sarco <jfe.sarco@gmail.com> Co-authored-by: Guillermo Guerrero González <3263397+guiguegon@users.noreply.github.com> Co-authored-by: Atiq Ur Rehman <6600985@gmail.com> Co-authored-by: Piotr Kubowicz <piotr.kubowicz@gmail.com>
1 parent 6d38511 commit 8606930

File tree

11 files changed

+293
-102
lines changed

11 files changed

+293
-102
lines changed

.github/workflows/check-starter-projects.yml

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -506,79 +506,79 @@ jobs:
506506
- name: Run Konsist Test
507507
run: cd samples/starter-projects/konsist-starter-spring-maven-kotest/ && mvn test
508508

509-
konsist-starter-kmp-gradle-kotlin-junit5:
510-
name: Konsist Starter KMP Gradle Kotlin Junit 5
511-
needs: get-github-context
512-
runs-on: ubuntu-latest
513-
if: |
514-
startsWith(needs.get-github-context.outputs.current_branch, 'release/') ||
515-
startsWith(needs.get-github-context.outputs.current_branch, 'renovate/') ||
516-
contains(needs.get-github-context.outputs.current_branch, 'starter-projects') ||
517-
needs.get-github-context.outputs.base_ref_branch == 'main' ||
518-
contains(needs.get-github-context.outputs.all_changed_files, 'samples/starter-projects/')
519-
steps:
520-
- name: Checkout
521-
uses: actions/checkout@v4
522-
523-
- name: Set up JDK
524-
uses: actions/setup-java@v3
525-
with:
526-
java-version: 19
527-
distribution: 'zulu'
528-
529-
- name: Set up Python
530-
uses: actions/setup-python@v4
531-
with:
532-
python-version: '3.11.3'
533-
534-
- name: Add Maven Local Repository
535-
run: python3 scripts/replace_konsist_version/add_maven_local_repository_to_config_file.py samples/starter-projects/konsist-starter-kmp-gradle-kotlin-junit5/build.gradle.kts
536-
537-
- name: Replace Konsist Version
538-
run: python3 scripts/replace_konsist_version/replace_konsist_version_gradle_groovy.py samples/starter-projects/konsist-starter-kmp-gradle-kotlin-junit5/build.gradle.kts
539-
540-
- name: Publish Konsist Artifact To Local Maven Repository
541-
run: >
542-
./gradlew publishToMavenLocal
543-
544-
- name: Run Konsist Test
545-
run: cd samples/starter-projects/konsist-starter-kmp-gradle-kotlin-junit5/ && ./gradlew test
546-
547-
548-
konsist-starter-kmp-gradle-kotlin-kotest:
549-
name: Konsist Starter KMP Gradle Kotlin KoTest
550-
needs: get-github-context
551-
runs-on: ubuntu-latest
552-
if: |
553-
startsWith(needs.get-github-context.outputs.current_branch, 'release/') ||
554-
startsWith(needs.get-github-context.outputs.current_branch, 'renovate/') ||
555-
contains(needs.get-github-context.outputs.current_branch, 'starter-projects') ||
556-
needs.get-github-context.outputs.base_ref_branch == 'main' ||
557-
contains(needs.get-github-context.outputs.all_changed_files, 'samples/starter-projects/')
558-
steps:
559-
- name: Checkout
560-
uses: actions/checkout@v4
561-
562-
- name: Set up JDK
563-
uses: actions/setup-java@v3
564-
with:
565-
java-version: 19
566-
distribution: 'zulu'
567-
568-
- name: Set up Python
569-
uses: actions/setup-python@v4
570-
with:
571-
python-version: '3.11.3'
572-
573-
- name: Add Maven Local Repository
574-
run: python3 scripts/replace_konsist_version/add_maven_local_repository_to_config_file.py samples/starter-projects/konsist-starter-kmp-gradle-kotlin-kotest/build.gradle.kts
575-
576-
- name: Replace Konsist Version
577-
run: python3 scripts/replace_konsist_version/replace_konsist_version_gradle_groovy.py samples/starter-projects/konsist-starter-kmp-gradle-kotlin-kotest/build.gradle.kts
578-
579-
- name: Publish Konsist Artifact To Local Maven Repository
580-
run: >
581-
./gradlew publishToMavenLocal
582-
583-
- name: Run Konsist Test
584-
run: cd samples/starter-projects/konsist-starter-kmp-gradle-kotlin-kotest/ && ./gradlew test
509+
# konsist-starter-kmp-gradle-kotlin-junit5:
510+
# name: Konsist Starter KMP Gradle Kotlin Junit 5
511+
# needs: get-github-context
512+
# runs-on: ubuntu-latest
513+
# if: |
514+
# startsWith(needs.get-github-context.outputs.current_branch, 'release/') ||
515+
# startsWith(needs.get-github-context.outputs.current_branch, 'renovate/') ||
516+
# contains(needs.get-github-context.outputs.current_branch, 'starter-projects') ||
517+
# needs.get-github-context.outputs.base_ref_branch == 'main' ||
518+
# contains(needs.get-github-context.outputs.all_changed_files, 'samples/starter-projects/')
519+
# steps:
520+
# - name: Checkout
521+
# uses: actions/checkout@v4
522+
#
523+
# - name: Set up JDK
524+
# uses: actions/setup-java@v3
525+
# with:
526+
# java-version: 19
527+
# distribution: 'zulu'
528+
#
529+
# - name: Set up Python
530+
# uses: actions/setup-python@v4
531+
# with:
532+
# python-version: '3.11.3'
533+
#
534+
# - name: Add Maven Local Repository
535+
# run: python3 scripts/replace_konsist_version/add_maven_local_repository_to_config_file.py samples/starter-projects/konsist-starter-kmp-gradle-kotlin-junit5/build.gradle.kts
536+
#
537+
# - name: Replace Konsist Version
538+
# run: python3 scripts/replace_konsist_version/replace_konsist_version_gradle_groovy.py samples/starter-projects/konsist-starter-kmp-gradle-kotlin-junit5/build.gradle.kts
539+
#
540+
# - name: Publish Konsist Artifact To Local Maven Repository
541+
# run: >
542+
# ./gradlew publishToMavenLocal
543+
#
544+
# - name: Run Konsist Test
545+
# run: cd samples/starter-projects/konsist-starter-kmp-gradle-kotlin-junit5/ && ./gradlew test
546+
547+
548+
# konsist-starter-kmp-gradle-kotlin-kotest:
549+
# name: Konsist Starter KMP Gradle Kotlin KoTest
550+
# needs: get-github-context
551+
# runs-on: ubuntu-latest
552+
# if: |
553+
# startsWith(needs.get-github-context.outputs.current_branch, 'release/') ||
554+
# startsWith(needs.get-github-context.outputs.current_branch, 'renovate/') ||
555+
# contains(needs.get-github-context.outputs.current_branch, 'starter-projects') ||
556+
# needs.get-github-context.outputs.base_ref_branch == 'main' ||
557+
# contains(needs.get-github-context.outputs.all_changed_files, 'samples/starter-projects/')
558+
# steps:
559+
# - name: Checkout
560+
# uses: actions/checkout@v4
561+
#
562+
# - name: Set up JDK
563+
# uses: actions/setup-java@v3
564+
# with:
565+
# java-version: 19
566+
# distribution: 'zulu'
567+
#
568+
# - name: Set up Python
569+
# uses: actions/setup-python@v4
570+
# with:
571+
# python-version: '3.11.3'
572+
#
573+
# - name: Add Maven Local Repository
574+
# run: python3 scripts/replace_konsist_version/add_maven_local_repository_to_config_file.py samples/starter-projects/konsist-starter-kmp-gradle-kotlin-kotest/build.gradle.kts
575+
#
576+
# - name: Replace Konsist Version
577+
# run: python3 scripts/replace_konsist_version/replace_konsist_version_gradle_groovy.py samples/starter-projects/konsist-starter-kmp-gradle-kotlin-kotest/build.gradle.kts
578+
#
579+
# - name: Publish Konsist Artifact To Local Maven Repository
580+
# run: >
581+
# ./gradlew publishToMavenLocal
582+
#
583+
# - name: Run Konsist Test
584+
# run: cd samples/starter-projects/konsist-starter-kmp-gradle-kotlin-kotest/ && ./gradlew test

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
![Check Workflow](https://github.com/LemonAppDev/konsist/actions/workflows/check.yml/badge.svg)
66
[<img src="https://img.shields.io/maven-central/v/com.lemonappdev/konsist?label=Release"/>](https://central.sonatype.com/artifact/com.lemonappdev/konsist)
77

8-
Konsist is a library that guards the consistency of [Kotlin](https://kotlinlang.org/) projects by promoting the
9-
standardization of the Kotlin codebase. It enforces coding conventions and project architecture. Konsist
10-
tests are written in Kotlin and can be easily integrated with popular testing frameworks such as
11-
[JUnit4](https://junit.org/junit4/), [JUnit5](https://junit.org/junit5/).
8+
Konsist is a linter that guards the consistency of [Kotlin](https://kotlinlang.org/) projects by enforcing a cohesive code structure
9+
and unified architecture. Konsist guards are written in the form of unit tests ([JUnit](https://junit.org/) / [Kotest](https://kotest.io/)).
1210

1311
## Dependencies
1412

@@ -29,11 +27,12 @@ testImplementation "com.lemonappdev:konsist:0.13.0"
2927
```
3028

3129
Check the [Konsist documentation](https://docs.konsist.lemonappdev.com/) to learn more about Konsist and take a
32-
look at [getting started guide](https://docs.konsist.lemonappdev.com/getting-started/gettingstarted).
30+
look at [getting started guide](https://docs.konsist.lemonappdev.com/getting-started/getting-started).
3331

3432
## Examples
3533

36-
Konsist API reflects the structure of Kotlin code. Konsist guards are written in form of unit tests.
34+
Konsist API reflects the structure of Kotlin code. All declarations such as classes, functions, and properties can be
35+
queried and verified with the Konsist API. Take a look at a few examples below.
3736

3837
### General Kotlin Check
3938

@@ -93,6 +92,8 @@ fun `clean architecture layers have correct dependencies`() {
9392
}
9493
```
9594

95+
Check out our [snippet](https://docs.konsist.lemonappdev.com/inspiration/snippets) page for a feast of examples!
96+
9697
## Articles
9798

9899
Read the [Konsist articles](https://docs.konsist.lemonappdev.com/getting-started/getting-started/articles) to gain valuable insights into best practices and strategies for maintaining consistency in your projects.

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
org.gradle.parallel=true
33
org.gradle.daemon=true
44

5-
65
konsist.version=0.13.0

lib/src/main/kotlin/com/lemonappdev/konsist/core/filesystem/rootprovider/GitProjectRootDirResolver.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class GitProjectRootDirResolver(
1313
Description of the '.git' directory https://githowto.com/git_internals_git_directory
1414
*/
1515
override val paths = setOf(
16-
"./.git/config".toOsSeparator(),
17-
"./.git/HEAD".toOsSeparator(),
18-
"./.git/refs".toOsSeparator(),
16+
".git/config".toOsSeparator(),
17+
".git/HEAD".toOsSeparator(),
18+
".git/refs".toOsSeparator(),
1919
)
2020
}

lib/src/main/kotlin/com/lemonappdev/konsist/core/util/LocationUtil.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ object LocationUtil {
1010
* \w = Matches any word char (alpha & underscore).
1111
* + = Match 1 or more of the preceding token.
1212
* | = OR
13+
* \.{2}?= allow using '..' as wildcard optionally (only one accepted)
14+
* \w = Matches any word char (alpha & underscore).
15+
* + = Match 1 or more of the preceding token.
16+
* | = OR
1317
* \.{2} = escaped char '.' (dot) appearing 2 times
1418
* $ = Matches end of string
1519
*/
16-
internal const val REGEX_PACKAGE_NAME_END_TWO_DOTS = "(?:^\\w+|\\w+\\.\\w+)+\\.{2}\$"
20+
internal const val REGEX_PACKAGE_NAME_END_TWO_DOTS = "(?:^\\w+|\\w+\\.\\w+\\.{2}?\\w+|\\w+\\.\\w+)+\\.{2}\$"
1721

1822
/**
1923
* Use '..' as a wildcard for any number of characters.

lib/src/test/kotlin/com/lemonappdev/konsist/api/architecture/LayerTest.kt

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@ class LayerTest {
1919
}
2020
2121
@Test
22-
fun `throws an exception when layer is defined by package without three dots at the end`() {
22+
fun `throws an exception when layer is defined by package without two dots at the end with dots as wildcard`() {
23+
// given
24+
val sut = { Layer("Domain", "package..feature") }
25+
26+
// then
27+
sut shouldThrow KoPreconditionFailedException::class withMessage """
28+
Layer Domain must be defined by package ending with '..'. Now: package..feature .
29+
""".trimIndent()
30+
}
31+
32+
@Test
33+
fun `throws an exception when layer is defined by package with three dots at the end`() {
2334
// given
2435
val sut = { Layer("Domain", "package...") }
2536
@@ -43,11 +54,11 @@ class LayerTest {
4354
@Test
4455
fun `throws an exception when layer is defined by package containing dots with more than two dots at the end`() {
4556
// given
46-
val sut = { Layer("Domain", "first.second.third_p.package....") }
57+
val sut = { Layer("Domain", "first.second..third_p.package....") }
4758
4859
// then
4960
sut shouldThrow KoPreconditionFailedException::class withMessage """
50-
Layer Domain must be defined by package ending with '..'. Now: first.second.third_p.package.... .
61+
Layer Domain must be defined by package ending with '..'. Now: first.second..third_p.package.... .
5162
""".trimIndent()
5263
}
5364
@@ -61,4 +72,26 @@ class LayerTest {
6172
Layer Domain must be defined by package ending with '..'. Now: first.second.third_p.package.... .
6273
""".trimIndent()
6374
}
75+
76+
@Test
77+
fun `do not throw an exception when the package ends with two dots and there are another two dots used as wildcard`() {
78+
// given
79+
val sut = { Layer("Domain", "first.second..package..") }
80+
81+
// then
82+
sut shouldNotThrow KoPreconditionFailedException::class withMessage """
83+
Layer Domain must be defined by package ending with '..'. Now: first.second.third_p.package.... .
84+
""".trimIndent()
85+
}
86+
87+
@Test
88+
fun `throws an exception when the package ends with two dots and there more than two dots used as wildcard`() {
89+
// given
90+
val sut = { Layer("Domain", "first.second..package..feature1..") }
91+
92+
// then
93+
sut shouldThrow KoPreconditionFailedException::class withMessage """
94+
Layer Domain must be defined by package ending with '..'. Now: first.second..package..feature1.. .
95+
""".trimIndent()
96+
}
6497
}

lib/src/test/kotlin/com/lemonappdev/konsist/core/filesystem/rootprovider/GitProjectRootDirResolverTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class GitProjectRootDirResolverTest {
1313
// given
1414
val file = mockk<File>()
1515
val pathVerifier = mockk<PathVerifier>()
16-
every { pathVerifier.verifyPathIfExists(file, "./.git/config") } returns true
17-
every { pathVerifier.verifyPathIfExists(file, "./.git/HEAD") } returns true
18-
every { pathVerifier.verifyPathIfExists(file, "./.git/refs") } returns true
16+
every { pathVerifier.verifyPathIfExists(file, ".git/config") } returns true
17+
every { pathVerifier.verifyPathIfExists(file, ".git/HEAD") } returns true
18+
every { pathVerifier.verifyPathIfExists(file, ".git/refs") } returns true
1919
val sut = GitProjectRootDirResolver(pathVerifier)
2020

2121
// when

samples/starter-projects/konsist-starter-android-gradle-groovy-junit-4/konsistTest/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ dependencies {
3636
// Add JUnit dependency
3737
testImplementation 'junit:junit:4.13.2'
3838

39-
// Add Konsist dependency
4039
testImplementation 'com.lemonappdev:konsist:0.13.0'
40+
41+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
42+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
4143
}

samples/starter-projects/konsist-starter-android-gradle-groovy-junit-5/konsistTest/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ dependencies {
4040

4141
// Add Konsist dependency
4242
testImplementation 'com.lemonappdev:konsist:0.13.0'
43+
44+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
45+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
4346
}

0 commit comments

Comments
 (0)