From 0732b24f453a85562c97a1b24997516aa3f67a50 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Fri, 10 Nov 2023 11:54:55 +0100 Subject: [PATCH 01/21] Add toString() tests --- parent-pom/pom.xml | 6 ++++++ project-keeper/pom.xml | 5 +++++ .../com/exasol/projectkeeper/RepoInfoTest.java | 7 +++++++ .../SimpleValidationFindingTest.java | 8 +++++++- .../projectkeeper/mavenrepo/VersionTest.java | 5 +++++ .../sources/AnalyzedMavenSourceTest.java | 7 +++++++ .../sources/AnalyzedSourceImplTest.java | 7 +++++++ .../sources/analyze/golang/GoModFileTest.java | 5 +++++ .../golang/GolangDependencyLicenseTest.java | 7 +++++++ .../NamedDependencyChangeReportTest.java | 7 +++++++ .../dependencies/ProjectWithDependenciesTest.java | 7 +++++++ .../finding/ValidationFindingGroupTest.java | 7 +++++++ shared-model-classes/pom.xml | 5 +++++ .../shared/CrawledMavenProjectTest.java | 6 ++++++ .../shared/MavenProjectCrawlResultTest.java | 8 +++++++- .../shared/config/FixedVersionTest.java | 7 +++++++ .../shared/config/ParentPomRefTest.java | 7 +++++++ .../shared/config/ProjectKeeperConfigTest.java | 6 ++++++ .../projectkeeper/shared/config/SourceTest.java | 7 +++++++ .../shared/config/VersionFromSourceTest.java | 7 +++++++ .../shared/dependencies/LicenseTest.java | 8 ++++++++ .../dependencies/ProjectDependenciesTest.java | 7 +++++++ .../dependencies/ProjectDependencyTest.java | 15 +++++++++++++++ .../dependencychanges/NewDependencyTest.java | 7 +++++++ .../dependencychanges/RemovedDependencyTest.java | 7 +++++++ .../dependencychanges/UpdatedDependencyTest.java | 7 +++++++ 26 files changed, 180 insertions(+), 2 deletions(-) diff --git a/parent-pom/pom.xml b/parent-pom/pom.xml index 95232ecf..cea80bc6 100644 --- a/parent-pom/pom.xml +++ b/parent-pom/pom.xml @@ -207,6 +207,12 @@ 3.15.3 test + + com.jparams + to-string-verifier + 1.4.8 + test + junit diff --git a/project-keeper/pom.xml b/project-keeper/pom.xml index d2b70f53..425c2cd9 100644 --- a/project-keeper/pom.xml +++ b/project-keeper/pom.xml @@ -92,6 +92,11 @@ equalsverifier test + + com.jparams + to-string-verifier + test + org.slf4j diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/RepoInfoTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/RepoInfoTest.java index e6444849..582eb8eb 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/RepoInfoTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/RepoInfoTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class RepoInfoTest { @@ -9,4 +11,9 @@ class RepoInfoTest { void testEqualsContract() { EqualsVerifier.forClass(RepoInfo.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(RepoInfo.class).verify(); + } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/SimpleValidationFindingTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/SimpleValidationFindingTest.java index d4c19190..f7eb3c6b 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/SimpleValidationFindingTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/SimpleValidationFindingTest.java @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test; import com.exasol.projectkeeper.validators.finding.SimpleValidationFinding; +import com.jparams.verifier.tostring.ToStringVerifier; import nl.jqno.equalsverifier.EqualsVerifier; @@ -28,4 +29,9 @@ void testWithoutFix() { void testEqualsContract() { EqualsVerifier.forClass(SimpleValidationFinding.class).verify(); } -} \ No newline at end of file + + @Test + void testToString() { + ToStringVerifier.forClass(SimpleValidationFinding.class).verify(); + } +} diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/mavenrepo/VersionTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/mavenrepo/VersionTest.java index f8ff0082..d397572f 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/mavenrepo/VersionTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/mavenrepo/VersionTest.java @@ -48,4 +48,9 @@ void versionEqual(final String a, final String b) throws UnsupportedVersionForma void testEqualsContract() { EqualsVerifier.forClass(Version.class).verify(); } + + @Test + void testToString() throws UnsupportedVersionFormatException { + assertThat(new Version("1.2.3"), hasToString("1.2.3")); + } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/sources/AnalyzedMavenSourceTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/sources/AnalyzedMavenSourceTest.java index 7263da66..d1d2a7d0 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/sources/AnalyzedMavenSourceTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/sources/AnalyzedMavenSourceTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class AnalyzedMavenSourceTest { @@ -9,4 +11,9 @@ class AnalyzedMavenSourceTest { void testEqualsContract() { EqualsVerifier.forClass(AnalyzedMavenSource.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(AnalyzedMavenSource.class).verify(); + } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/sources/AnalyzedSourceImplTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/sources/AnalyzedSourceImplTest.java index 33afa6c6..cea15643 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/sources/AnalyzedSourceImplTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/sources/AnalyzedSourceImplTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class AnalyzedSourceImplTest { @@ -9,4 +11,9 @@ class AnalyzedSourceImplTest { void testEqualsContract() { EqualsVerifier.forClass(AnalyzedSourceImpl.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(AnalyzedSourceImpl.class).verify(); + } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/sources/analyze/golang/GoModFileTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/sources/analyze/golang/GoModFileTest.java index 45a9e92d..9c99db58 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/sources/analyze/golang/GoModFileTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/sources/analyze/golang/GoModFileTest.java @@ -13,6 +13,8 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class GoModFileTest { @@ -139,5 +141,8 @@ private void assertModFile(final GoModFile file, final String expectedModuleName @Test void testEqualsContract() { EqualsVerifier.forClass(GoModFile.class).verify(); + }@Test + void testToString() { + ToStringVerifier.forClass(GoModFile.class).verify(); } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/sources/analyze/golang/GolangDependencyLicenseTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/sources/analyze/golang/GolangDependencyLicenseTest.java index ce124f26..1add8a5e 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/sources/analyze/golang/GolangDependencyLicenseTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/sources/analyze/golang/GolangDependencyLicenseTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class GolangDependencyLicenseTest { @@ -9,4 +11,9 @@ class GolangDependencyLicenseTest { void testEqualsContract() { EqualsVerifier.forClass(GolangDependencyLicense.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(GolangDependencyLicense.class).verify(); + } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/changesfile/NamedDependencyChangeReportTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/changesfile/NamedDependencyChangeReportTest.java index bf21347d..65ba421b 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/changesfile/NamedDependencyChangeReportTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/changesfile/NamedDependencyChangeReportTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class NamedDependencyChangeReportTest { @@ -9,4 +11,9 @@ class NamedDependencyChangeReportTest { void testEqualsContract() { EqualsVerifier.forClass(NamedDependencyChangeReport.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(NamedDependencyChangeReport.class).verify(); + } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/dependencies/ProjectWithDependenciesTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/dependencies/ProjectWithDependenciesTest.java index df852f83..5d69e358 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/dependencies/ProjectWithDependenciesTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/dependencies/ProjectWithDependenciesTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class ProjectWithDependenciesTest { @@ -9,4 +11,9 @@ class ProjectWithDependenciesTest { void testEqualsContract() { EqualsVerifier.forClass(ProjectWithDependencies.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(ProjectWithDependencies.class).verify(); + } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/finding/ValidationFindingGroupTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/finding/ValidationFindingGroupTest.java index 4b0caedb..365d5b25 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/finding/ValidationFindingGroupTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/finding/ValidationFindingGroupTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class ValidationFindingGroupTest { @@ -9,4 +11,9 @@ class ValidationFindingGroupTest { void testEqualsContract() { EqualsVerifier.forClass(ValidationFindingGroup.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(ValidationFindingGroup.class).verify(); + } } diff --git a/shared-model-classes/pom.xml b/shared-model-classes/pom.xml index 4e743434..ad2a3501 100644 --- a/shared-model-classes/pom.xml +++ b/shared-model-classes/pom.xml @@ -58,6 +58,11 @@ equalsverifier test + + com.jparams + to-string-verifier + test + org.mockito mockito-core diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/CrawledMavenProjectTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/CrawledMavenProjectTest.java index 648d486c..c63ad4e9 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/CrawledMavenProjectTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/CrawledMavenProjectTest.java @@ -3,6 +3,7 @@ import org.junit.jupiter.api.Test; import com.exasol.projectkeeper.shared.mavenprojectcrawler.CrawledMavenProject; +import com.jparams.verifier.tostring.ToStringVerifier; import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.Warning; @@ -12,4 +13,9 @@ class CrawledMavenProjectTest { void testEqualsContract() { EqualsVerifier.forClass(CrawledMavenProject.class).suppress(Warning.NONFINAL_FIELDS).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(CrawledMavenProject.class).verify(); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/MavenProjectCrawlResultTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/MavenProjectCrawlResultTest.java index 76e16d5c..1cf70730 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/MavenProjectCrawlResultTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/MavenProjectCrawlResultTest.java @@ -13,6 +13,7 @@ import com.exasol.projectkeeper.shared.dependencychanges.*; import com.exasol.projectkeeper.shared.mavenprojectcrawler.CrawledMavenProject; import com.exasol.projectkeeper.shared.mavenprojectcrawler.MavenProjectCrawlResult; +import com.jparams.verifier.tostring.ToStringVerifier; import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.Warning; @@ -53,4 +54,9 @@ void testJsonContainsDependencyTypeInfo() { void testEqualsContract() { EqualsVerifier.forClass(MavenProjectCrawlResult.class).suppress(Warning.NONFINAL_FIELDS).verify(); } -} \ No newline at end of file + + @Test + void testToString() { + ToStringVerifier.forClass(MavenProjectCrawlResult.class).verify(); + } +} diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/FixedVersionTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/FixedVersionTest.java index fde4561d..042046e9 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/FixedVersionTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/FixedVersionTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class FixedVersionTest { @@ -9,4 +11,9 @@ class FixedVersionTest { void testEqualsContract() { EqualsVerifier.forClass(FixedVersion.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(FixedVersion.class).verify(); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ParentPomRefTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ParentPomRefTest.java index e2bb5f62..826c5ef5 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ParentPomRefTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ParentPomRefTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class ParentPomRefTest { @@ -9,4 +11,9 @@ class ParentPomRefTest { void testEqualsContract() { EqualsVerifier.forClass(ParentPomRef.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(ParentPomRef.class).verify(); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java index da2fc509..454d1cea 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java @@ -14,6 +14,7 @@ import org.junit.jupiter.api.Test; import com.exasol.projectkeeper.shared.config.VersionConfig.Visitor; +import com.jparams.verifier.tostring.ToStringVerifier; import nl.jqno.equalsverifier.EqualsVerifier; @@ -77,4 +78,9 @@ void fixedVersionAcceptsVisitor() { void testEqualsContract() { EqualsVerifier.forClass(ProjectKeeperConfig.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(ProjectKeeperConfig.class).verify(); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/SourceTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/SourceTest.java index d60da5e9..ae124e9a 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/SourceTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/SourceTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class SourceTest { @@ -9,4 +11,9 @@ class SourceTest { void testEqualsContract() { EqualsVerifier.forClass(Source.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(Source.class).verify(); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/VersionFromSourceTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/VersionFromSourceTest.java index 88ed0504..80e86834 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/VersionFromSourceTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/VersionFromSourceTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class VersionFromSourceTest { @@ -9,4 +11,9 @@ class VersionFromSourceTest { void testEqualsContract() { EqualsVerifier.forClass(VersionFromSource.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(VersionFromSource.class).verify(); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/LicenseTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/LicenseTest.java index 841f3b3a..b0f52f9d 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/LicenseTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/LicenseTest.java @@ -1,5 +1,8 @@ package com.exasol.projectkeeper.shared.dependencies; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasToString; + import org.junit.jupiter.api.Test; import nl.jqno.equalsverifier.EqualsVerifier; @@ -10,4 +13,9 @@ class LicenseTest { void testEqualsContract() { EqualsVerifier.forClass(License.class).suppress(Warning.NONFINAL_FIELDS).verify(); } + + @Test + void testToString() { + assertThat(new License("name", "url"), hasToString("name url")); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/ProjectDependenciesTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/ProjectDependenciesTest.java index e2644419..17eefc02 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/ProjectDependenciesTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/ProjectDependenciesTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.Warning; @@ -10,4 +12,9 @@ class ProjectDependenciesTest { void testEqualsContract() { EqualsVerifier.forClass(ProjectDependencies.class).suppress(Warning.NONFINAL_FIELDS).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(ProjectDependencies.class).verify(); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/ProjectDependencyTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/ProjectDependencyTest.java index a5373027..39372cb7 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/ProjectDependencyTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencies/ProjectDependencyTest.java @@ -1,7 +1,14 @@ package com.exasol.projectkeeper.shared.dependencies; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasToString; + +import java.util.List; + import org.junit.jupiter.api.Test; +import com.exasol.projectkeeper.shared.dependencies.BaseDependency.Type; + import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.Warning; @@ -10,4 +17,12 @@ class ProjectDependencyTest { void testEqualsContract() { EqualsVerifier.forClass(ProjectDependency.class).suppress(Warning.NONFINAL_FIELDS).verify(); } + + @Test + void testToString() { + assertThat( + ProjectDependency.builder().licenses(List.of(new License("lic", "licUrl"))).name("name") + .type(Type.COMPILE).websiteUrl("url").build(), + hasToString("COMPILE dependency 'name', url, 1 licenses: lic licUrl")); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/NewDependencyTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/NewDependencyTest.java index c0defe1a..96faef5b 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/NewDependencyTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/NewDependencyTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class NewDependencyTest { @@ -9,4 +11,9 @@ class NewDependencyTest { void testEqualsContract() { EqualsVerifier.forClass(NewDependency.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(NewDependency.class).verify(); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/RemovedDependencyTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/RemovedDependencyTest.java index f0ac65d4..5f564cb0 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/RemovedDependencyTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/RemovedDependencyTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class RemovedDependencyTest { @@ -9,4 +11,9 @@ class RemovedDependencyTest { void testEqualsContract() { EqualsVerifier.forClass(RemovedDependency.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(RemovedDependency.class).verify(); + } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/UpdatedDependencyTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/UpdatedDependencyTest.java index da5a2f0a..f52d0a98 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/UpdatedDependencyTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/dependencychanges/UpdatedDependencyTest.java @@ -2,6 +2,8 @@ import org.junit.jupiter.api.Test; +import com.jparams.verifier.tostring.ToStringVerifier; + import nl.jqno.equalsverifier.EqualsVerifier; class UpdatedDependencyTest { @@ -9,4 +11,9 @@ class UpdatedDependencyTest { void testEqualsContract() { EqualsVerifier.forClass(UpdatedDependency.class).verify(); } + + @Test + void testToString() { + ToStringVerifier.forClass(UpdatedDependency.class).verify(); + } } From e033b929e5f55d2e76454ce7c857bc65348c07e1 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Fri, 10 Nov 2023 12:00:59 +0100 Subject: [PATCH 02/21] #488: Refactor build configuration --- README.md | 11 ++- .../exasol/projectkeeper/ProjectKeeper.java | 2 +- .../config/ProjectKeeperConfigReader.java | 11 ++- .../config/ProjectKeeperRawConfig.java | 49 ++++++++--- .../files/FileTemplatesFactory.java | 9 +- .../files/ProjectFilesValidator.java | 16 ++-- .../config/ProjectKeeperConfigReaderTest.java | 7 +- .../files/FileTemplatesFactoryTest.java | 6 +- .../files/ProjectFilesValidatorTest.java | 3 +- .../shared/config/BuildConfig.java | 87 +++++++++++++++++++ .../shared/config/ProjectKeeperConfig.java | 50 ++++++----- .../shared/config/BuildConfigTest.java | 20 +++++ .../config/ProjectKeeperConfigTest.java | 11 +-- 13 files changed, 217 insertions(+), 65 deletions(-) create mode 100644 shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java create mode 100644 shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildConfigTest.java diff --git a/README.md b/README.md index 8433ee65..842ad60c 100644 --- a/README.md +++ b/README.md @@ -101,12 +101,17 @@ The syntax for a replacement is `broken-url|replacement`. Project-keeper will then use the replacement in the `dependencies.md` file instead of the original url. -### GitHub Runner Operating System +### CI Build Configuration -Some projects require to run the integration tests in the CI build on an operating system other than the default `ubuntu-latest`. In this case you can add the following to file `.project-keeper.yml`: +PK allows configuring the generated CI-Build workflow scripts using the `build` section in file `.project-keeper.yml`. + +#### GitHub Runner Operating System + +Some projects require to run the integration tests in the CI build on an operating system other than the default `ubuntu-latest`. In this case you can use the following: ```yml -ciBuildRunnerOS: ubuntu-20.04 +build: + runnerOs: ubuntu-20.04 ``` PK will use this setting for GitHub workflows `ci-build.yml` and `release_droid_prepare_original_checksum.yml` which run integration tests. The other workflows don't run integration tests and will stick to the default `ubuntu-latest`. diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/ProjectKeeper.java b/project-keeper/src/main/java/com/exasol/projectkeeper/ProjectKeeper.java index 2d824738..c7170f60 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/ProjectKeeper.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/ProjectKeeper.java @@ -134,7 +134,7 @@ private ValidationPhase phase2(final ValidationPhase.Provision provision) { .logger(this.logger) // .projectKeeperVersion(this.ownVersion) // .hasNpmModule(hasSourceOfType(sources, SourceType.NPM)) // - .ciBuildRunnerOS(config.getCiBuildRunnerOS()) // + .ciBuildConfig(config.getCiBuildConfig()) // .build(); final List validators = List.of( // projectFilesValidator, diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java index dbcf0f24..f99cf07f 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java @@ -12,6 +12,7 @@ import org.yaml.snakeyaml.error.YAMLException; import com.exasol.errorreporting.ExaError; +import com.exasol.projectkeeper.config.ProjectKeeperRawConfig.Build; import com.exasol.projectkeeper.shared.config.*; /** @@ -79,14 +80,13 @@ private ProjectKeeperConfig parseRawConfig(final ProjectKeeperRawConfig rawConfi final List excludes = convertExcludes(rawConfig.getExcludes()); final List linkReplacements = Objects.requireNonNullElseGet(rawConfig.getLinkReplacements(), Collections::emptyList); - final VersionConfig version = parseVersion(rawConfig.getVersion(), projectDir); return ProjectKeeperConfig.builder() // .sources(sources) // .linkReplacements(linkReplacements) // .excludes(excludes) // - .versionConfig(version) // - .ciBuildRunnerOS(rawConfig.getCiBuildRunnerOS()) // + .versionConfig(parseVersion(rawConfig.getVersion(), projectDir)) // + .buildConfig(convertBuildConfig(rawConfig.getBuild())) // .build(); } @@ -109,6 +109,11 @@ private VersionConfig parseVersion(final Object rawVersion, final Path projectDi .toString()); } + private BuildConfig convertBuildConfig(final Build build) { + return BuildConfig.builder() // + .runnerOs(build != null ? build.getRunnerOs() : null).build(); + } + private List convertExcludes(final List rawExcludes) { if (rawExcludes == null) { return Collections.emptyList(); diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java index 6efad78f..73df1556 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java @@ -10,18 +10,18 @@ *

*/ public class ProjectKeeperRawConfig { - private List sources; + private List sources; private List linkReplacements; private List excludes; private Object version; - private String ciBuildRunnerOS; + private Build build; /** * Get the sources. * * @return sources */ - public List getSources() { + public List getSources() { return sources; } @@ -103,21 +103,21 @@ public void setVersion(final Object version) { } /** - * Get CI build runner operating system, e.g. {@code ubuntu-20.04}. + * Get the CI build configuration. * - * @return CI build runner operating system + * @return build configuration */ - public String getCiBuildRunnerOS() { - return ciBuildRunnerOS; + public Build getBuild() { + return build; } /** - * Set CI build runner operating system, e.g. {@code ubuntu-20.04}. Default: {@code ubuntu-latest}. + * Set the CI build configuration. * - * @param ciBuildRunnerOS CI build runner operating system + * @param build build configuration */ - public void setCiBuildRunnerOS(final String ciBuildRunnerOS) { - this.ciBuildRunnerOS = ciBuildRunnerOS; + public void setBuild(final Build build) { + this.build = build; } /** @@ -307,4 +307,31 @@ public void setRelativePath(final String relativePath) { this.relativePath = relativePath; } } + + /** + * Intermediate class for reading the CI build configuration sources. + *

+ * SnakeYML requires this class to be public. + */ + public static class Build { + private String runnerOs; + + /** + * Get CI build runner operating system, e.g. {@code ubuntu-20.04}. + * + * @return CI build runner operating system + */ + public String getRunnerOs() { + return runnerOs; + } + + /** + * Set CI build runner operating system, e.g. {@code ubuntu-20.04}. Default: {@code ubuntu-latest}. + * + * @param ciBuildRunnerOS CI build runner operating system + */ + public void setRunnerOs(final String runnerOs) { + this.runnerOs = runnerOs; + } + } } diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java index 76f3943b..40269f70 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java @@ -8,6 +8,7 @@ import com.exasol.errorreporting.ExaError; import com.exasol.projectkeeper.Logger; +import com.exasol.projectkeeper.shared.config.BuildConfig; import com.exasol.projectkeeper.shared.config.ProjectKeeperModule; import com.exasol.projectkeeper.sources.*; @@ -36,14 +37,14 @@ private static String lines(final String... line) { private final Logger logger; private final String ownVersion; private final boolean hasNpmModule; - private final String ciBuildRunnerOS; + private final BuildConfig buildConfig; public FileTemplatesFactory(final Logger logger, final String ownVersion, final boolean hasNpmModule, - final String ciBuildRunnerOS) { + final BuildConfig buildConfig) { this.logger = Objects.requireNonNull(logger, "logger"); this.ownVersion = Objects.requireNonNull(ownVersion, "ownVersion"); this.hasNpmModule = hasNpmModule; - this.ciBuildRunnerOS = Objects.requireNonNull(ciBuildRunnerOS, CI_BUILD_RUNNER_OS_PLACEHOLDER); + this.buildConfig = Objects.requireNonNull(buildConfig, "buildConfig"); } List getGlobalTemplates(final List sources) { @@ -86,7 +87,7 @@ private List getGenericMavenTemplates(final Set modules) { diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidator.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidator.java index 5b07f2f5..7034dca3 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidator.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidator.java @@ -10,6 +10,7 @@ import com.exasol.errorreporting.ExaError; import com.exasol.projectkeeper.Logger; import com.exasol.projectkeeper.Validator; +import com.exasol.projectkeeper.shared.config.BuildConfig; import com.exasol.projectkeeper.sources.AnalyzedSource; import com.exasol.projectkeeper.validators.files.RequiredFileValidator.ContentValidator; import com.exasol.projectkeeper.validators.finding.ValidationFinding; @@ -24,7 +25,7 @@ public class ProjectFilesValidator implements Validator { private final Logger logger; private final String projectKeeperVersion; private final boolean hasNpmModule; - private final String ciBuildRunnerOS; + private final BuildConfig buildConfig; private ProjectFilesValidator(final Builder builder) { this.projectDirectory = Objects.requireNonNull(builder.projectDirectory, "projectDirectory"); @@ -32,14 +33,14 @@ private ProjectFilesValidator(final Builder builder) { this.logger = Objects.requireNonNull(builder.logger, "logger"); this.projectKeeperVersion = Objects.requireNonNull(builder.projectKeeperVersion, "projectKeeperVersion"); this.hasNpmModule = builder.hasNpmModule; - this.ciBuildRunnerOS = Objects.requireNonNull(builder.ciBuildRunnerOS, "ciBuildRunnerOS"); + this.buildConfig = Objects.requireNonNull(builder.buildConfig, "buildConfig"); } @Override public List validate() { final List findings = new ArrayList<>(); final FileTemplatesFactory templatesFactory = new FileTemplatesFactory(this.logger, this.projectKeeperVersion, - this.hasNpmModule, this.ciBuildRunnerOS); + this.hasNpmModule, this.buildConfig); findings.addAll(validateTemplatesRelativeToRepo(templatesFactory)); findings.addAll(validateTemplatesRelativeToSource(templatesFactory)); return findings; @@ -111,7 +112,7 @@ public static final class Builder { private Logger logger; private String projectKeeperVersion; private boolean hasNpmModule; - private String ciBuildRunnerOS; + private BuildConfig buildConfig; private Builder() { // empty by intention @@ -163,12 +164,11 @@ public Builder hasNpmModule(final boolean value) { } /** - * - * @param ciBuildRunnerOS operating system to use for CI builds + * @param buildConfig CI build configuration * @return {@code this} for fluent programming */ - public Builder ciBuildRunnerOS(final String ciBuildRunnerOS) { - this.ciBuildRunnerOS = ciBuildRunnerOS; + public Builder ciBuildConfig(final BuildConfig buildConfig) { + this.buildConfig = buildConfig; return this; } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java index 4e483e55..86c62ed3 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java @@ -53,13 +53,14 @@ void read() throws IOException { " artifactId: \"my-parent\"\n" + // " version: \"1.2.3\"\n" + // " relativePath: \"./my-parent.xml\"\n" + // - "ciBuildRunnerOS: custom-runner-os\n" + // + "build:\n" + // + " runnerOs: custom-runner-os\n" + // "linkReplacements:\n" + // " - \"http://wrong-url.com|my-dependency.de\"\n"); final ProjectKeeperConfig config = this.reader.readConfig(this.tempDir); final Source source = config.getSources().get(0); assertAll(// - () -> assertThat(config.getCiBuildRunnerOS(), equalTo("custom-runner-os")), + () -> assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("custom-runner-os")), () -> assertThat(source.getType(), equalTo(MAVEN)), () -> assertThat(source.isAdvertised(), equalTo(false)), () -> assertThat(source.getPath(), equalTo(this.tempDir.resolve("my-sub-project/pom.xml"))), @@ -91,7 +92,7 @@ void readDefaults() throws IOException { () -> assertThat(source.getModules(), Matchers.containsInAnyOrder(DEFAULT)), () -> assertThat(source.getParentPom(), nullValue()), () -> assertThat(config.getExcludes(), equalTo(Collections.emptyList())), - () -> assertThat(config.getCiBuildRunnerOS(), equalTo("ubuntu-latest")), + () -> assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("ubuntu-latest")), () -> assertThat(config.getLinkReplacements(), equalTo(Collections.emptyList()))// ); } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactoryTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactoryTest.java index 87d42cbc..d8105685 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactoryTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactoryTest.java @@ -20,6 +20,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import com.exasol.projectkeeper.Logger; +import com.exasol.projectkeeper.shared.config.BuildConfig; import com.exasol.projectkeeper.shared.config.ProjectKeeperModule; import com.exasol.projectkeeper.sources.AnalyzedMavenSource; import com.exasol.projectkeeper.sources.AnalyzedSource; @@ -47,7 +48,8 @@ private FileTemplatesFactory testee() { } private FileTemplatesFactory testee(final boolean hasNpmModule) { - return new FileTemplatesFactory(loggerMock, OWN_VERSION, hasNpmModule, "ci-build-runner-os"); + return new FileTemplatesFactory(this.loggerMock, OWN_VERSION, hasNpmModule, + BuildConfig.builder().runnerOs("ci-build-runner-os").build()); } private List getMavenSourceWithModules(final Set modules) { @@ -65,7 +67,7 @@ void testGetCiBuildTemplatesForNonAggregatedMvnProject() { final List templates = testee().getGlobalTemplates(sources); assertFalse(() -> templates.stream() .anyMatch(template -> template.getPathInProject().equals(Path.of(".github/workflows/ci-build.yml")))); - verify(loggerMock).warn( + verify(this.loggerMock).warn( "W-PK-CORE-91: For this project structure project keeper does not know how to configure ci-build. Please create the required actions on your own."); } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidatorTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidatorTest.java index 34d68712..cc4bf9fe 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidatorTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidatorTest.java @@ -21,6 +21,7 @@ import org.junit.jupiter.api.io.TempDir; import com.exasol.projectkeeper.Logger; +import com.exasol.projectkeeper.shared.config.BuildConfig; import com.exasol.projectkeeper.shared.config.ProjectKeeperModule; import com.exasol.projectkeeper.sources.AnalyzedMavenSource; import com.exasol.projectkeeper.sources.AnalyzedSource; @@ -157,7 +158,7 @@ private ProjectFilesValidator testee(final List sources) { .analyzedSources(sources) // .logger(mock(Logger.class)) // .projectKeeperVersion(OWN_VERSION) // - .ciBuildRunnerOS("ci-runner-os") // + .ciBuildConfig(BuildConfig.builder().runnerOs("ci-runner-os").build()) // .build(); } diff --git a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java new file mode 100644 index 00000000..584d8d17 --- /dev/null +++ b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java @@ -0,0 +1,87 @@ +package com.exasol.projectkeeper.shared.config; + +import java.util.Objects; + +/** + * CI build configuration. + */ +public final class BuildConfig { + private static final String DEFAULT_RUNNER_OS = "ubuntu-latest"; + + private final String runnerOs; + + private BuildConfig(final Builder builder) { + this.runnerOs = Objects.requireNonNull(builder.runnerOs, "runnerOs"); + } + + /** @return CI build runner operating system */ + public String getRunnerOs() { + return this.runnerOs; + } + + /** + * Creates builder to build {@link BuildConfig}. + * + * @return created builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Builder to build {@link BuildConfig}. + */ + public static final class Builder { + private String runnerOs = DEFAULT_RUNNER_OS; + + private Builder() { + } + + /** + * CI build runner operating system, e.g. {@code ubuntu-latest}. + * + * @param runnerOs runner operating system + * @return {@code this} for fluent programming + */ + public Builder runnerOs(final String runnerOs) { + if (runnerOs != null) { + this.runnerOs = runnerOs; + } + return this; + } + + /** + * Build a new {@link BuildConfig}. + * + * @return built class + */ + public BuildConfig build() { + return new BuildConfig(this); + } + } + + @Override + public String toString() { + return "BuildConfig [runnerOs=" + runnerOs + "]"; + } + + @Override + public int hashCode() { + return Objects.hash(runnerOs); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final BuildConfig other = (BuildConfig) obj; + return Objects.equals(runnerOs, other.runnerOs); + } +} diff --git a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java index 4e16f077..5bb68f75 100644 --- a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java +++ b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java @@ -8,46 +8,45 @@ * Use {@link ProjectKeeperConfig#builder()} for creating new instances. */ public final class ProjectKeeperConfig { - private static final String DEFAULT_CI_BUILD_RUNNER_OS = "ubuntu-latest"; private final List sources; private final List linkReplacements; // [impl->dsn~excluding~1] private final List excludes; private final VersionConfig versionConfig; - private final String ciBuildRunnerOS; + private final BuildConfig buildConfig; private ProjectKeeperConfig(final Builder builder) { - this.sources = builder.sources; - this.linkReplacements = builder.linkReplacements; - this.excludes = builder.excludes; + this.sources = Objects.requireNonNull(builder.sources, "sources"); + this.linkReplacements = Objects.requireNonNull(builder.linkReplacements, "linkReplacements"); + this.excludes = Objects.requireNonNull(builder.excludes, "excludes"); this.versionConfig = builder.versionConfig; - this.ciBuildRunnerOS = builder.ciBuildRunnerOS; + this.buildConfig = Objects.requireNonNull(builder.buildConfig, "buildConfig"); } /** @return List with source-projects to crawl */ public List getSources() { - return sources; + return this.sources; } /** @return List of replacements for broken links */ public List getLinkReplacements() { - return linkReplacements; + return this.linkReplacements; } /** @return List of regular expressions that match validation messages to exclude */ public List getExcludes() { - return excludes; + return this.excludes; } /** @return project version configuration */ public VersionConfig getVersionConfig() { - return versionConfig; + return this.versionConfig; } - /** @return CI build runner operating system */ - public String getCiBuildRunnerOS() { - return ciBuildRunnerOS; + /** @return CI build configuration */ + public BuildConfig getCiBuildConfig() { + return this.buildConfig; } /** @return a new builder for creating {@link ProjectKeeperConfig} instances */ @@ -63,7 +62,7 @@ public static class Builder { private List linkReplacements = Collections.emptyList(); private List excludes = Collections.emptyList(); private VersionConfig versionConfig; - private String ciBuildRunnerOS = DEFAULT_CI_BUILD_RUNNER_OS; + private BuildConfig buildConfig = BuildConfig.builder().build(); private Builder() { // empty by intention @@ -106,12 +105,12 @@ public ProjectKeeperConfig.Builder versionConfig(final VersionConfig versionConf } /** - * @param ciBuildRunnerOS operating system for CI builds (default: {@code ubuntu-latest}) + * @param buildConfig project build configuration * @return {@code this}. */ - public ProjectKeeperConfig.Builder ciBuildRunnerOS(final String ciBuildRunnerOS) { - if (ciBuildRunnerOS != null) { - this.ciBuildRunnerOS = ciBuildRunnerOS; + public ProjectKeeperConfig.Builder buildConfig(final BuildConfig buildConfig) { + if (buildConfig != null) { + this.buildConfig = buildConfig; } return this; } @@ -124,13 +123,14 @@ public ProjectKeeperConfig build() { @Override public String toString() { - return "ProjectKeeperConfig [sources=" + sources + ", linkReplacements=" + linkReplacements + ", excludes=" - + excludes + ", versionConfig=" + versionConfig + "]"; + return "ProjectKeeperConfig [sources=" + this.sources + ", linkReplacements=" + this.linkReplacements + + ", excludes=" + this.excludes + ", versionConfig=" + this.versionConfig + ", buildConfig=" + + this.buildConfig + "]"; } @Override public int hashCode() { - return Objects.hash(sources, linkReplacements, excludes, versionConfig, ciBuildRunnerOS); + return Objects.hash(this.sources, this.linkReplacements, this.excludes, this.versionConfig, this.buildConfig); } @Override @@ -145,8 +145,10 @@ public boolean equals(final Object obj) { return false; } final ProjectKeeperConfig other = (ProjectKeeperConfig) obj; - return Objects.equals(sources, other.sources) && Objects.equals(linkReplacements, other.linkReplacements) - && Objects.equals(excludes, other.excludes) && Objects.equals(versionConfig, other.versionConfig) - && Objects.equals(ciBuildRunnerOS, other.ciBuildRunnerOS); + return Objects.equals(this.sources, other.sources) + && Objects.equals(this.linkReplacements, other.linkReplacements) + && Objects.equals(this.excludes, other.excludes) + && Objects.equals(this.versionConfig, other.versionConfig) + && Objects.equals(this.buildConfig, other.buildConfig); } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildConfigTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildConfigTest.java new file mode 100644 index 00000000..b0c818c4 --- /dev/null +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildConfigTest.java @@ -0,0 +1,20 @@ +package com.exasol.projectkeeper.shared.config; + +import org.junit.jupiter.api.Test; + +import com.jparams.verifier.tostring.ToStringVerifier; + +import nl.jqno.equalsverifier.EqualsVerifier; + +class BuildConfigTest { + + @Test + void testEqualsContract() { + EqualsVerifier.forClass(BuildConfig.class).verify(); + } + + @Test + void testToString() { + ToStringVerifier.forClass(BuildConfig.class).verify(); + } +} diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java index 454d1cea..f578d7cf 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java @@ -29,11 +29,12 @@ void createConfig() { "parentRelativePath")) .build())) .excludes(List.of("exclude1")).linkReplacements(List.of("linkReplacement1")) - .versionConfig(new VersionFromSource(Path.of("version-pom.xml"))).ciBuildRunnerOS("runner-os").build(); + .versionConfig(new VersionFromSource(Path.of("version-pom.xml"))) + .buildConfig(BuildConfig.builder().runnerOs("runner-os").build()).build(); assertAll(() -> assertThat(config.getExcludes(), contains("exclude1")), () -> assertThat(config.getLinkReplacements(), contains("linkReplacement1")), () -> assertThat(config.getVersionConfig(), instanceOf(VersionFromSource.class)), - () -> assertThat(config.getCiBuildRunnerOS(), equalTo("runner-os")), + () -> assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("runner-os")), () -> assertThat(config.getSources(), hasSize(1)), () -> assertThat(config.getSources().get(0).getType(), equalTo(SourceType.MAVEN)), () -> assertThat(config.getSources().get(0).getPath(), equalTo(Path.of("pom.xml"))), @@ -49,13 +50,13 @@ void createConfig() { @Test void createConfigWithDefaultRunnerOS() { final ProjectKeeperConfig config = ProjectKeeperConfig.builder().build(); - assertThat(config.getCiBuildRunnerOS(), equalTo("ubuntu-latest")); + assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("ubuntu-latest")); } @Test void createConfigWithNullRunnerOS() { - final ProjectKeeperConfig config = ProjectKeeperConfig.builder().ciBuildRunnerOS(null).build(); - assertThat(config.getCiBuildRunnerOS(), equalTo("ubuntu-latest")); + final ProjectKeeperConfig config = ProjectKeeperConfig.builder().buildConfig(null).build(); + assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("ubuntu-latest")); } @Test From 15637b7bbff48e3f8b8071b6bd7e11ac97f21d7a Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Fri, 10 Nov 2023 12:01:59 +0100 Subject: [PATCH 03/21] Add changelog entry --- doc/changes/changes_2.9.16.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/changes/changes_2.9.16.md b/doc/changes/changes_2.9.16.md index d4464784..a0f8b83e 100644 --- a/doc/changes/changes_2.9.16.md +++ b/doc/changes/changes_2.9.16.md @@ -1,4 +1,4 @@ -# Project Keeper 2.9.16, released 2023-??-?? +# Project Keeper 2.9.16, released 2023-11-10 Code name: Support Matrix builds & enable compiler warnings @@ -9,6 +9,7 @@ This release enables linter warnings for the Java compiler by adding argument `- ## Features * #497: Enabled linter warnings +* #488: Added support for Matrix builds ## Dependency Updates From fc282255da3977f8928afe7b8ccd3951ad519d8d Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Fri, 10 Nov 2023 12:03:00 +0100 Subject: [PATCH 04/21] Fix javadoc --- .../com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java index 73df1556..5e194baf 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java @@ -328,7 +328,7 @@ public String getRunnerOs() { /** * Set CI build runner operating system, e.g. {@code ubuntu-20.04}. Default: {@code ubuntu-latest}. * - * @param ciBuildRunnerOS CI build runner operating system + * @param runnerOs CI build runner operating system */ public void setRunnerOs(final String runnerOs) { this.runnerOs = runnerOs; From df6b7e06f08bc38827f70a912f672a2d60f017e9 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Fri, 10 Nov 2023 12:52:54 +0100 Subject: [PATCH 05/21] Run PK fix --- dependencies.md | 397 +++++++++++++++++----------------- doc/changes/changes_2.9.16.md | 2 + 2 files changed, 202 insertions(+), 197 deletions(-) diff --git a/dependencies.md b/dependencies.md index c3cd7ae9..4edca6c6 100644 --- a/dependencies.md +++ b/dependencies.md @@ -22,29 +22,30 @@ | [Hamcrest][12] | [BSD License 3][13] | | [JUnit5 System Extensions][14] | [Eclipse Public License v2.0][5] | | [EqualsVerifier \| release normal jar][15] | [Apache License, Version 2.0][16] | -| [mockito-core][17] | [MIT][18] | -| [SLF4J JDK14 Binding][19] | [MIT License][20] | +| [to-string-verifier][17] | [MIT License][18] | +| [mockito-core][19] | [MIT][20] | +| [SLF4J JDK14 Binding][21] | [MIT License][18] | ### Plugin Dependencies | Dependency | License | | ------------------------------------------------------- | --------------------------------- | -| [SonarQube Scanner for Maven][21] | [GNU LGPL 3][22] | -| [Apache Maven Compiler Plugin][23] | [Apache-2.0][16] | -| [Apache Maven Enforcer Plugin][24] | [Apache-2.0][16] | -| [Maven Flatten Plugin][25] | [Apache Software Licenese][16] | -| [org.sonatype.ossindex.maven:ossindex-maven-plugin][26] | [ASL2][27] | -| [Maven Surefire Plugin][28] | [Apache-2.0][16] | -| [Versions Maven Plugin][29] | [Apache License, Version 2.0][16] | -| [duplicate-finder-maven-plugin Maven Mojo][30] | [Apache License 2.0][31] | -| [Apache Maven Deploy Plugin][32] | [Apache-2.0][16] | -| [Apache Maven GPG Plugin][33] | [Apache-2.0][16] | -| [Apache Maven Source Plugin][34] | [Apache License, Version 2.0][16] | -| [Apache Maven Javadoc Plugin][35] | [Apache-2.0][16] | -| [Nexus Staging Maven Plugin][36] | [Eclipse Public License][37] | -| [JaCoCo :: Maven Plugin][38] | [Eclipse Public License 2.0][39] | -| [error-code-crawler-maven-plugin][40] | [MIT License][41] | -| [Reproducible Build Maven Plugin][42] | [Apache 2.0][27] | +| [SonarQube Scanner for Maven][22] | [GNU LGPL 3][23] | +| [Apache Maven Compiler Plugin][24] | [Apache-2.0][16] | +| [Apache Maven Enforcer Plugin][25] | [Apache-2.0][16] | +| [Maven Flatten Plugin][26] | [Apache Software Licenese][16] | +| [org.sonatype.ossindex.maven:ossindex-maven-plugin][27] | [ASL2][28] | +| [Maven Surefire Plugin][29] | [Apache-2.0][16] | +| [Versions Maven Plugin][30] | [Apache License, Version 2.0][16] | +| [duplicate-finder-maven-plugin Maven Mojo][31] | [Apache License 2.0][32] | +| [Apache Maven Deploy Plugin][33] | [Apache-2.0][16] | +| [Apache Maven GPG Plugin][34] | [Apache-2.0][16] | +| [Apache Maven Source Plugin][35] | [Apache License, Version 2.0][16] | +| [Apache Maven Javadoc Plugin][36] | [Apache-2.0][16] | +| [Nexus Staging Maven Plugin][37] | [Eclipse Public License][38] | +| [JaCoCo :: Maven Plugin][39] | [Eclipse Public License 2.0][40] | +| [error-code-crawler-maven-plugin][41] | [MIT License][42] | +| [Reproducible Build Maven Plugin][43] | [Apache 2.0][28] | ## Project Keeper Core @@ -52,57 +53,58 @@ | Dependency | License | | ----------------------------------------- | ---------------------------------------------- | -| [Project-Keeper shared model classes][43] | [The MIT License][44] | -| [org.xmlunit:xmlunit-core][45] | [The Apache Software License, Version 2.0][27] | +| [Project-Keeper shared model classes][44] | [The MIT License][45] | +| [org.xmlunit:xmlunit-core][46] | [The Apache Software License, Version 2.0][28] | | [error-reporting-java][7] | [MIT License][8] | -| [Markdown Generator][46] | [The Apache Software License, Version 2.0][27] | -| [semver4j][47] | [The MIT License][20] | -| [SnakeYAML][48] | [Apache License, Version 2.0][27] | -| [Maven Model][49] | [Apache-2.0][16] | +| [Markdown Generator][47] | [The Apache Software License, Version 2.0][28] | +| [semver4j][48] | [The MIT License][18] | +| [SnakeYAML][49] | [Apache License, Version 2.0][28] | +| [Maven Model][50] | [Apache-2.0][16] | ### Test Dependencies | Dependency | License | | ------------------------------------------ | ---------------------------------------------- | -| [Project Keeper shared test setup][43] | [The MIT License][44] | -| [Maven Project Version Getter][50] | [MIT License][51] | +| [Project Keeper shared test setup][44] | [The MIT License][45] | +| [Maven Project Version Getter][51] | [MIT License][52] | | [JUnit Jupiter Engine][10] | [Eclipse Public License v2.0][11] | | [JUnit Jupiter Params][10] | [Eclipse Public License v2.0][11] | | [Hamcrest][12] | [BSD License 3][13] | -| [org.xmlunit:xmlunit-matchers][45] | [The Apache Software License, Version 2.0][27] | -| [mockito-junit-jupiter][17] | [MIT][18] | -| [Maven Plugin Integration Testing][52] | [MIT License][53] | +| [org.xmlunit:xmlunit-matchers][46] | [The Apache Software License, Version 2.0][28] | +| [mockito-junit-jupiter][19] | [MIT][20] | +| [Maven Plugin Integration Testing][53] | [MIT License][54] | | [EqualsVerifier \| release normal jar][15] | [Apache License, Version 2.0][16] | -| [SLF4J JDK14 Binding][19] | [MIT License][20] | +| [to-string-verifier][17] | [MIT License][18] | +| [SLF4J JDK14 Binding][21] | [MIT License][18] | ### Runtime Dependencies | Dependency | License | | ----------------------------------------- | --------------------- | -| [Project keeper Java project crawler][43] | [The MIT License][44] | +| [Project keeper Java project crawler][44] | [The MIT License][45] | ### Plugin Dependencies | Dependency | License | | ------------------------------------------------------- | --------------------------------- | -| [SonarQube Scanner for Maven][21] | [GNU LGPL 3][22] | -| [Apache Maven Compiler Plugin][23] | [Apache-2.0][16] | -| [Apache Maven Enforcer Plugin][24] | [Apache-2.0][16] | -| [Maven Flatten Plugin][25] | [Apache Software Licenese][16] | -| [org.sonatype.ossindex.maven:ossindex-maven-plugin][26] | [ASL2][27] | -| [Maven Surefire Plugin][28] | [Apache-2.0][16] | -| [Versions Maven Plugin][29] | [Apache License, Version 2.0][16] | -| [duplicate-finder-maven-plugin Maven Mojo][30] | [Apache License 2.0][31] | -| [Apache Maven Deploy Plugin][32] | [Apache-2.0][16] | -| [Apache Maven GPG Plugin][33] | [Apache-2.0][16] | -| [Apache Maven Source Plugin][34] | [Apache License, Version 2.0][16] | -| [Apache Maven Javadoc Plugin][35] | [Apache-2.0][16] | -| [Nexus Staging Maven Plugin][36] | [Eclipse Public License][37] | -| [Maven Failsafe Plugin][54] | [Apache-2.0][16] | -| [JaCoCo :: Maven Plugin][38] | [Eclipse Public License 2.0][39] | -| [error-code-crawler-maven-plugin][40] | [MIT License][41] | -| [Reproducible Build Maven Plugin][42] | [Apache 2.0][27] | -| [Apache Maven JAR Plugin][55] | [Apache License, Version 2.0][16] | +| [SonarQube Scanner for Maven][22] | [GNU LGPL 3][23] | +| [Apache Maven Compiler Plugin][24] | [Apache-2.0][16] | +| [Apache Maven Enforcer Plugin][25] | [Apache-2.0][16] | +| [Maven Flatten Plugin][26] | [Apache Software Licenese][16] | +| [org.sonatype.ossindex.maven:ossindex-maven-plugin][27] | [ASL2][28] | +| [Maven Surefire Plugin][29] | [Apache-2.0][16] | +| [Versions Maven Plugin][30] | [Apache License, Version 2.0][16] | +| [duplicate-finder-maven-plugin Maven Mojo][31] | [Apache License 2.0][32] | +| [Apache Maven Deploy Plugin][33] | [Apache-2.0][16] | +| [Apache Maven GPG Plugin][34] | [Apache-2.0][16] | +| [Apache Maven Source Plugin][35] | [Apache License, Version 2.0][16] | +| [Apache Maven Javadoc Plugin][36] | [Apache-2.0][16] | +| [Nexus Staging Maven Plugin][37] | [Eclipse Public License][38] | +| [Maven Failsafe Plugin][55] | [Apache-2.0][16] | +| [JaCoCo :: Maven Plugin][39] | [Eclipse Public License 2.0][40] | +| [error-code-crawler-maven-plugin][41] | [MIT License][42] | +| [Reproducible Build Maven Plugin][43] | [Apache 2.0][28] | +| [Apache Maven JAR Plugin][56] | [Apache License, Version 2.0][16] | ## Project Keeper Command Line Interface @@ -110,50 +112,50 @@ | Dependency | License | | ------------------------- | --------------------- | -| [Project keeper core][43] | [The MIT License][44] | +| [Project keeper core][44] | [The MIT License][45] | | [error-reporting-java][7] | [MIT License][8] | -| [Maven Model][49] | [Apache-2.0][16] | +| [Maven Model][50] | [Apache-2.0][16] | ### Test Dependencies | Dependency | License | | -------------------------------------- | --------------------------------- | -| [Project Keeper shared test setup][43] | [The MIT License][44] | +| [Project Keeper shared test setup][44] | [The MIT License][45] | | [JUnit Jupiter Engine][10] | [Eclipse Public License v2.0][11] | | [JUnit Jupiter Params][10] | [Eclipse Public License v2.0][11] | | [Hamcrest][12] | [BSD License 3][13] | -| [Maven Project Version Getter][50] | [MIT License][51] | +| [Maven Project Version Getter][51] | [MIT License][52] | ### Runtime Dependencies | Dependency | License | | ------------------------- | ----------------- | -| [SLF4J JDK14 Binding][19] | [MIT License][20] | +| [SLF4J JDK14 Binding][21] | [MIT License][18] | ### Plugin Dependencies | Dependency | License | | ------------------------------------------------------- | --------------------------------- | -| [SonarQube Scanner for Maven][21] | [GNU LGPL 3][22] | -| [Apache Maven Compiler Plugin][23] | [Apache-2.0][16] | -| [Apache Maven Enforcer Plugin][24] | [Apache-2.0][16] | -| [Maven Flatten Plugin][25] | [Apache Software Licenese][16] | -| [org.sonatype.ossindex.maven:ossindex-maven-plugin][26] | [ASL2][27] | -| [Maven Surefire Plugin][28] | [Apache-2.0][16] | -| [Versions Maven Plugin][29] | [Apache License, Version 2.0][16] | -| [duplicate-finder-maven-plugin Maven Mojo][30] | [Apache License 2.0][31] | -| [Apache Maven Assembly Plugin][56] | [Apache-2.0][16] | -| [Apache Maven JAR Plugin][55] | [Apache License, Version 2.0][16] | -| [Artifact reference checker and unifier][57] | [MIT License][58] | -| [Apache Maven Deploy Plugin][32] | [Apache-2.0][16] | -| [Apache Maven GPG Plugin][33] | [Apache-2.0][16] | -| [Apache Maven Source Plugin][34] | [Apache License, Version 2.0][16] | -| [Apache Maven Javadoc Plugin][35] | [Apache-2.0][16] | -| [Nexus Staging Maven Plugin][36] | [Eclipse Public License][37] | -| [Maven Failsafe Plugin][54] | [Apache-2.0][16] | -| [JaCoCo :: Maven Plugin][38] | [Eclipse Public License 2.0][39] | -| [error-code-crawler-maven-plugin][40] | [MIT License][41] | -| [Reproducible Build Maven Plugin][42] | [Apache 2.0][27] | +| [SonarQube Scanner for Maven][22] | [GNU LGPL 3][23] | +| [Apache Maven Compiler Plugin][24] | [Apache-2.0][16] | +| [Apache Maven Enforcer Plugin][25] | [Apache-2.0][16] | +| [Maven Flatten Plugin][26] | [Apache Software Licenese][16] | +| [org.sonatype.ossindex.maven:ossindex-maven-plugin][27] | [ASL2][28] | +| [Maven Surefire Plugin][29] | [Apache-2.0][16] | +| [Versions Maven Plugin][30] | [Apache License, Version 2.0][16] | +| [duplicate-finder-maven-plugin Maven Mojo][31] | [Apache License 2.0][32] | +| [Apache Maven Assembly Plugin][57] | [Apache-2.0][16] | +| [Apache Maven JAR Plugin][56] | [Apache License, Version 2.0][16] | +| [Artifact reference checker and unifier][58] | [MIT License][59] | +| [Apache Maven Deploy Plugin][33] | [Apache-2.0][16] | +| [Apache Maven GPG Plugin][34] | [Apache-2.0][16] | +| [Apache Maven Source Plugin][35] | [Apache License, Version 2.0][16] | +| [Apache Maven Javadoc Plugin][36] | [Apache-2.0][16] | +| [Nexus Staging Maven Plugin][37] | [Eclipse Public License][38] | +| [Maven Failsafe Plugin][55] | [Apache-2.0][16] | +| [JaCoCo :: Maven Plugin][39] | [Eclipse Public License 2.0][40] | +| [error-code-crawler-maven-plugin][41] | [MIT License][42] | +| [Reproducible Build Maven Plugin][43] | [Apache 2.0][28] | ## Project Keeper Maven Plugin @@ -161,50 +163,50 @@ | Dependency | License | | ----------------------------------------- | --------------------- | -| [Project keeper core][43] | [The MIT License][44] | -| [Maven Plugin Tools Java Annotations][59] | [Apache-2.0][16] | -| [Maven Plugin API][60] | [Apache-2.0][16] | -| [Maven Core][61] | [Apache-2.0][16] | +| [Project keeper core][44] | [The MIT License][45] | +| [Maven Plugin Tools Java Annotations][60] | [Apache-2.0][16] | +| [Maven Plugin API][61] | [Apache-2.0][16] | +| [Maven Core][62] | [Apache-2.0][16] | | [error-reporting-java][7] | [MIT License][8] | ### Test Dependencies | Dependency | License | | -------------------------------------- | ---------------------------------------------- | -| [Maven Project Version Getter][50] | [MIT License][51] | +| [Maven Project Version Getter][51] | [MIT License][52] | | [JUnit Jupiter Engine][10] | [Eclipse Public License v2.0][11] | | [JUnit Jupiter Params][10] | [Eclipse Public License v2.0][11] | | [Hamcrest][12] | [BSD License 3][13] | -| [org.xmlunit:xmlunit-matchers][45] | [The Apache Software License, Version 2.0][27] | -| [mockito-core][17] | [MIT][18] | -| [Maven Plugin Integration Testing][52] | [MIT License][53] | -| [SLF4J JDK14 Binding][19] | [MIT License][20] | -| [JaCoCo :: Agent][62] | [Eclipse Public License 2.0][39] | +| [org.xmlunit:xmlunit-matchers][46] | [The Apache Software License, Version 2.0][28] | +| [mockito-core][19] | [MIT][20] | +| [Maven Plugin Integration Testing][53] | [MIT License][54] | +| [SLF4J JDK14 Binding][21] | [MIT License][18] | +| [JaCoCo :: Agent][63] | [Eclipse Public License 2.0][40] | ### Plugin Dependencies | Dependency | License | | ------------------------------------------------------- | --------------------------------- | -| [SonarQube Scanner for Maven][21] | [GNU LGPL 3][22] | -| [Apache Maven Compiler Plugin][23] | [Apache-2.0][16] | -| [Apache Maven Enforcer Plugin][24] | [Apache-2.0][16] | -| [Maven Flatten Plugin][25] | [Apache Software Licenese][16] | -| [org.sonatype.ossindex.maven:ossindex-maven-plugin][26] | [ASL2][27] | -| [Maven Surefire Plugin][28] | [Apache-2.0][16] | -| [Versions Maven Plugin][29] | [Apache License, Version 2.0][16] | -| [Maven Plugin Plugin][63] | [Apache-2.0][16] | -| [Apache Maven JAR Plugin][55] | [Apache License, Version 2.0][16] | -| [duplicate-finder-maven-plugin Maven Mojo][30] | [Apache License 2.0][31] | -| [Apache Maven Deploy Plugin][32] | [Apache-2.0][16] | -| [Apache Maven GPG Plugin][33] | [Apache-2.0][16] | -| [Apache Maven Source Plugin][34] | [Apache License, Version 2.0][16] | -| [Apache Maven Javadoc Plugin][35] | [Apache-2.0][16] | -| [Nexus Staging Maven Plugin][36] | [Eclipse Public License][37] | -| [Apache Maven Dependency Plugin][64] | [Apache-2.0][16] | -| [Maven Failsafe Plugin][54] | [Apache-2.0][16] | -| [JaCoCo :: Maven Plugin][38] | [Eclipse Public License 2.0][39] | -| [error-code-crawler-maven-plugin][40] | [MIT License][41] | -| [Reproducible Build Maven Plugin][42] | [Apache 2.0][27] | +| [SonarQube Scanner for Maven][22] | [GNU LGPL 3][23] | +| [Apache Maven Compiler Plugin][24] | [Apache-2.0][16] | +| [Apache Maven Enforcer Plugin][25] | [Apache-2.0][16] | +| [Maven Flatten Plugin][26] | [Apache Software Licenese][16] | +| [org.sonatype.ossindex.maven:ossindex-maven-plugin][27] | [ASL2][28] | +| [Maven Surefire Plugin][29] | [Apache-2.0][16] | +| [Versions Maven Plugin][30] | [Apache License, Version 2.0][16] | +| [Maven Plugin Plugin][64] | [Apache-2.0][16] | +| [Apache Maven JAR Plugin][56] | [Apache License, Version 2.0][16] | +| [duplicate-finder-maven-plugin Maven Mojo][31] | [Apache License 2.0][32] | +| [Apache Maven Deploy Plugin][33] | [Apache-2.0][16] | +| [Apache Maven GPG Plugin][34] | [Apache-2.0][16] | +| [Apache Maven Source Plugin][35] | [Apache License, Version 2.0][16] | +| [Apache Maven Javadoc Plugin][36] | [Apache-2.0][16] | +| [Nexus Staging Maven Plugin][37] | [Eclipse Public License][38] | +| [Apache Maven Dependency Plugin][65] | [Apache-2.0][16] | +| [Maven Failsafe Plugin][55] | [Apache-2.0][16] | +| [JaCoCo :: Maven Plugin][39] | [Eclipse Public License 2.0][40] | +| [error-code-crawler-maven-plugin][41] | [MIT License][42] | +| [Reproducible Build Maven Plugin][43] | [Apache 2.0][28] | ## Project Keeper Java Project Crawler @@ -212,52 +214,52 @@ | Dependency | License | | ----------------------------------------- | ---------------------------------------------- | -| [Project-Keeper shared model classes][43] | [The MIT License][44] | -| [Maven Plugin Tools Java Annotations][59] | [Apache-2.0][16] | -| [Maven Plugin API][60] | [Apache-2.0][16] | +| [Project-Keeper shared model classes][44] | [The MIT License][45] | +| [Maven Plugin Tools Java Annotations][60] | [Apache-2.0][16] | +| [Maven Plugin API][61] | [Apache-2.0][16] | | [error-reporting-java][7] | [MIT License][8] | | [JGit - Core][9] | Eclipse Distribution License (New BSD License) | -| [semver4j][47] | [The MIT License][20] | -| [Maven Core][61] | [Apache-2.0][16] | +| [semver4j][48] | [The MIT License][18] | +| [Maven Core][62] | [Apache-2.0][16] | ### Test Dependencies | Dependency | License | | -------------------------------------- | ---------------------------------------------- | -| [Maven Project Version Getter][50] | [MIT License][51] | +| [Maven Project Version Getter][51] | [MIT License][52] | | [JUnit Jupiter Engine][10] | [Eclipse Public License v2.0][11] | | [JUnit Jupiter Params][10] | [Eclipse Public License v2.0][11] | | [Hamcrest][12] | [BSD License 3][13] | -| [org.xmlunit:xmlunit-matchers][45] | [The Apache Software License, Version 2.0][27] | -| [SLF4J JDK14 Binding][19] | [MIT License][20] | -| [mockito-core][17] | [MIT][18] | -| [mockito-junit-jupiter][17] | [MIT][18] | -| [Maven Plugin Integration Testing][52] | [MIT License][53] | -| [JaCoCo :: Agent][62] | [Eclipse Public License 2.0][39] | +| [org.xmlunit:xmlunit-matchers][46] | [The Apache Software License, Version 2.0][28] | +| [SLF4J JDK14 Binding][21] | [MIT License][18] | +| [mockito-core][19] | [MIT][20] | +| [mockito-junit-jupiter][19] | [MIT][20] | +| [Maven Plugin Integration Testing][53] | [MIT License][54] | +| [JaCoCo :: Agent][63] | [Eclipse Public License 2.0][40] | ### Plugin Dependencies | Dependency | License | | ------------------------------------------------------- | --------------------------------- | -| [SonarQube Scanner for Maven][21] | [GNU LGPL 3][22] | -| [Apache Maven Compiler Plugin][23] | [Apache-2.0][16] | -| [Apache Maven Enforcer Plugin][24] | [Apache-2.0][16] | -| [Maven Flatten Plugin][25] | [Apache Software Licenese][16] | -| [org.sonatype.ossindex.maven:ossindex-maven-plugin][26] | [ASL2][27] | -| [Maven Surefire Plugin][28] | [Apache-2.0][16] | -| [Versions Maven Plugin][29] | [Apache License, Version 2.0][16] | -| [Maven Plugin Plugin][63] | [Apache-2.0][16] | -| [duplicate-finder-maven-plugin Maven Mojo][30] | [Apache License 2.0][31] | -| [Apache Maven Deploy Plugin][32] | [Apache-2.0][16] | -| [Apache Maven GPG Plugin][33] | [Apache-2.0][16] | -| [Apache Maven Source Plugin][34] | [Apache License, Version 2.0][16] | -| [Apache Maven Javadoc Plugin][35] | [Apache-2.0][16] | -| [Nexus Staging Maven Plugin][36] | [Eclipse Public License][37] | -| [Apache Maven Dependency Plugin][64] | [Apache-2.0][16] | -| [Maven Failsafe Plugin][54] | [Apache-2.0][16] | -| [JaCoCo :: Maven Plugin][38] | [Eclipse Public License 2.0][39] | -| [error-code-crawler-maven-plugin][40] | [MIT License][41] | -| [Reproducible Build Maven Plugin][42] | [Apache 2.0][27] | +| [SonarQube Scanner for Maven][22] | [GNU LGPL 3][23] | +| [Apache Maven Compiler Plugin][24] | [Apache-2.0][16] | +| [Apache Maven Enforcer Plugin][25] | [Apache-2.0][16] | +| [Maven Flatten Plugin][26] | [Apache Software Licenese][16] | +| [org.sonatype.ossindex.maven:ossindex-maven-plugin][27] | [ASL2][28] | +| [Maven Surefire Plugin][29] | [Apache-2.0][16] | +| [Versions Maven Plugin][30] | [Apache License, Version 2.0][16] | +| [Maven Plugin Plugin][64] | [Apache-2.0][16] | +| [duplicate-finder-maven-plugin Maven Mojo][31] | [Apache License 2.0][32] | +| [Apache Maven Deploy Plugin][33] | [Apache-2.0][16] | +| [Apache Maven GPG Plugin][34] | [Apache-2.0][16] | +| [Apache Maven Source Plugin][35] | [Apache License, Version 2.0][16] | +| [Apache Maven Javadoc Plugin][36] | [Apache-2.0][16] | +| [Nexus Staging Maven Plugin][37] | [Eclipse Public License][38] | +| [Apache Maven Dependency Plugin][65] | [Apache-2.0][16] | +| [Maven Failsafe Plugin][55] | [Apache-2.0][16] | +| [JaCoCo :: Maven Plugin][39] | [Eclipse Public License 2.0][40] | +| [error-code-crawler-maven-plugin][41] | [MIT License][42] | +| [Reproducible Build Maven Plugin][43] | [Apache 2.0][28] | ## Project Keeper Shared Test Setup @@ -265,26 +267,26 @@ | Dependency | License | | ----------------------------------------- | --------------------------------- | -| [Project-Keeper shared model classes][43] | [The MIT License][44] | -| [SnakeYAML][48] | [Apache License, Version 2.0][27] | +| [Project-Keeper shared model classes][44] | [The MIT License][45] | +| [SnakeYAML][49] | [Apache License, Version 2.0][28] | | [Hamcrest][12] | [BSD License 3][13] | -| [Maven Model][49] | [Apache-2.0][16] | +| [Maven Model][50] | [Apache-2.0][16] | ### Plugin Dependencies | Dependency | License | | ------------------------------------------------------- | --------------------------------- | -| [SonarQube Scanner for Maven][21] | [GNU LGPL 3][22] | -| [Apache Maven Compiler Plugin][23] | [Apache-2.0][16] | -| [Apache Maven Enforcer Plugin][24] | [Apache-2.0][16] | -| [Maven Flatten Plugin][25] | [Apache Software Licenese][16] | -| [org.sonatype.ossindex.maven:ossindex-maven-plugin][26] | [ASL2][27] | -| [Maven Surefire Plugin][28] | [Apache-2.0][16] | -| [Versions Maven Plugin][29] | [Apache License, Version 2.0][16] | -| [duplicate-finder-maven-plugin Maven Mojo][30] | [Apache License 2.0][31] | -| [JaCoCo :: Maven Plugin][38] | [Eclipse Public License 2.0][39] | -| [error-code-crawler-maven-plugin][40] | [MIT License][41] | -| [Reproducible Build Maven Plugin][42] | [Apache 2.0][27] | +| [SonarQube Scanner for Maven][22] | [GNU LGPL 3][23] | +| [Apache Maven Compiler Plugin][24] | [Apache-2.0][16] | +| [Apache Maven Enforcer Plugin][25] | [Apache-2.0][16] | +| [Maven Flatten Plugin][26] | [Apache Software Licenese][16] | +| [org.sonatype.ossindex.maven:ossindex-maven-plugin][27] | [ASL2][28] | +| [Maven Surefire Plugin][29] | [Apache-2.0][16] | +| [Versions Maven Plugin][30] | [Apache License, Version 2.0][16] | +| [duplicate-finder-maven-plugin Maven Mojo][31] | [Apache License 2.0][32] | +| [JaCoCo :: Maven Plugin][39] | [Eclipse Public License 2.0][40] | +| [error-code-crawler-maven-plugin][41] | [MIT License][42] | +| [Reproducible Build Maven Plugin][43] | [Apache 2.0][28] | [0]: https://github.com/eclipse-ee4j/jsonp [1]: https://projects.eclipse.org/license/epl-2.0 @@ -303,51 +305,52 @@ [14]: https://github.com/itsallcode/junit5-system-extensions [15]: https://www.jqno.nl/equalsverifier [16]: https://www.apache.org/licenses/LICENSE-2.0.txt -[17]: https://github.com/mockito/mockito -[18]: https://opensource.org/licenses/MIT -[19]: http://www.slf4j.org -[20]: http://www.opensource.org/licenses/mit-license.php -[21]: http://sonarsource.github.io/sonar-scanner-maven/ -[22]: http://www.gnu.org/licenses/lgpl.txt -[23]: https://maven.apache.org/plugins/maven-compiler-plugin/ -[24]: https://maven.apache.org/enforcer/maven-enforcer-plugin/ -[25]: https://www.mojohaus.org/flatten-maven-plugin/ -[26]: https://sonatype.github.io/ossindex-maven/maven-plugin/ -[27]: http://www.apache.org/licenses/LICENSE-2.0.txt -[28]: https://maven.apache.org/surefire/maven-surefire-plugin/ -[29]: https://www.mojohaus.org/versions/versions-maven-plugin/ -[30]: https://basepom.github.io/duplicate-finder-maven-plugin -[31]: http://www.apache.org/licenses/LICENSE-2.0.html -[32]: https://maven.apache.org/plugins/maven-deploy-plugin/ -[33]: https://maven.apache.org/plugins/maven-gpg-plugin/ -[34]: https://maven.apache.org/plugins/maven-source-plugin/ -[35]: https://maven.apache.org/plugins/maven-javadoc-plugin/ -[36]: http://www.sonatype.com/public-parent/nexus-maven-plugins/nexus-staging/nexus-staging-maven-plugin/ -[37]: http://www.eclipse.org/legal/epl-v10.html -[38]: https://www.jacoco.org/jacoco/trunk/doc/maven.html -[39]: https://www.eclipse.org/legal/epl-2.0/ -[40]: https://github.com/exasol/error-code-crawler-maven-plugin/ -[41]: https://github.com/exasol/error-code-crawler-maven-plugin/blob/main/LICENSE -[42]: http://zlika.github.io/reproducible-build-maven-plugin -[43]: https://github.com/exasol/project-keeper/ -[44]: https://github.com/exasol/project-keeper/blob/main/LICENSE -[45]: https://www.xmlunit.org/ -[46]: https://github.com/Steppschuh/Java-Markdown-Generator -[47]: https://github.com/vdurmont/semver4j -[48]: https://bitbucket.org/snakeyaml/snakeyaml -[49]: https://maven.apache.org/ref/3.9.5/maven-model/ -[50]: https://github.com/exasol/maven-project-version-getter/ -[51]: https://github.com/exasol/maven-project-version-getter/blob/main/LICENSE -[52]: https://github.com/exasol/maven-plugin-integration-testing/ -[53]: https://github.com/exasol/maven-plugin-integration-testing/blob/main/LICENSE -[54]: https://maven.apache.org/surefire/maven-failsafe-plugin/ -[55]: https://maven.apache.org/plugins/maven-jar-plugin/ -[56]: https://maven.apache.org/plugins/maven-assembly-plugin/ -[57]: https://github.com/exasol/artifact-reference-checker-maven-plugin/ -[58]: https://github.com/exasol/artifact-reference-checker-maven-plugin/blob/main/LICENSE -[59]: https://maven.apache.org/plugin-tools/maven-plugin-annotations -[60]: https://maven.apache.org/ref/3.9.5/maven-plugin-api/ -[61]: https://maven.apache.org/ref/3.9.5/maven-core/ -[62]: https://www.eclemma.org/jacoco/index.html -[63]: https://maven.apache.org/plugin-tools/maven-plugin-plugin -[64]: https://maven.apache.org/plugins/maven-dependency-plugin/ +[17]: https://github.com/jparams/to-string-verifier +[18]: http://www.opensource.org/licenses/mit-license.php +[19]: https://github.com/mockito/mockito +[20]: https://opensource.org/licenses/MIT +[21]: http://www.slf4j.org +[22]: http://sonarsource.github.io/sonar-scanner-maven/ +[23]: http://www.gnu.org/licenses/lgpl.txt +[24]: https://maven.apache.org/plugins/maven-compiler-plugin/ +[25]: https://maven.apache.org/enforcer/maven-enforcer-plugin/ +[26]: https://www.mojohaus.org/flatten-maven-plugin/ +[27]: https://sonatype.github.io/ossindex-maven/maven-plugin/ +[28]: http://www.apache.org/licenses/LICENSE-2.0.txt +[29]: https://maven.apache.org/surefire/maven-surefire-plugin/ +[30]: https://www.mojohaus.org/versions/versions-maven-plugin/ +[31]: https://basepom.github.io/duplicate-finder-maven-plugin +[32]: http://www.apache.org/licenses/LICENSE-2.0.html +[33]: https://maven.apache.org/plugins/maven-deploy-plugin/ +[34]: https://maven.apache.org/plugins/maven-gpg-plugin/ +[35]: https://maven.apache.org/plugins/maven-source-plugin/ +[36]: https://maven.apache.org/plugins/maven-javadoc-plugin/ +[37]: http://www.sonatype.com/public-parent/nexus-maven-plugins/nexus-staging/nexus-staging-maven-plugin/ +[38]: http://www.eclipse.org/legal/epl-v10.html +[39]: https://www.jacoco.org/jacoco/trunk/doc/maven.html +[40]: https://www.eclipse.org/legal/epl-2.0/ +[41]: https://github.com/exasol/error-code-crawler-maven-plugin/ +[42]: https://github.com/exasol/error-code-crawler-maven-plugin/blob/main/LICENSE +[43]: http://zlika.github.io/reproducible-build-maven-plugin +[44]: https://github.com/exasol/project-keeper/ +[45]: https://github.com/exasol/project-keeper/blob/main/LICENSE +[46]: https://www.xmlunit.org/ +[47]: https://github.com/Steppschuh/Java-Markdown-Generator +[48]: https://github.com/vdurmont/semver4j +[49]: https://bitbucket.org/snakeyaml/snakeyaml +[50]: https://maven.apache.org/ref/3.9.5/maven-model/ +[51]: https://github.com/exasol/maven-project-version-getter/ +[52]: https://github.com/exasol/maven-project-version-getter/blob/main/LICENSE +[53]: https://github.com/exasol/maven-plugin-integration-testing/ +[54]: https://github.com/exasol/maven-plugin-integration-testing/blob/main/LICENSE +[55]: https://maven.apache.org/surefire/maven-failsafe-plugin/ +[56]: https://maven.apache.org/plugins/maven-jar-plugin/ +[57]: https://maven.apache.org/plugins/maven-assembly-plugin/ +[58]: https://github.com/exasol/artifact-reference-checker-maven-plugin/ +[59]: https://github.com/exasol/artifact-reference-checker-maven-plugin/blob/main/LICENSE +[60]: https://maven.apache.org/plugin-tools/maven-plugin-annotations +[61]: https://maven.apache.org/ref/3.9.5/maven-plugin-api/ +[62]: https://maven.apache.org/ref/3.9.5/maven-core/ +[63]: https://www.eclemma.org/jacoco/index.html +[64]: https://maven.apache.org/plugin-tools/maven-plugin-plugin +[65]: https://maven.apache.org/plugins/maven-dependency-plugin/ diff --git a/doc/changes/changes_2.9.16.md b/doc/changes/changes_2.9.16.md index a0f8b83e..4b53f9f6 100644 --- a/doc/changes/changes_2.9.16.md +++ b/doc/changes/changes_2.9.16.md @@ -17,6 +17,7 @@ This release enables linter warnings for the Java compiler by adding argument `- #### Test Dependency Updates +* Added `com.jparams:to-string-verifier:1.4.8` * Updated `nl.jqno.equalsverifier:equalsverifier:3.15.2` to `3.15.3` * Updated `org.junit.jupiter:junit-jupiter-engine:5.10.0` to `5.10.1` * Updated `org.junit.jupiter:junit-jupiter-params:5.10.0` to `5.10.1` @@ -40,6 +41,7 @@ This release enables linter warnings for the Java compiler by adding argument `- #### Test Dependency Updates * Updated `com.exasol:project-keeper-shared-test-setup:2.9.15` to `2.9.16` +* Added `com.jparams:to-string-verifier:1.4.8` * Updated `nl.jqno.equalsverifier:equalsverifier:3.15.2` to `3.15.3` * Updated `org.junit.jupiter:junit-jupiter-engine:5.10.0` to `5.10.1` * Updated `org.junit.jupiter:junit-jupiter-params:5.10.0` to `5.10.1` From ec2abc7907a79eb07dfca2e1f85a34e7d57f61e7 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Fri, 10 Nov 2023 15:36:46 +0100 Subject: [PATCH 06/21] Prevent adding the same replacement --- .../validators/files/FileTemplateFromResource.java | 6 ++++++ .../validators/files/FileTemplateFromResourceTest.java | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResource.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResource.java index 0d96b0b2..db71c005 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResource.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResource.java @@ -49,6 +49,12 @@ public FileTemplateFromResource(final String templateResource, final String path * @return this for fluent programming */ public FileTemplateFromResource replacing(final String name, final String replacement) { + if (this.replacements.containsKey(name)) { + throw new IllegalStateException(ExaError.messageBuilder("E-PK-CORE-170").message( + "Cannot add replacement with value {{new replacement}} because {{name}} is already registered as replacement with value {{existing value}}.", + replacement, name, replacements.get(name)).mitigation("Remove or rename one of the replacements.") + .toString()); + } this.replacements.put(name, replacement); return this; } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResourceTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResourceTest.java index 26b5b94b..db8be994 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResourceTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResourceTest.java @@ -27,6 +27,16 @@ private FileTemplateFromResource testee() { return new FileTemplateFromResource(".github/workflows/ci-build.yml", Validation.REQUIRE_EXACT); } + @Test + void rejectsReplacingTheSameKey() { + final FileTemplateFromResource testee = testee(); + testee.replacing("key", "value1"); + final IllegalStateException exception = assertThrows(IllegalStateException.class, + () -> testee.replacing("key", "value2")); + assertThat(exception.getMessage(), equalTo( + "E-PK-CORE-170: Cannot add replacement with value 'value2' because 'key' is already registered as replacement with value 'value1'. Remove or rename one of the replacements.")); + } + @Test void getContentReplacesPlaceholders() { final String content = testee().replacing("ciBuildRunnerOS", "custom-runner").getContent(); From 3f91f6f16e813d71df5220253e2e1715eacbdcb3 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Fri, 10 Nov 2023 16:38:21 +0100 Subject: [PATCH 07/21] Cleanup CI build script: remove unnecessary variable --- .github/workflows/ci-build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index e90f12fe..3499c51b 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -35,9 +35,8 @@ jobs: path: | ~/.cache/go-build ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go-${{ matrix.go }} ${{ runner.os }}-go- - name: Install Go tools run: go install github.com/google/go-licenses@v1.6.0 From b4d46b74873156bc52d1865dc26150db74acc6f7 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Fri, 10 Nov 2023 16:40:09 +0100 Subject: [PATCH 08/21] #488: Added option to free disk space --- README.md | 11 +++ doc/changes/changes_2.9.16.md | 6 ++ project-keeper/error_code_config.yml | 2 +- .../config/ProjectKeeperConfigReader.java | 4 +- .../config/ProjectKeeperRawConfig.java | 15 ++++ .../files/CiBuildWorkflowGenerator.java | 27 +++++++ .../files/FileTemplatesFactory.java | 14 ++-- .../templates/.github/workflows/ci-build.yml | 1 + ...elease_droid_prepare_original_checksum.yml | 1 + .../config/ProjectKeeperConfigReaderTest.java | 3 + .../files/CiBuildWorkflowGeneratorTest.java | 72 +++++++++++++++++++ .../shared/config/BuildConfig.java | 20 ++++++ 12 files changed, 164 insertions(+), 12 deletions(-) create mode 100644 project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java create mode 100644 project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java diff --git a/README.md b/README.md index 842ad60c..fba01e4a 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,17 @@ build: PK will use this setting for GitHub workflows `ci-build.yml` and `release_droid_prepare_original_checksum.yml` which run integration tests. The other workflows don't run integration tests and will stick to the default `ubuntu-latest`. +#### Free Disk Space + +Some projects need more disk space during build, e.g. for Docker images. You can free up disk space before the build like this: + +```yml +build: + freeDiskSpace: true +``` + +This will slow down the build by about one minute. + ## POM File For maven projects, project-keeper generates a `pk_generated_parent.pom` file. This file contains all the required plugins, dependencies and configurations. PK configures your `pom.xml` to use this file as a parent pom. By that, your `pom.xml` inherits all the configuration. diff --git a/doc/changes/changes_2.9.16.md b/doc/changes/changes_2.9.16.md index 4b53f9f6..393fb166 100644 --- a/doc/changes/changes_2.9.16.md +++ b/doc/changes/changes_2.9.16.md @@ -6,6 +6,12 @@ Code name: Support Matrix builds & enable compiler warnings This release enables linter warnings for the Java compiler by adding argument `-Xlint:all`. This will log warnings but the build won't fail. +The release also adds the following options for the build script: +* Free up disk space before build +* Select operating system for build + +See the [user guide](../../README.md#ci-build-configuration) for details. + ## Features * #497: Enabled linter warnings diff --git a/project-keeper/error_code_config.yml b/project-keeper/error_code_config.yml index 97c94ffe..e550c0e8 100644 --- a/project-keeper/error_code_config.yml +++ b/project-keeper/error_code_config.yml @@ -2,4 +2,4 @@ error-tags: PK-CORE: packages: - com.exasol.projectkeeper - highest-index: 169 + highest-index: 170 diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java index f99cf07f..4978c124 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java @@ -111,7 +111,9 @@ private VersionConfig parseVersion(final Object rawVersion, final Path projectDi private BuildConfig convertBuildConfig(final Build build) { return BuildConfig.builder() // - .runnerOs(build != null ? build.getRunnerOs() : null).build(); + .runnerOs(build != null ? build.getRunnerOs() : null) // + .freeDiskSpace(build != null && build.shouldFreeDiskSpace()) // + .build(); } private List convertExcludes(final List rawExcludes) { diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java index 5e194baf..668d651c 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java @@ -315,6 +315,7 @@ public void setRelativePath(final String relativePath) { */ public static class Build { private String runnerOs; + private boolean freeDiskSpace = false; /** * Get CI build runner operating system, e.g. {@code ubuntu-20.04}. @@ -333,5 +334,19 @@ public String getRunnerOs() { public void setRunnerOs(final String runnerOs) { this.runnerOs = runnerOs; } + + /** + * @return {@code true} if the CI build should free disk space before running the build + */ + public boolean shouldFreeDiskSpace() { + return freeDiskSpace; + } + + /** + * @param freeDiskSpace {@code true} if the CI build should free disk space before running the build + */ + public void setFreeDiskSpace(final boolean freeDiskSpace) { + this.freeDiskSpace = freeDiskSpace; + } } } diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java new file mode 100644 index 00000000..a30daecf --- /dev/null +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java @@ -0,0 +1,27 @@ +package com.exasol.projectkeeper.validators.files; + +import static com.exasol.projectkeeper.validators.files.FileTemplate.Validation.REQUIRE_EXACT; + +import com.exasol.projectkeeper.shared.config.BuildConfig; + +class CiBuildWorkflowGenerator { + private static final String CI_BUILD_RUNNER_OS_PLACEHOLDER = "ciBuildRunnerOS"; + private final BuildConfig buildConfig; + + CiBuildWorkflowGenerator(final BuildConfig buildConfig) { + this.buildConfig = buildConfig; + } + + FileTemplate createReleaseDroidPrepareOriginalChecksumWorkflow() { + return new FileTemplateFromResource(".github/workflows/release_droid_prepare_original_checksum.yml", + REQUIRE_EXACT) // + .replacing(CI_BUILD_RUNNER_OS_PLACEHOLDER, buildConfig.getRunnerOs()) + .replacing("freeDiskSpace", String.valueOf(buildConfig.shouldFreeDiskSpace())); + } + + FileTemplateFromResource createCiBuildWorkflow() { + return new FileTemplateFromResource(".github/workflows/ci-build.yml", REQUIRE_EXACT) + .replacing(CI_BUILD_RUNNER_OS_PLACEHOLDER, buildConfig.getRunnerOs()) + .replacing("freeDiskSpace", String.valueOf(buildConfig.shouldFreeDiskSpace())); + } +} diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java index 40269f70..0276948f 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java @@ -16,8 +16,6 @@ * Factory for file templates. */ class FileTemplatesFactory { - - private static final String CI_BUILD_RUNNER_OS_PLACEHOLDER = "ciBuildRunnerOS"; private static final String POM_FILES_GENERATED = String.format("%-65s%s", "pk_generated_parent.pom", "linguist-generated=true"); @@ -38,6 +36,7 @@ private static String lines(final String... line) { private final String ownVersion; private final boolean hasNpmModule; private final BuildConfig buildConfig; + private final CiBuildWorkflowGenerator workflowGenerator; public FileTemplatesFactory(final Logger logger, final String ownVersion, final boolean hasNpmModule, final BuildConfig buildConfig) { @@ -45,6 +44,7 @@ public FileTemplatesFactory(final Logger logger, final String ownVersion, final this.ownVersion = Objects.requireNonNull(ownVersion, "ownVersion"); this.hasNpmModule = hasNpmModule; this.buildConfig = Objects.requireNonNull(buildConfig, "buildConfig"); + this.workflowGenerator = new CiBuildWorkflowGenerator(this.buildConfig); } List getGlobalTemplates(final List sources) { @@ -77,8 +77,7 @@ private List getGenericMavenTemplates(final Set getGenericMavenTemplates(final Set modules) { if (modules.contains(NATIVE_IMAGE)) { return new FileTemplateFromResource("templates/.github/workflows/ci-build-native-build.yml", ".github/workflows/ci-build.yml", REQUIRE_EXACT); } else { - return new FileTemplateFromResource(".github/workflows/ci-build.yml", REQUIRE_EXACT) - .replacing(CI_BUILD_RUNNER_OS_PLACEHOLDER, getCiBuildRunnerOS()); + return workflowGenerator.createCiBuildWorkflow(); } } diff --git a/project-keeper/src/main/resources/templates/.github/workflows/ci-build.yml b/project-keeper/src/main/resources/templates/.github/workflows/ci-build.yml index f86a342b..bd6579c8 100644 --- a/project-keeper/src/main/resources/templates/.github/workflows/ci-build.yml +++ b/project-keeper/src/main/resources/templates/.github/workflows/ci-build.yml @@ -14,6 +14,7 @@ jobs: cancel-in-progress: true steps: - name: Free Disk Space + if: ${{ $freeDiskSpace }} run: | sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/share/dotnet diff --git a/project-keeper/src/main/resources/templates/.github/workflows/release_droid_prepare_original_checksum.yml b/project-keeper/src/main/resources/templates/.github/workflows/release_droid_prepare_original_checksum.yml index e60f5738..c10a1d25 100644 --- a/project-keeper/src/main/resources/templates/.github/workflows/release_droid_prepare_original_checksum.yml +++ b/project-keeper/src/main/resources/templates/.github/workflows/release_droid_prepare_original_checksum.yml @@ -8,6 +8,7 @@ jobs: runs-on: $ciBuildRunnerOS steps: - name: Free Disk Space + if: ${{ $freeDiskSpace }} run: | sudo rm -rf /usr/local/lib/android sudo rm -rf /usr/share/dotnet diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java index 86c62ed3..92168d4e 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java @@ -55,12 +55,14 @@ void read() throws IOException { " relativePath: \"./my-parent.xml\"\n" + // "build:\n" + // " runnerOs: custom-runner-os\n" + // + " freeDiskSpace: true\n" + // "linkReplacements:\n" + // " - \"http://wrong-url.com|my-dependency.de\"\n"); final ProjectKeeperConfig config = this.reader.readConfig(this.tempDir); final Source source = config.getSources().get(0); assertAll(// () -> assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("custom-runner-os")), + () -> assertThat(config.getCiBuildConfig().shouldFreeDiskSpace(), equalTo(true)), () -> assertThat(source.getType(), equalTo(MAVEN)), () -> assertThat(source.isAdvertised(), equalTo(false)), () -> assertThat(source.getPath(), equalTo(this.tempDir.resolve("my-sub-project/pom.xml"))), @@ -93,6 +95,7 @@ void readDefaults() throws IOException { () -> assertThat(source.getParentPom(), nullValue()), () -> assertThat(config.getExcludes(), equalTo(Collections.emptyList())), () -> assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("ubuntu-latest")), + () -> assertThat(config.getCiBuildConfig().shouldFreeDiskSpace(), equalTo(false)), () -> assertThat(config.getLinkReplacements(), equalTo(Collections.emptyList()))// ); } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java new file mode 100644 index 00000000..7219a165 --- /dev/null +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java @@ -0,0 +1,72 @@ +package com.exasol.projectkeeper.validators.files; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; + +import org.junit.jupiter.api.Test; +import org.yaml.snakeyaml.Yaml; + +import com.exasol.projectkeeper.shared.config.BuildConfig; + +class CiBuildWorkflowGeneratorTest { + + @Test + void rdOrgChecksumContainsRunnerOs() { + assertThat(releaseDroidOriginalChecksumContent(BuildConfig.builder().runnerOs("my-runner-os")), + containsString("runs-on: my-runner-os")); + } + + @Test + void rdOrgChecksumDoesNotFreeDiskSpace() { + assertThat(releaseDroidOriginalChecksumContent(BuildConfig.builder().freeDiskSpace(false)), + containsString("- name: Free Disk Space\n" + // + " if: ${{ false }}")); + } + + @Test + void rdOrgChecksumDoesFreeDiskSpace() { + assertThat(releaseDroidOriginalChecksumContent(BuildConfig.builder().freeDiskSpace(true)), + containsString("- name: Free Disk Space\n" + // + " if: ${{ true }}")); + } + + @Test + void ciBuildContainsRunnerOs() { + assertThat(ciBuildContent(BuildConfig.builder().runnerOs("my-runner-os")), + containsString("runs-on: my-runner-os")); + } + + @Test + void ciBuildDoesNotFreeDiskSpace() { + assertThat(ciBuildContent(BuildConfig.builder().freeDiskSpace(false)), + containsString("- name: Free Disk Space\n" + // + " if: ${{ false }}")); + } + + @Test + void ciBuildDoesFreeDiskSpace() { + assertThat(ciBuildContent(BuildConfig.builder().freeDiskSpace(true)), + containsString("- name: Free Disk Space\n" + // + " if: ${{ true }}")); + } + + private String releaseDroidOriginalChecksumContent(final BuildConfig.Builder configBuilder) { + final String content = testee(configBuilder).createReleaseDroidPrepareOriginalChecksumWorkflow().getContent(); + validateYamlSyntax(content); + return content; + } + + private String ciBuildContent(final BuildConfig.Builder configBuilder) { + final String content = testee(configBuilder).createCiBuildWorkflow().getContent(); + validateYamlSyntax(content); + return content; + } + + private void validateYamlSyntax(final String content) { + new Yaml().load(content); + } + + private CiBuildWorkflowGenerator testee(final BuildConfig.Builder configBuilder) { + return new CiBuildWorkflowGenerator(configBuilder.build()); + } +} diff --git a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java index 584d8d17..04a59238 100644 --- a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java +++ b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java @@ -9,9 +9,11 @@ public final class BuildConfig { private static final String DEFAULT_RUNNER_OS = "ubuntu-latest"; private final String runnerOs; + private final boolean freeDiskSpace; private BuildConfig(final Builder builder) { this.runnerOs = Objects.requireNonNull(builder.runnerOs, "runnerOs"); + this.freeDiskSpace = builder.freeDiskSpace; } /** @return CI build runner operating system */ @@ -19,6 +21,11 @@ public String getRunnerOs() { return this.runnerOs; } + /** @return {@code true} if disk space should be freed before running the build */ + public boolean shouldFreeDiskSpace() { + return freeDiskSpace; + } + /** * Creates builder to build {@link BuildConfig}. * @@ -32,6 +39,7 @@ public static Builder builder() { * Builder to build {@link BuildConfig}. */ public static final class Builder { + private boolean freeDiskSpace = false; private String runnerOs = DEFAULT_RUNNER_OS; private Builder() { @@ -50,6 +58,18 @@ public Builder runnerOs(final String runnerOs) { return this; } + /** + * Some builds need more disk space, e.g. for Docker images. If this is {@code true}, the CI build will free up + * disk space before running the actual build. This will slow down the build about one minute. + * + * @param freeDiskSpace {@code true} if the CI build should free up disk space + * @return {@code this} for fluent programming + */ + public Builder freeDiskSpace(final boolean freeDiskSpace) { + this.freeDiskSpace = freeDiskSpace; + return this; + } + /** * Build a new {@link BuildConfig}. * From 9d83b027a3ba59d7d15ce9628198cb4ba640a7a8 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Fri, 10 Nov 2023 16:48:38 +0100 Subject: [PATCH 09/21] Fix hash code & equals --- .../com/exasol/projectkeeper/shared/config/BuildConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java index 04a59238..fd9c6f96 100644 --- a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java +++ b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java @@ -82,12 +82,12 @@ public BuildConfig build() { @Override public String toString() { - return "BuildConfig [runnerOs=" + runnerOs + "]"; + return "BuildConfig [runnerOs=" + runnerOs + ", freeDiskSpace=" + freeDiskSpace + "]"; } @Override public int hashCode() { - return Objects.hash(runnerOs); + return Objects.hash(runnerOs, freeDiskSpace); } @Override @@ -102,6 +102,6 @@ public boolean equals(final Object obj) { return false; } final BuildConfig other = (BuildConfig) obj; - return Objects.equals(runnerOs, other.runnerOs); + return Objects.equals(runnerOs, other.runnerOs) && freeDiskSpace == other.freeDiskSpace; } } From 4e7383c6bca79ba5ef470d01f2074dbca783e543 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 08:11:56 +0100 Subject: [PATCH 10/21] #488: Configure Matrix build --- README.md | 13 ++++ doc/changes/changes_2.9.16.md | 1 + .../config/ProjectKeeperConfigReader.java | 1 + .../config/ProjectKeeperRawConfig.java | 21 ++++-- .../files/CiBuildWorkflowGenerator.java | 26 ++++++- .../workflows/ci-build-db-version-matrix.yml | 70 +++++++++++++++++++ .../templates/.github/workflows/ci-build.yml | 3 +- .../config/ProjectKeeperConfigReaderTest.java | 5 ++ .../files/CiBuildWorkflowGeneratorTest.java | 25 ++++++- .../shared/config/BuildConfig.java | 38 +++++++++- 10 files changed, 191 insertions(+), 12 deletions(-) create mode 100644 project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml diff --git a/README.md b/README.md index fba01e4a..7b2b9209 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,19 @@ build: This will slow down the build by about one minute. +#### Matrix Build with Exasol DB Versions + +To CI build as a matrix build with multiple Exasol DB versions you can add the following: + +```yml +build: + exasolDbVersions: + - "7.1.24" + - "8.23.1" +``` + +Sonar will only run for the first version in the list. + ## POM File For maven projects, project-keeper generates a `pk_generated_parent.pom` file. This file contains all the required plugins, dependencies and configurations. PK configures your `pom.xml` to use this file as a parent pom. By that, your `pom.xml` inherits all the configuration. diff --git a/doc/changes/changes_2.9.16.md b/doc/changes/changes_2.9.16.md index 393fb166..f94d3c8d 100644 --- a/doc/changes/changes_2.9.16.md +++ b/doc/changes/changes_2.9.16.md @@ -9,6 +9,7 @@ This release enables linter warnings for the Java compiler by adding argument `- The release also adds the following options for the build script: * Free up disk space before build * Select operating system for build +* Select Exasol DB versions for which to run the build See the [user guide](../../README.md#ci-build-configuration) for details. diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java index 4978c124..adb5d0fb 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java @@ -113,6 +113,7 @@ private BuildConfig convertBuildConfig(final Build build) { return BuildConfig.builder() // .runnerOs(build != null ? build.getRunnerOs() : null) // .freeDiskSpace(build != null && build.shouldFreeDiskSpace()) // + .exasolDbVersions(build != null ? build.getExasolDbVersions() : null) // .build(); } diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java index 668d651c..c58cf68f 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java @@ -1,5 +1,7 @@ package com.exasol.projectkeeper.config; +import static java.util.Collections.emptyList; + import java.util.List; import java.util.Map; @@ -316,6 +318,7 @@ public void setRelativePath(final String relativePath) { public static class Build { private String runnerOs; private boolean freeDiskSpace = false; + private List exasolDbVersions = emptyList(); /** * Get CI build runner operating system, e.g. {@code ubuntu-20.04}. @@ -335,18 +338,24 @@ public void setRunnerOs(final String runnerOs) { this.runnerOs = runnerOs; } - /** - * @return {@code true} if the CI build should free disk space before running the build - */ + /** @return {@code true} if the CI build should free disk space before running the build */ public boolean shouldFreeDiskSpace() { return freeDiskSpace; } - /** - * @param freeDiskSpace {@code true} if the CI build should free disk space before running the build - */ + /** @param freeDiskSpace {@code true} if the CI build should free disk space before running the build */ public void setFreeDiskSpace(final boolean freeDiskSpace) { this.freeDiskSpace = freeDiskSpace; } + + /** @return Exasol DB versions for which to run the CI build */ + public List getExasolDbVersions() { + return exasolDbVersions; + } + + /** @param exasolDbVersions Exasol DB versions for which to run the CI build */ + public void setExasolDbVersions(final List exasolDbVersions) { + this.exasolDbVersions = exasolDbVersions; + } } } diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java index a30daecf..72dc1bcf 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java @@ -1,6 +1,7 @@ package com.exasol.projectkeeper.validators.files; import static com.exasol.projectkeeper.validators.files.FileTemplate.Validation.REQUIRE_EXACT; +import static java.util.stream.Collectors.joining; import com.exasol.projectkeeper.shared.config.BuildConfig; @@ -20,8 +21,31 @@ FileTemplate createReleaseDroidPrepareOriginalChecksumWorkflow() { } FileTemplateFromResource createCiBuildWorkflow() { - return new FileTemplateFromResource(".github/workflows/ci-build.yml", REQUIRE_EXACT) + final FileTemplateFromResource template = new FileTemplateFromResource(getCiBuildTemplate(), REQUIRE_EXACT) .replacing(CI_BUILD_RUNNER_OS_PLACEHOLDER, buildConfig.getRunnerOs()) .replacing("freeDiskSpace", String.valueOf(buildConfig.shouldFreeDiskSpace())); + + if (isMatrixBuild()) { + template.replacing("matrixExasolDbVersions", + buildConfig.getExasolDbVersions().stream().map(this::quote).collect(joining(", "))); + template.replacing("defaultExasolDbVersion", quote(buildConfig.getExasolDbVersions().get(0))); + } + return template; + } + + private String quote(final String value) { + return '"' + value + '"'; + } + + private String getCiBuildTemplate() { + if (isMatrixBuild()) { + return ".github/workflows/ci-build-db-version-matrix.yml"; + } else { + return ".github/workflows/ci-build.yml"; + } + } + + private boolean isMatrixBuild() { + return !buildConfig.getExasolDbVersions().isEmpty(); } } diff --git a/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml b/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml new file mode 100644 index 00000000..8fd514a1 --- /dev/null +++ b/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml @@ -0,0 +1,70 @@ +# Generated by Project Keeper +# https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml +name: CI Build +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: $ciBuildRunnerOS + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.exasol_db_version }} + cancel-in-progress: true + strategy: + fail-fast: false + matrix: + exasol_db_version: [$matrixExasolDbVersions] + env: + DEFAULT_EXASOL_DB_VERSION: $defaultExasolDbVersion + steps: + - name: Free Disk Space + if: ${{ $freeDiskSpace }} + run: | + sudo rm -rf /usr/local/lib/android + sudo rm -rf /usr/share/dotnet + - name: Checkout the repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up JDK 11 & 17 + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: | + 17 + 11 + cache: "maven" + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Enable testcontainer reuse + run: echo 'testcontainers.reuse.enable=true' > "$HOME/.testcontainers.properties" + - name: Run tests and build with Maven + run: | + JAVA_HOME=$JAVA_HOME_11_X64 mvn --batch-mode clean verify \ + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ + -DtrimStackTrace=false \ + -Dcom.exasol.dockerdb.image=${{ matrix.exasol_db_version }} + - name: Publish Test Report + uses: scacap/action-surefire-report@v1 + if: ${{ always() && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Sonar analysis + if: ${{ env.SONAR_TOKEN != null && matrix.exasol_db_version == env.DEFAULT_EXASOL_DB_VERSION }} + run: | + JAVA_HOME=$JAVA_HOME_17_X64 mvn --batch-mode org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ + -DtrimStackTrace=false \ + -Dsonar.organization=exasol \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.token=$SONAR_TOKEN + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/project-keeper/src/main/resources/templates/.github/workflows/ci-build.yml b/project-keeper/src/main/resources/templates/.github/workflows/ci-build.yml index bd6579c8..fbbf2a40 100644 --- a/project-keeper/src/main/resources/templates/.github/workflows/ci-build.yml +++ b/project-keeper/src/main/resources/templates/.github/workflows/ci-build.yml @@ -1,5 +1,6 @@ +# Generated by Project Keeper +# https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/ci-build.yml name: CI Build - on: push: branches: diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java index 92168d4e..aae65c91 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReaderTest.java @@ -56,6 +56,9 @@ void read() throws IOException { "build:\n" + // " runnerOs: custom-runner-os\n" + // " freeDiskSpace: true\n" + // + " exasolDbVersions:\n" + // + " - v1\n" + // + " - v2\n" + // "linkReplacements:\n" + // " - \"http://wrong-url.com|my-dependency.de\"\n"); final ProjectKeeperConfig config = this.reader.readConfig(this.tempDir); @@ -63,6 +66,7 @@ void read() throws IOException { assertAll(// () -> assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("custom-runner-os")), () -> assertThat(config.getCiBuildConfig().shouldFreeDiskSpace(), equalTo(true)), + () -> assertThat(config.getCiBuildConfig().getExasolDbVersions(), contains("v1", "v2")), () -> assertThat(source.getType(), equalTo(MAVEN)), () -> assertThat(source.isAdvertised(), equalTo(false)), () -> assertThat(source.getPath(), equalTo(this.tempDir.resolve("my-sub-project/pom.xml"))), @@ -96,6 +100,7 @@ void readDefaults() throws IOException { () -> assertThat(config.getExcludes(), equalTo(Collections.emptyList())), () -> assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("ubuntu-latest")), () -> assertThat(config.getCiBuildConfig().shouldFreeDiskSpace(), equalTo(false)), + () -> assertThat(config.getCiBuildConfig().getExasolDbVersions(), empty()), () -> assertThat(config.getLinkReplacements(), equalTo(Collections.emptyList()))// ); } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java index 7219a165..d7497e8c 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java @@ -1,7 +1,9 @@ package com.exasol.projectkeeper.validators.files; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.*; + +import java.util.List; import org.junit.jupiter.api.Test; import org.yaml.snakeyaml.Yaml; @@ -50,6 +52,27 @@ void ciBuildDoesFreeDiskSpace() { " if: ${{ true }}")); } + @Test + void ciBuildNonMatrixBuild() { + assertThat(ciBuildContent(BuildConfig.builder()), allOf( // + containsString("group: ${{ github.workflow }}-${{ github.ref }}\n"), // + not(containsString("matrix")), // + not(containsString("com.exasol.dockerdb.image")) // + )); + } + + @Test + void ciBuildMatrixBuild() { + assertThat(ciBuildContent(BuildConfig.builder().exasolDbVersions(List.of("v1", "v2"))), allOf( // + containsString("group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.exasol_db_version }}\n"), // + containsString("matrix:\n exasol_db_version: [\"v1\", \"v2\"]"), // + containsString("env:\n DEFAULT_EXASOL_DB_VERSION: \"v1\""), + containsString("-Dcom.exasol.dockerdb.image=${{ matrix.exasol_db_version }}"), // + containsString( + "- name: Sonar analysis\n if: ${{ env.SONAR_TOKEN != null && matrix.exasol_db_version == env.DEFAULT_EXASOL_DB_VERSION }}") // + )); + } + private String releaseDroidOriginalChecksumContent(final BuildConfig.Builder configBuilder) { final String content = testee(configBuilder).createReleaseDroidPrepareOriginalChecksumWorkflow().getContent(); validateYamlSyntax(content); diff --git a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java index fd9c6f96..aa96e00f 100644 --- a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java +++ b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java @@ -1,5 +1,9 @@ package com.exasol.projectkeeper.shared.config; +import static java.util.Collections.emptyList; +import static java.util.Collections.unmodifiableList; + +import java.util.List; import java.util.Objects; /** @@ -10,10 +14,12 @@ public final class BuildConfig { private final String runnerOs; private final boolean freeDiskSpace; + private final List exasolDbVersions; private BuildConfig(final Builder builder) { this.runnerOs = Objects.requireNonNull(builder.runnerOs, "runnerOs"); this.freeDiskSpace = builder.freeDiskSpace; + this.exasolDbVersions = unmodifiableList(Objects.requireNonNull(builder.exasolDbVersions, "exasolDbVersions")); } /** @return CI build runner operating system */ @@ -26,6 +32,15 @@ public boolean shouldFreeDiskSpace() { return freeDiskSpace; } + /** + * Exasol DB versions for which to run the CI build. If the list is empty, no Matrix build will be used. + * + * @return Exasol DB versions for which to run the build + */ + public List getExasolDbVersions() { + return exasolDbVersions; + } + /** * Creates builder to build {@link BuildConfig}. * @@ -39,6 +54,7 @@ public static Builder builder() { * Builder to build {@link BuildConfig}. */ public static final class Builder { + private List exasolDbVersions = emptyList(); private boolean freeDiskSpace = false; private String runnerOs = DEFAULT_RUNNER_OS; @@ -70,6 +86,20 @@ public Builder freeDiskSpace(final boolean freeDiskSpace) { return this; } + /** + * Run the CI build as a matrix build using the given Exasol DB versions. Sonar will only be run using the first + * version in the list. If the list is empty, no Matrix build will be used. + * + * @param exasolDbVersions Exasol DB versions for which to run the build + * @return {@code this} for fluent programming + */ + public Builder exasolDbVersions(final List exasolDbVersions) { + if (exasolDbVersions != null) { + this.exasolDbVersions = exasolDbVersions; + } + return this; + } + /** * Build a new {@link BuildConfig}. * @@ -82,12 +112,13 @@ public BuildConfig build() { @Override public String toString() { - return "BuildConfig [runnerOs=" + runnerOs + ", freeDiskSpace=" + freeDiskSpace + "]"; + return "BuildConfig [runnerOs=" + runnerOs + ", freeDiskSpace=" + freeDiskSpace + ",exasolDbVersions=" + + exasolDbVersions + "]"; } @Override public int hashCode() { - return Objects.hash(runnerOs, freeDiskSpace); + return Objects.hash(runnerOs, freeDiskSpace, exasolDbVersions); } @Override @@ -102,6 +133,7 @@ public boolean equals(final Object obj) { return false; } final BuildConfig other = (BuildConfig) obj; - return Objects.equals(runnerOs, other.runnerOs) && freeDiskSpace == other.freeDiskSpace; + return Objects.equals(runnerOs, other.runnerOs) && freeDiskSpace == other.freeDiskSpace + && Objects.equals(exasolDbVersions, other.exasolDbVersions); } } From 5741916f3770edfd76a6231cb8e3e345c12d2730 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 08:25:23 +0100 Subject: [PATCH 11/21] #488: Use correct path in project --- .../validators/files/CiBuildWorkflowGenerator.java | 7 ++++--- .../validators/files/CiBuildWorkflowGeneratorTest.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java index 72dc1bcf..39ee905a 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java @@ -21,7 +21,8 @@ FileTemplate createReleaseDroidPrepareOriginalChecksumWorkflow() { } FileTemplateFromResource createCiBuildWorkflow() { - final FileTemplateFromResource template = new FileTemplateFromResource(getCiBuildTemplate(), REQUIRE_EXACT) + final FileTemplateFromResource template = new FileTemplateFromResource( + "templates/.github/workflows/" + getCiBuildTemplate(), ".github/workflows/ci-build.yml", REQUIRE_EXACT) .replacing(CI_BUILD_RUNNER_OS_PLACEHOLDER, buildConfig.getRunnerOs()) .replacing("freeDiskSpace", String.valueOf(buildConfig.shouldFreeDiskSpace())); @@ -39,9 +40,9 @@ private String quote(final String value) { private String getCiBuildTemplate() { if (isMatrixBuild()) { - return ".github/workflows/ci-build-db-version-matrix.yml"; + return "ci-build-db-version-matrix.yml"; } else { - return ".github/workflows/ci-build.yml"; + return "ci-build.yml"; } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java index d7497e8c..6b3bb3e2 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java @@ -3,6 +3,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +import java.nio.file.Path; import java.util.List; import org.junit.jupiter.api.Test; @@ -74,13 +75,18 @@ void ciBuildMatrixBuild() { } private String releaseDroidOriginalChecksumContent(final BuildConfig.Builder configBuilder) { - final String content = testee(configBuilder).createReleaseDroidPrepareOriginalChecksumWorkflow().getContent(); + final FileTemplate template = testee(configBuilder).createReleaseDroidPrepareOriginalChecksumWorkflow(); + assertThat(template.getPathInProject(), + equalTo(Path.of(".github/workflows/release_droid_prepare_original_checksum.yml"))); + final String content = template.getContent(); validateYamlSyntax(content); return content; } private String ciBuildContent(final BuildConfig.Builder configBuilder) { - final String content = testee(configBuilder).createCiBuildWorkflow().getContent(); + final FileTemplateFromResource template = testee(configBuilder).createCiBuildWorkflow(); + assertThat(template.getPathInProject(), equalTo(Path.of(".github/workflows/ci-build.yml"))); + final String content = template.getContent(); validateYamlSyntax(content); return content; } From dc8cc687737b1fcc85ff0b026ec8abe16876a1ea Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 08:51:20 +0100 Subject: [PATCH 12/21] Update release date --- doc/changes/changes_2.9.16.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/changes_2.9.16.md b/doc/changes/changes_2.9.16.md index f94d3c8d..1ee36e48 100644 --- a/doc/changes/changes_2.9.16.md +++ b/doc/changes/changes_2.9.16.md @@ -1,4 +1,4 @@ -# Project Keeper 2.9.16, released 2023-11-10 +# Project Keeper 2.9.16, released 2023-11-13 Code name: Support Matrix builds & enable compiler warnings From 34bcfd9ef6196f53724cd2314b2d1ab678a5294c Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 09:09:11 +0100 Subject: [PATCH 13/21] Adapt tests for windows --- .../files/CiBuildWorkflowGeneratorTest.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java index 6b3bb3e2..59267392 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java @@ -13,6 +13,8 @@ class CiBuildWorkflowGeneratorTest { + private static String NL = System.lineSeparator(); + @Test void rdOrgChecksumContainsRunnerOs() { assertThat(releaseDroidOriginalChecksumContent(BuildConfig.builder().runnerOs("my-runner-os")), @@ -22,14 +24,14 @@ void rdOrgChecksumContainsRunnerOs() { @Test void rdOrgChecksumDoesNotFreeDiskSpace() { assertThat(releaseDroidOriginalChecksumContent(BuildConfig.builder().freeDiskSpace(false)), - containsString("- name: Free Disk Space\n" + // + containsString("- name: Free Disk Space" + NL + // " if: ${{ false }}")); } @Test void rdOrgChecksumDoesFreeDiskSpace() { assertThat(releaseDroidOriginalChecksumContent(BuildConfig.builder().freeDiskSpace(true)), - containsString("- name: Free Disk Space\n" + // + containsString("- name: Free Disk Space" + NL + // " if: ${{ true }}")); } @@ -42,21 +44,21 @@ void ciBuildContainsRunnerOs() { @Test void ciBuildDoesNotFreeDiskSpace() { assertThat(ciBuildContent(BuildConfig.builder().freeDiskSpace(false)), - containsString("- name: Free Disk Space\n" + // + containsString("- name: Free Disk Space" + NL + // " if: ${{ false }}")); } @Test void ciBuildDoesFreeDiskSpace() { assertThat(ciBuildContent(BuildConfig.builder().freeDiskSpace(true)), - containsString("- name: Free Disk Space\n" + // + containsString("- name: Free Disk Space" + NL + // " if: ${{ true }}")); } @Test void ciBuildNonMatrixBuild() { assertThat(ciBuildContent(BuildConfig.builder()), allOf( // - containsString("group: ${{ github.workflow }}-${{ github.ref }}\n"), // + containsString("group: ${{ github.workflow }}-${{ github.ref }}" + NL), // not(containsString("matrix")), // not(containsString("com.exasol.dockerdb.image")) // )); @@ -65,12 +67,12 @@ void ciBuildNonMatrixBuild() { @Test void ciBuildMatrixBuild() { assertThat(ciBuildContent(BuildConfig.builder().exasolDbVersions(List.of("v1", "v2"))), allOf( // - containsString("group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.exasol_db_version }}\n"), // - containsString("matrix:\n exasol_db_version: [\"v1\", \"v2\"]"), // - containsString("env:\n DEFAULT_EXASOL_DB_VERSION: \"v1\""), + containsString("group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.exasol_db_version }}" + NL), // + containsString("matrix:" + NL + " exasol_db_version: [\"v1\", \"v2\"]"), // + containsString("env:" + NL + " DEFAULT_EXASOL_DB_VERSION: \"v1\""), containsString("-Dcom.exasol.dockerdb.image=${{ matrix.exasol_db_version }}"), // - containsString( - "- name: Sonar analysis\n if: ${{ env.SONAR_TOKEN != null && matrix.exasol_db_version == env.DEFAULT_EXASOL_DB_VERSION }}") // + containsString("- name: Sonar analysis" + NL + + " if: ${{ env.SONAR_TOKEN != null && matrix.exasol_db_version == env.DEFAULT_EXASOL_DB_VERSION }}") // )); } From 3a4af7b6930900a5c40f93ce1d97dbbb4c98cc7c Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 09:13:50 +0100 Subject: [PATCH 14/21] Code cleanup --- .../validators/files/CiBuildWorkflowGenerator.java | 5 ++--- .../validators/files/FileTemplateFromResource.java | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java index 39ee905a..843fa699 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java @@ -6,7 +6,6 @@ import com.exasol.projectkeeper.shared.config.BuildConfig; class CiBuildWorkflowGenerator { - private static final String CI_BUILD_RUNNER_OS_PLACEHOLDER = "ciBuildRunnerOS"; private final BuildConfig buildConfig; CiBuildWorkflowGenerator(final BuildConfig buildConfig) { @@ -16,14 +15,14 @@ class CiBuildWorkflowGenerator { FileTemplate createReleaseDroidPrepareOriginalChecksumWorkflow() { return new FileTemplateFromResource(".github/workflows/release_droid_prepare_original_checksum.yml", REQUIRE_EXACT) // - .replacing(CI_BUILD_RUNNER_OS_PLACEHOLDER, buildConfig.getRunnerOs()) + .replacing("ciBuildRunnerOS", buildConfig.getRunnerOs()) .replacing("freeDiskSpace", String.valueOf(buildConfig.shouldFreeDiskSpace())); } FileTemplateFromResource createCiBuildWorkflow() { final FileTemplateFromResource template = new FileTemplateFromResource( "templates/.github/workflows/" + getCiBuildTemplate(), ".github/workflows/ci-build.yml", REQUIRE_EXACT) - .replacing(CI_BUILD_RUNNER_OS_PLACEHOLDER, buildConfig.getRunnerOs()) + .replacing("ciBuildRunnerOS", buildConfig.getRunnerOs()) .replacing("freeDiskSpace", String.valueOf(buildConfig.shouldFreeDiskSpace())); if (isMatrixBuild()) { diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResource.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResource.java index db71c005..13eee378 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResource.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplateFromResource.java @@ -41,8 +41,8 @@ public FileTemplateFromResource(final String templateResource, final String path } /** - * Add a replacement definition. {@link FileTemplateFromResource} identifies variables in the template by prefix "$" - * and replaces each variable with the value provided beforehand. + * Add a replacement definition. {@link FileTemplateFromResource} identifies variables in the template by prefix + * {@code $} and replaces each variable with the value provided beforehand. * * @param name name of the variable * @param replacement text that should be used to replace the variable From 8a4c7bb1a8c0dc77cde18c3c684fc2ce97fbc4bd Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 09:51:43 +0100 Subject: [PATCH 15/21] Add test for single db version --- .../files/CiBuildWorkflowGeneratorTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java index 59267392..bae27dab 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java @@ -76,6 +76,18 @@ void ciBuildMatrixBuild() { )); } + @Test + void ciBuildMatrixBuildSingleVersion() { + assertThat(ciBuildContent(BuildConfig.builder().exasolDbVersions(List.of("v1"))), allOf( // + containsString("group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.exasol_db_version }}" + NL), // + containsString("matrix:" + NL + " exasol_db_version: [\"v1\"]"), // + containsString("env:" + NL + " DEFAULT_EXASOL_DB_VERSION: \"v1\""), + containsString("-Dcom.exasol.dockerdb.image=${{ matrix.exasol_db_version }}"), // + containsString("- name: Sonar analysis" + NL + + " if: ${{ env.SONAR_TOKEN != null && matrix.exasol_db_version == env.DEFAULT_EXASOL_DB_VERSION }}") // + )); + } + private String releaseDroidOriginalChecksumContent(final BuildConfig.Builder configBuilder) { final FileTemplate template = testee(configBuilder).createReleaseDroidPrepareOriginalChecksumWorkflow(); assertThat(template.getPathInProject(), From 0d6ee7257ea82a806eec9a97fc236d3be88f0d23 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 10:36:57 +0100 Subject: [PATCH 16/21] Add env variable with Exasol version for Scala projects --- .../templates/.github/workflows/ci-build-db-version-matrix.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml b/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml index 8fd514a1..bc36504b 100644 --- a/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml +++ b/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml @@ -51,6 +51,8 @@ jobs: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -DtrimStackTrace=false \ -Dcom.exasol.dockerdb.image=${{ matrix.exasol_db_version }} + env: + EXASOL_DB_VERSION: ${{ matrix.exasol_db_version }} - name: Publish Test Report uses: scacap/action-surefire-report@v1 if: ${{ always() && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }} From bc93c8b8702760186081f5784edefbdd69aca698 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 10:41:57 +0100 Subject: [PATCH 17/21] Rename build config --- .../exasol/projectkeeper/ProjectKeeper.java | 2 +- .../config/ProjectKeeperConfigReader.java | 6 ++-- .../files/CiBuildWorkflowGenerator.java | 22 ++++++------- .../files/FileTemplatesFactory.java | 10 +++--- .../files/ProjectFilesValidator.java | 14 ++++---- .../files/CiBuildWorkflowGeneratorTest.java | 32 +++++++++---------- .../files/FileTemplatesFactoryTest.java | 4 +-- .../files/ProjectFilesValidatorTest.java | 4 +-- .../{BuildConfig.java => BuildOptions.java} | 16 +++++----- .../shared/config/ProjectKeeperConfig.java | 26 +++++++-------- ...dConfigTest.java => BuildOptionsTest.java} | 6 ++-- .../config/ProjectKeeperConfigTest.java | 4 +-- 12 files changed, 73 insertions(+), 73 deletions(-) rename shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/{BuildConfig.java => BuildOptions.java} (91%) rename shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/{BuildConfigTest.java => BuildOptionsTest.java} (65%) diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/ProjectKeeper.java b/project-keeper/src/main/java/com/exasol/projectkeeper/ProjectKeeper.java index c7170f60..46a9de64 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/ProjectKeeper.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/ProjectKeeper.java @@ -134,7 +134,7 @@ private ValidationPhase phase2(final ValidationPhase.Provision provision) { .logger(this.logger) // .projectKeeperVersion(this.ownVersion) // .hasNpmModule(hasSourceOfType(sources, SourceType.NPM)) // - .ciBuildConfig(config.getCiBuildConfig()) // + .ciBuildOptions(config.getCiBuildConfig()) // .build(); final List validators = List.of( // projectFilesValidator, diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java index adb5d0fb..2a14fa57 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java @@ -86,7 +86,7 @@ private ProjectKeeperConfig parseRawConfig(final ProjectKeeperRawConfig rawConfi .linkReplacements(linkReplacements) // .excludes(excludes) // .versionConfig(parseVersion(rawConfig.getVersion(), projectDir)) // - .buildConfig(convertBuildConfig(rawConfig.getBuild())) // + .buildOptions(convertBuildOptions(rawConfig.getBuild())) // .build(); } @@ -109,8 +109,8 @@ private VersionConfig parseVersion(final Object rawVersion, final Path projectDi .toString()); } - private BuildConfig convertBuildConfig(final Build build) { - return BuildConfig.builder() // + private BuildOptions convertBuildOptions(final Build build) { + return BuildOptions.builder() // .runnerOs(build != null ? build.getRunnerOs() : null) // .freeDiskSpace(build != null && build.shouldFreeDiskSpace()) // .exasolDbVersions(build != null ? build.getExasolDbVersions() : null) // diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java index 843fa699..39e1a1b0 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGenerator.java @@ -3,32 +3,32 @@ import static com.exasol.projectkeeper.validators.files.FileTemplate.Validation.REQUIRE_EXACT; import static java.util.stream.Collectors.joining; -import com.exasol.projectkeeper.shared.config.BuildConfig; +import com.exasol.projectkeeper.shared.config.BuildOptions; class CiBuildWorkflowGenerator { - private final BuildConfig buildConfig; + private final BuildOptions buildOptions; - CiBuildWorkflowGenerator(final BuildConfig buildConfig) { - this.buildConfig = buildConfig; + CiBuildWorkflowGenerator(final BuildOptions buildOptions) { + this.buildOptions = buildOptions; } FileTemplate createReleaseDroidPrepareOriginalChecksumWorkflow() { return new FileTemplateFromResource(".github/workflows/release_droid_prepare_original_checksum.yml", REQUIRE_EXACT) // - .replacing("ciBuildRunnerOS", buildConfig.getRunnerOs()) - .replacing("freeDiskSpace", String.valueOf(buildConfig.shouldFreeDiskSpace())); + .replacing("ciBuildRunnerOS", buildOptions.getRunnerOs()) + .replacing("freeDiskSpace", String.valueOf(buildOptions.shouldFreeDiskSpace())); } FileTemplateFromResource createCiBuildWorkflow() { final FileTemplateFromResource template = new FileTemplateFromResource( "templates/.github/workflows/" + getCiBuildTemplate(), ".github/workflows/ci-build.yml", REQUIRE_EXACT) - .replacing("ciBuildRunnerOS", buildConfig.getRunnerOs()) - .replacing("freeDiskSpace", String.valueOf(buildConfig.shouldFreeDiskSpace())); + .replacing("ciBuildRunnerOS", buildOptions.getRunnerOs()) + .replacing("freeDiskSpace", String.valueOf(buildOptions.shouldFreeDiskSpace())); if (isMatrixBuild()) { template.replacing("matrixExasolDbVersions", - buildConfig.getExasolDbVersions().stream().map(this::quote).collect(joining(", "))); - template.replacing("defaultExasolDbVersion", quote(buildConfig.getExasolDbVersions().get(0))); + buildOptions.getExasolDbVersions().stream().map(this::quote).collect(joining(", "))); + template.replacing("defaultExasolDbVersion", quote(buildOptions.getExasolDbVersions().get(0))); } return template; } @@ -46,6 +46,6 @@ private String getCiBuildTemplate() { } private boolean isMatrixBuild() { - return !buildConfig.getExasolDbVersions().isEmpty(); + return !buildOptions.getExasolDbVersions().isEmpty(); } } diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java index 0276948f..b73db74d 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactory.java @@ -8,7 +8,7 @@ import com.exasol.errorreporting.ExaError; import com.exasol.projectkeeper.Logger; -import com.exasol.projectkeeper.shared.config.BuildConfig; +import com.exasol.projectkeeper.shared.config.BuildOptions; import com.exasol.projectkeeper.shared.config.ProjectKeeperModule; import com.exasol.projectkeeper.sources.*; @@ -35,16 +35,16 @@ private static String lines(final String... line) { private final Logger logger; private final String ownVersion; private final boolean hasNpmModule; - private final BuildConfig buildConfig; + private final BuildOptions buildOptions; private final CiBuildWorkflowGenerator workflowGenerator; public FileTemplatesFactory(final Logger logger, final String ownVersion, final boolean hasNpmModule, - final BuildConfig buildConfig) { + final BuildOptions buildOptions) { this.logger = Objects.requireNonNull(logger, "logger"); this.ownVersion = Objects.requireNonNull(ownVersion, "ownVersion"); this.hasNpmModule = hasNpmModule; - this.buildConfig = Objects.requireNonNull(buildConfig, "buildConfig"); - this.workflowGenerator = new CiBuildWorkflowGenerator(this.buildConfig); + this.buildOptions = Objects.requireNonNull(buildOptions, "buildOptions"); + this.workflowGenerator = new CiBuildWorkflowGenerator(this.buildOptions); } List getGlobalTemplates(final List sources) { diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidator.java b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidator.java index 7034dca3..c168aba5 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidator.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidator.java @@ -10,7 +10,7 @@ import com.exasol.errorreporting.ExaError; import com.exasol.projectkeeper.Logger; import com.exasol.projectkeeper.Validator; -import com.exasol.projectkeeper.shared.config.BuildConfig; +import com.exasol.projectkeeper.shared.config.BuildOptions; import com.exasol.projectkeeper.sources.AnalyzedSource; import com.exasol.projectkeeper.validators.files.RequiredFileValidator.ContentValidator; import com.exasol.projectkeeper.validators.finding.ValidationFinding; @@ -25,7 +25,7 @@ public class ProjectFilesValidator implements Validator { private final Logger logger; private final String projectKeeperVersion; private final boolean hasNpmModule; - private final BuildConfig buildConfig; + private final BuildOptions buildConfig; private ProjectFilesValidator(final Builder builder) { this.projectDirectory = Objects.requireNonNull(builder.projectDirectory, "projectDirectory"); @@ -33,7 +33,7 @@ private ProjectFilesValidator(final Builder builder) { this.logger = Objects.requireNonNull(builder.logger, "logger"); this.projectKeeperVersion = Objects.requireNonNull(builder.projectKeeperVersion, "projectKeeperVersion"); this.hasNpmModule = builder.hasNpmModule; - this.buildConfig = Objects.requireNonNull(builder.buildConfig, "buildConfig"); + this.buildConfig = Objects.requireNonNull(builder.buildOptions, "buildConfig"); } @Override @@ -112,7 +112,7 @@ public static final class Builder { private Logger logger; private String projectKeeperVersion; private boolean hasNpmModule; - private BuildConfig buildConfig; + private BuildOptions buildOptions; private Builder() { // empty by intention @@ -164,11 +164,11 @@ public Builder hasNpmModule(final boolean value) { } /** - * @param buildConfig CI build configuration + * @param buildOptions CI build options * @return {@code this} for fluent programming */ - public Builder ciBuildConfig(final BuildConfig buildConfig) { - this.buildConfig = buildConfig; + public Builder ciBuildOptions(final BuildOptions buildOptions) { + this.buildOptions = buildOptions; return this; } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java index bae27dab..b9060cba 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test; import org.yaml.snakeyaml.Yaml; -import com.exasol.projectkeeper.shared.config.BuildConfig; +import com.exasol.projectkeeper.shared.config.BuildOptions; class CiBuildWorkflowGeneratorTest { @@ -17,47 +17,47 @@ class CiBuildWorkflowGeneratorTest { @Test void rdOrgChecksumContainsRunnerOs() { - assertThat(releaseDroidOriginalChecksumContent(BuildConfig.builder().runnerOs("my-runner-os")), + assertThat(releaseDroidOriginalChecksumContent(BuildOptions.builder().runnerOs("my-runner-os")), containsString("runs-on: my-runner-os")); } @Test void rdOrgChecksumDoesNotFreeDiskSpace() { - assertThat(releaseDroidOriginalChecksumContent(BuildConfig.builder().freeDiskSpace(false)), + assertThat(releaseDroidOriginalChecksumContent(BuildOptions.builder().freeDiskSpace(false)), containsString("- name: Free Disk Space" + NL + // " if: ${{ false }}")); } @Test void rdOrgChecksumDoesFreeDiskSpace() { - assertThat(releaseDroidOriginalChecksumContent(BuildConfig.builder().freeDiskSpace(true)), + assertThat(releaseDroidOriginalChecksumContent(BuildOptions.builder().freeDiskSpace(true)), containsString("- name: Free Disk Space" + NL + // " if: ${{ true }}")); } @Test void ciBuildContainsRunnerOs() { - assertThat(ciBuildContent(BuildConfig.builder().runnerOs("my-runner-os")), + assertThat(ciBuildContent(BuildOptions.builder().runnerOs("my-runner-os")), containsString("runs-on: my-runner-os")); } @Test void ciBuildDoesNotFreeDiskSpace() { - assertThat(ciBuildContent(BuildConfig.builder().freeDiskSpace(false)), + assertThat(ciBuildContent(BuildOptions.builder().freeDiskSpace(false)), containsString("- name: Free Disk Space" + NL + // " if: ${{ false }}")); } @Test void ciBuildDoesFreeDiskSpace() { - assertThat(ciBuildContent(BuildConfig.builder().freeDiskSpace(true)), + assertThat(ciBuildContent(BuildOptions.builder().freeDiskSpace(true)), containsString("- name: Free Disk Space" + NL + // " if: ${{ true }}")); } @Test void ciBuildNonMatrixBuild() { - assertThat(ciBuildContent(BuildConfig.builder()), allOf( // + assertThat(ciBuildContent(BuildOptions.builder()), allOf( // containsString("group: ${{ github.workflow }}-${{ github.ref }}" + NL), // not(containsString("matrix")), // not(containsString("com.exasol.dockerdb.image")) // @@ -66,7 +66,7 @@ void ciBuildNonMatrixBuild() { @Test void ciBuildMatrixBuild() { - assertThat(ciBuildContent(BuildConfig.builder().exasolDbVersions(List.of("v1", "v2"))), allOf( // + assertThat(ciBuildContent(BuildOptions.builder().exasolDbVersions(List.of("v1", "v2"))), allOf( // containsString("group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.exasol_db_version }}" + NL), // containsString("matrix:" + NL + " exasol_db_version: [\"v1\", \"v2\"]"), // containsString("env:" + NL + " DEFAULT_EXASOL_DB_VERSION: \"v1\""), @@ -78,7 +78,7 @@ void ciBuildMatrixBuild() { @Test void ciBuildMatrixBuildSingleVersion() { - assertThat(ciBuildContent(BuildConfig.builder().exasolDbVersions(List.of("v1"))), allOf( // + assertThat(ciBuildContent(BuildOptions.builder().exasolDbVersions(List.of("v1"))), allOf( // containsString("group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.exasol_db_version }}" + NL), // containsString("matrix:" + NL + " exasol_db_version: [\"v1\"]"), // containsString("env:" + NL + " DEFAULT_EXASOL_DB_VERSION: \"v1\""), @@ -88,8 +88,8 @@ void ciBuildMatrixBuildSingleVersion() { )); } - private String releaseDroidOriginalChecksumContent(final BuildConfig.Builder configBuilder) { - final FileTemplate template = testee(configBuilder).createReleaseDroidPrepareOriginalChecksumWorkflow(); + private String releaseDroidOriginalChecksumContent(final BuildOptions.Builder optionsBuilder) { + final FileTemplate template = testee(optionsBuilder).createReleaseDroidPrepareOriginalChecksumWorkflow(); assertThat(template.getPathInProject(), equalTo(Path.of(".github/workflows/release_droid_prepare_original_checksum.yml"))); final String content = template.getContent(); @@ -97,8 +97,8 @@ private String releaseDroidOriginalChecksumContent(final BuildConfig.Builder con return content; } - private String ciBuildContent(final BuildConfig.Builder configBuilder) { - final FileTemplateFromResource template = testee(configBuilder).createCiBuildWorkflow(); + private String ciBuildContent(final BuildOptions.Builder optionsBuilder) { + final FileTemplateFromResource template = testee(optionsBuilder).createCiBuildWorkflow(); assertThat(template.getPathInProject(), equalTo(Path.of(".github/workflows/ci-build.yml"))); final String content = template.getContent(); validateYamlSyntax(content); @@ -109,7 +109,7 @@ private void validateYamlSyntax(final String content) { new Yaml().load(content); } - private CiBuildWorkflowGenerator testee(final BuildConfig.Builder configBuilder) { - return new CiBuildWorkflowGenerator(configBuilder.build()); + private CiBuildWorkflowGenerator testee(final BuildOptions.Builder optionsBuilder) { + return new CiBuildWorkflowGenerator(optionsBuilder.build()); } } diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactoryTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactoryTest.java index d8105685..084761a0 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactoryTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/FileTemplatesFactoryTest.java @@ -20,7 +20,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import com.exasol.projectkeeper.Logger; -import com.exasol.projectkeeper.shared.config.BuildConfig; +import com.exasol.projectkeeper.shared.config.BuildOptions; import com.exasol.projectkeeper.shared.config.ProjectKeeperModule; import com.exasol.projectkeeper.sources.AnalyzedMavenSource; import com.exasol.projectkeeper.sources.AnalyzedSource; @@ -49,7 +49,7 @@ private FileTemplatesFactory testee() { private FileTemplatesFactory testee(final boolean hasNpmModule) { return new FileTemplatesFactory(this.loggerMock, OWN_VERSION, hasNpmModule, - BuildConfig.builder().runnerOs("ci-build-runner-os").build()); + BuildOptions.builder().runnerOs("ci-build-runner-os").build()); } private List getMavenSourceWithModules(final Set modules) { diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidatorTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidatorTest.java index cc4bf9fe..16553b1a 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidatorTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/ProjectFilesValidatorTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.io.TempDir; import com.exasol.projectkeeper.Logger; -import com.exasol.projectkeeper.shared.config.BuildConfig; +import com.exasol.projectkeeper.shared.config.BuildOptions; import com.exasol.projectkeeper.shared.config.ProjectKeeperModule; import com.exasol.projectkeeper.sources.AnalyzedMavenSource; import com.exasol.projectkeeper.sources.AnalyzedSource; @@ -158,7 +158,7 @@ private ProjectFilesValidator testee(final List sources) { .analyzedSources(sources) // .logger(mock(Logger.class)) // .projectKeeperVersion(OWN_VERSION) // - .ciBuildConfig(BuildConfig.builder().runnerOs("ci-runner-os").build()) // + .ciBuildOptions(BuildOptions.builder().runnerOs("ci-runner-os").build()) // .build(); } diff --git a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildOptions.java similarity index 91% rename from shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java rename to shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildOptions.java index aa96e00f..405e6693 100644 --- a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildConfig.java +++ b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/BuildOptions.java @@ -9,14 +9,14 @@ /** * CI build configuration. */ -public final class BuildConfig { +public final class BuildOptions { private static final String DEFAULT_RUNNER_OS = "ubuntu-latest"; private final String runnerOs; private final boolean freeDiskSpace; private final List exasolDbVersions; - private BuildConfig(final Builder builder) { + private BuildOptions(final Builder builder) { this.runnerOs = Objects.requireNonNull(builder.runnerOs, "runnerOs"); this.freeDiskSpace = builder.freeDiskSpace; this.exasolDbVersions = unmodifiableList(Objects.requireNonNull(builder.exasolDbVersions, "exasolDbVersions")); @@ -42,7 +42,7 @@ public List getExasolDbVersions() { } /** - * Creates builder to build {@link BuildConfig}. + * Creates builder to build {@link BuildOptions}. * * @return created builder */ @@ -51,7 +51,7 @@ public static Builder builder() { } /** - * Builder to build {@link BuildConfig}. + * Builder to build {@link BuildOptions}. */ public static final class Builder { private List exasolDbVersions = emptyList(); @@ -101,12 +101,12 @@ public Builder exasolDbVersions(final List exasolDbVersions) { } /** - * Build a new {@link BuildConfig}. + * Build a new {@link BuildOptions}. * * @return built class */ - public BuildConfig build() { - return new BuildConfig(this); + public BuildOptions build() { + return new BuildOptions(this); } } @@ -132,7 +132,7 @@ public boolean equals(final Object obj) { if (getClass() != obj.getClass()) { return false; } - final BuildConfig other = (BuildConfig) obj; + final BuildOptions other = (BuildOptions) obj; return Objects.equals(runnerOs, other.runnerOs) && freeDiskSpace == other.freeDiskSpace && Objects.equals(exasolDbVersions, other.exasolDbVersions); } diff --git a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java index 5bb68f75..3b3018eb 100644 --- a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java +++ b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java @@ -14,14 +14,14 @@ public final class ProjectKeeperConfig { // [impl->dsn~excluding~1] private final List excludes; private final VersionConfig versionConfig; - private final BuildConfig buildConfig; + private final BuildOptions buildOptions; private ProjectKeeperConfig(final Builder builder) { this.sources = Objects.requireNonNull(builder.sources, "sources"); this.linkReplacements = Objects.requireNonNull(builder.linkReplacements, "linkReplacements"); this.excludes = Objects.requireNonNull(builder.excludes, "excludes"); this.versionConfig = builder.versionConfig; - this.buildConfig = Objects.requireNonNull(builder.buildConfig, "buildConfig"); + this.buildOptions = Objects.requireNonNull(builder.buildOptions, "buildOptions"); } /** @return List with source-projects to crawl */ @@ -45,8 +45,8 @@ public VersionConfig getVersionConfig() { } /** @return CI build configuration */ - public BuildConfig getCiBuildConfig() { - return this.buildConfig; + public BuildOptions getCiBuildConfig() { + return this.buildOptions; } /** @return a new builder for creating {@link ProjectKeeperConfig} instances */ @@ -62,7 +62,7 @@ public static class Builder { private List linkReplacements = Collections.emptyList(); private List excludes = Collections.emptyList(); private VersionConfig versionConfig; - private BuildConfig buildConfig = BuildConfig.builder().build(); + private BuildOptions buildOptions = BuildOptions.builder().build(); private Builder() { // empty by intention @@ -105,12 +105,12 @@ public ProjectKeeperConfig.Builder versionConfig(final VersionConfig versionConf } /** - * @param buildConfig project build configuration + * @param buildOptions project build configuration * @return {@code this}. */ - public ProjectKeeperConfig.Builder buildConfig(final BuildConfig buildConfig) { - if (buildConfig != null) { - this.buildConfig = buildConfig; + public ProjectKeeperConfig.Builder buildOptions(final BuildOptions buildOptions) { + if (buildOptions != null) { + this.buildOptions = buildOptions; } return this; } @@ -124,13 +124,13 @@ public ProjectKeeperConfig build() { @Override public String toString() { return "ProjectKeeperConfig [sources=" + this.sources + ", linkReplacements=" + this.linkReplacements - + ", excludes=" + this.excludes + ", versionConfig=" + this.versionConfig + ", buildConfig=" - + this.buildConfig + "]"; + + ", excludes=" + this.excludes + ", versionConfig=" + this.versionConfig + ", buildOptions=" + + this.buildOptions + "]"; } @Override public int hashCode() { - return Objects.hash(this.sources, this.linkReplacements, this.excludes, this.versionConfig, this.buildConfig); + return Objects.hash(this.sources, this.linkReplacements, this.excludes, this.versionConfig, this.buildOptions); } @Override @@ -149,6 +149,6 @@ public boolean equals(final Object obj) { && Objects.equals(this.linkReplacements, other.linkReplacements) && Objects.equals(this.excludes, other.excludes) && Objects.equals(this.versionConfig, other.versionConfig) - && Objects.equals(this.buildConfig, other.buildConfig); + && Objects.equals(this.buildOptions, other.buildOptions); } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildConfigTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildOptionsTest.java similarity index 65% rename from shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildConfigTest.java rename to shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildOptionsTest.java index b0c818c4..43080500 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildConfigTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/BuildOptionsTest.java @@ -6,15 +6,15 @@ import nl.jqno.equalsverifier.EqualsVerifier; -class BuildConfigTest { +class BuildOptionsTest { @Test void testEqualsContract() { - EqualsVerifier.forClass(BuildConfig.class).verify(); + EqualsVerifier.forClass(BuildOptions.class).verify(); } @Test void testToString() { - ToStringVerifier.forClass(BuildConfig.class).verify(); + ToStringVerifier.forClass(BuildOptions.class).verify(); } } diff --git a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java index f578d7cf..f54d77dc 100644 --- a/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java +++ b/shared-model-classes/src/test/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfigTest.java @@ -30,7 +30,7 @@ void createConfig() { .build())) .excludes(List.of("exclude1")).linkReplacements(List.of("linkReplacement1")) .versionConfig(new VersionFromSource(Path.of("version-pom.xml"))) - .buildConfig(BuildConfig.builder().runnerOs("runner-os").build()).build(); + .buildOptions(BuildOptions.builder().runnerOs("runner-os").build()).build(); assertAll(() -> assertThat(config.getExcludes(), contains("exclude1")), () -> assertThat(config.getLinkReplacements(), contains("linkReplacement1")), () -> assertThat(config.getVersionConfig(), instanceOf(VersionFromSource.class)), @@ -55,7 +55,7 @@ void createConfigWithDefaultRunnerOS() { @Test void createConfigWithNullRunnerOS() { - final ProjectKeeperConfig config = ProjectKeeperConfig.builder().buildConfig(null).build(); + final ProjectKeeperConfig config = ProjectKeeperConfig.builder().buildOptions(null).build(); assertThat(config.getCiBuildConfig().getRunnerOs(), equalTo("ubuntu-latest")); } From 8c697591e3d62b064436666d4843f69c6b60e648 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 10:49:52 +0100 Subject: [PATCH 18/21] Simplify converting build options --- .../projectkeeper/config/ProjectKeeperConfigReader.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java index 2a14fa57..264fc3f1 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperConfigReader.java @@ -110,10 +110,13 @@ private VersionConfig parseVersion(final Object rawVersion, final Path projectDi } private BuildOptions convertBuildOptions(final Build build) { + if (build == null) { + return BuildOptions.builder().build(); + } return BuildOptions.builder() // - .runnerOs(build != null ? build.getRunnerOs() : null) // - .freeDiskSpace(build != null && build.shouldFreeDiskSpace()) // - .exasolDbVersions(build != null ? build.getExasolDbVersions() : null) // + .runnerOs(build.getRunnerOs()) // + .freeDiskSpace(build.shouldFreeDiskSpace()) // + .exasolDbVersions(build.getExasolDbVersions()) // .build(); } From 3d26f697a96f8451db21bc7a9c46d0f642a4335b Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 10:52:15 +0100 Subject: [PATCH 19/21] Fix comment --- .../exasol/projectkeeper/config/ProjectKeeperRawConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java index c58cf68f..b09d4ffd 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java @@ -311,7 +311,8 @@ public void setRelativePath(final String relativePath) { } /** - * Intermediate class for reading the CI build configuration sources. + * Intermediate class for de-serializing build options from PK's YAML configuration file + * {@link ProjectKeeperConfigReader#CONFIG_FILE_NAME}. *

* SnakeYML requires this class to be public. */ From 715389e92231e8d306fe60c116b9e9c46c4604e0 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 11:54:15 +0100 Subject: [PATCH 20/21] Check validation type --- .../files/CiBuildWorkflowGeneratorTest.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java index b9060cba..556154b4 100644 --- a/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java +++ b/project-keeper/src/test/java/com/exasol/projectkeeper/validators/files/CiBuildWorkflowGeneratorTest.java @@ -2,6 +2,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.nio.file.Path; import java.util.List; @@ -10,6 +12,7 @@ import org.yaml.snakeyaml.Yaml; import com.exasol.projectkeeper.shared.config.BuildOptions; +import com.exasol.projectkeeper.validators.files.FileTemplate.Validation; class CiBuildWorkflowGeneratorTest { @@ -90,23 +93,26 @@ void ciBuildMatrixBuildSingleVersion() { private String releaseDroidOriginalChecksumContent(final BuildOptions.Builder optionsBuilder) { final FileTemplate template = testee(optionsBuilder).createReleaseDroidPrepareOriginalChecksumWorkflow(); - assertThat(template.getPathInProject(), - equalTo(Path.of(".github/workflows/release_droid_prepare_original_checksum.yml"))); final String content = template.getContent(); - validateYamlSyntax(content); + assertAll(() -> assertThat(template.getValidation(), equalTo(Validation.REQUIRE_EXACT)), + () -> assertThat(template.getPathInProject(), + equalTo(Path.of(".github/workflows/release_droid_prepare_original_checksum.yml"))), + () -> validateYamlSyntax(content)); return content; } private String ciBuildContent(final BuildOptions.Builder optionsBuilder) { final FileTemplateFromResource template = testee(optionsBuilder).createCiBuildWorkflow(); - assertThat(template.getPathInProject(), equalTo(Path.of(".github/workflows/ci-build.yml"))); final String content = template.getContent(); - validateYamlSyntax(content); + assertAll(() -> assertThat(template.getPathInProject(), equalTo(Path.of(".github/workflows/ci-build.yml"))), + () -> assertThat(template.getValidation(), equalTo(Validation.REQUIRE_EXACT)), + () -> validateYamlSyntax(content)); return content; } private void validateYamlSyntax(final String content) { - new Yaml().load(content); + final Yaml yaml = new Yaml(); + assertDoesNotThrow(() -> yaml.load(content)); } private CiBuildWorkflowGenerator testee(final BuildOptions.Builder optionsBuilder) { From d9e9d5af2c352bf914b3e836251c05fa4e9efca7 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Mon, 13 Nov 2023 12:09:50 +0100 Subject: [PATCH 21/21] Apply suggestions from code review Co-authored-by: Christoph Kuhnke --- .../exasol/projectkeeper/config/ProjectKeeperRawConfig.java | 4 ++-- .../.github/workflows/ci-build-db-version-matrix.yml | 2 ++ .../projectkeeper/shared/config/ProjectKeeperConfig.java | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java index b09d4ffd..bb70bb7e 100644 --- a/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java +++ b/project-keeper/src/main/java/com/exasol/projectkeeper/config/ProjectKeeperRawConfig.java @@ -107,14 +107,14 @@ public void setVersion(final Object version) { /** * Get the CI build configuration. * - * @return build configuration + * @return build options */ public Build getBuild() { return build; } /** - * Set the CI build configuration. + * Set the CI build options. * * @param build build configuration */ diff --git a/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml b/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml index bc36504b..e2def04a 100644 --- a/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml +++ b/project-keeper/src/main/resources/templates/.github/workflows/ci-build-db-version-matrix.yml @@ -52,6 +52,8 @@ jobs: -DtrimStackTrace=false \ -Dcom.exasol.dockerdb.image=${{ matrix.exasol_db_version }} env: + # Set additional environment variable as in scala projects the scalatest plugin does not forward + # the system property -Dcom.exasol.dockerdb.image to the test's implementation. EXASOL_DB_VERSION: ${{ matrix.exasol_db_version }} - name: Publish Test Report uses: scacap/action-surefire-report@v1 diff --git a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java index 3b3018eb..b312df57 100644 --- a/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java +++ b/shared-model-classes/src/main/java/com/exasol/projectkeeper/shared/config/ProjectKeeperConfig.java @@ -44,7 +44,7 @@ public VersionConfig getVersionConfig() { return this.versionConfig; } - /** @return CI build configuration */ + /** @return CI build options */ public BuildOptions getCiBuildConfig() { return this.buildOptions; } @@ -105,7 +105,7 @@ public ProjectKeeperConfig.Builder versionConfig(final VersionConfig versionConf } /** - * @param buildOptions project build configuration + * @param buildOptions options for project build workflows * @return {@code this}. */ public ProjectKeeperConfig.Builder buildOptions(final BuildOptions buildOptions) {