Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build issues #6424

Merged
merged 7 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion .github/workflows/pre-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ jobs:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'

- name: Assemble and publish artifacts to Maven Local
uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2
with:
gradle-home-cache-cleanup: true
arguments: publishToMavenLocal
Copy link
Member

Choose a reason for hiding this comment

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

Is this better than make the functionalTest depend on publishToMavebLocal?

Copy link
Member Author

@3flex 3flex Aug 30, 2023

Choose a reason for hiding this comment

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

You're right, but I couldn't find a way to do that while the plugin is an included build, so this seemed the next best option.

Skipping this step when running locally may lead to confusion (though that's no different to the current situation) but CI will at least be ok.

Copy link
Member

Choose a reason for hiding this comment

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

Could a similar switcheroo be done here? cashapp/paparazzi#924

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't know there was prior art but there's this draft PR open already to do the same: #6415

I might look at what they did in cashapp org since they often end up setting unofficial standard ways of doing things.


- name: Build detekt
uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2
with:
gradle-home-cache-cleanup: true
arguments: build -x detekt publishToMavenLocal
arguments: build -x detekt

- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,9 @@ private fun createGradleRunnerAndSetupProject(
mainBuildFileContent = """
subprojects {
repositories {
mavenLocal()
mavenCentral()
google()
mavenLocal()
}
}
""".trimIndent(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ private fun setupProject(projectLayoutAction: ProjectLayout.() -> Unit): DslGrad
mainBuildFileContent = """
subprojects {
repositories {
mavenLocal()
mavenCentral()
google()
mavenLocal()
}
}
""".trimIndent(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ class DetektReportMergeSpec {
assertThat(result.output).containsIgnoringWhitespaces(
"""
Execution failed for task ':child1:detekt'.
> Analysis failed with 2 weighted issues.
> Analysis failed with 2 issues.
""".trimIndent()
)
assertThat(result.output).containsIgnoringWhitespaces(
"""
Execution failed for task ':child2:detekt'.
> Analysis failed with 4 weighted issues.
> Analysis failed with 4 issues.
""".trimIndent()
)
assertThat(projectFile("build/reports/detekt/detekt.sarif")).doesNotExist()
Expand Down Expand Up @@ -121,13 +121,13 @@ class DetektReportMergeSpec {
assertThat(result.output).containsIgnoringWhitespaces(
"""
Execution failed for task ':child1:detekt'.
> Analysis failed with 2 weighted issues.
> Analysis failed with 2 issues.
""".trimIndent()
)
assertThat(result.output).containsIgnoringWhitespaces(
"""
Execution failed for task ':child2:detekt'.
> Analysis failed with 4 weighted issues.
> Analysis failed with 4 issues.
""".trimIndent()
)
assertThat(projectFile("build/reports/detekt/detekt.xml")).doesNotExist()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DetektTaskSpec {
.build()

gradleRunner.runDetektTaskAndExpectFailure { result ->
assertThat(result.output).contains("Analysis failed with 15 weighted issues.")
assertThat(result.output).contains("Analysis failed with 15 issues.")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class JvmSpec {
.withArguments("detektMain")
.buildAndFail()

assertThat(result.output).contains("failed with 3 weighted issues.")
assertThat(result.output).contains("failed with 3 issues.")
assertThat(result.output).contains(
"Do not directly exit the process outside the `main` function. Throw an exception(...)"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ class ReportMergeSpec {

allprojects {
repositories {
mavenLocal()
mavenCentral()
google()
mavenLocal()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
}

repositories {
mavenCentral()
mavenLocal()
mavenCentral()
}

tasks.detektMain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,5 @@ abstract class DetektGenerateConfigTask @Inject constructor(
}
}

@Suppress("UnnecessaryAbstractClass")
abstract class SingleExecutionBuildService : BuildService<BuildServiceParameters.None>
interface SingleExecutionBuildService : BuildService<BuildServiceParameters.None>
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DetektPlugin : Plugin<Project> {
)

extension.reportsDir = project.extensions.getByType(ReportingExtension::class.java).file("detekt")
extension.basePath = project.rootProject.layout.projectDirectory.asFile.absolutePath

val defaultConfigFile =
project.file("${project.rootProject.layout.projectDirectory.dir(CONFIG_DIR_NAME)}/$CONFIG_FILE")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ constructor(

@Language("yaml")
private val configFileContent = """
build:
maxIssues: 5
style:
MagicNumber:
active: true
Expand Down