Skip to content

Commit 29033dd

Browse files
authored
Merge pull request #2 from dataliquid/bugfix/fix-ci-integration-tests
Fix CI integration test failures
2 parents bc8c741 + a5f05a3 commit 29033dd

24 files changed

Lines changed: 593 additions & 299 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
java: [ 17, 21 ]
14+
java: [ 21 ]
1515

1616
steps:
1717
- uses: actions/checkout@v4

src/main/resources/META-INF/archetype-post-generate.groovy

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/main/resources/META-INF/maven/archetype-metadata.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
<requiredProperty key="javaVersion">
2222
<defaultValue>17</defaultValue>
2323
</requiredProperty>
24+
<requiredProperty key="gitignore">
25+
<defaultValue>.gitignore</defaultValue>
26+
</requiredProperty>
27+
<requiredProperty key="github">
28+
<defaultValue>.github</defaultValue>
29+
</requiredProperty>
2430
</requiredProperties>
2531

2632
<fileSets>

src/test/resources/projects/basic/archetype.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ groupId=com.example.test
22
artifactId=test-project
33
version=1.0.0-SNAPSHOT
44
package=com.example.test
5-
javaVersion=17
5+
javaVersion=17
6+
gitignore=.gitignore
7+
github=.github
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
clean test
1+
clean test
Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
11
// Verify the generated project
22
def projectDir = new File(basedir, "project/test-project")
33

4-
// Check basic structure
5-
assert projectDir.exists() : "Project directory should exist: ${projectDir}"
6-
assert new File(projectDir, "pom.xml").exists() : "pom.xml should exist"
7-
assert new File(projectDir, "LICENSE").exists() : "LICENSE should exist"
8-
assert new File(projectDir, ".gitignore").exists() : ".gitignore should exist"
9-
10-
// Check GitHub workflows
11-
assert new File(projectDir, ".github/workflows").exists() : ".github/workflows should exist"
12-
assert new File(projectDir, ".github/workflows/ci.yml").exists() : "CI workflow should exist"
13-
assert new File(projectDir, ".github/workflows/dependency-check.yml").exists() : "Dependency check workflow should exist"
14-
assert new File(projectDir, ".github/workflows/gitflow-release.yml").exists() : "Gitflow release workflow should exist"
15-
assert new File(projectDir, ".github/workflows/gitflow-hotfix.yml").exists() : "Gitflow hotfix workflow should exist"
16-
17-
// Check source directories
18-
assert new File(projectDir, "src/main/java/com/example/test/App.java").exists() : "Main App.java should exist"
19-
assert new File(projectDir, "src/test/java/com/example/test/AppTest.java").exists() : "Test AppTest.java should exist"
20-
21-
println "Integration test passed: All expected files were created!"
22-
return true
4+
try {
5+
println "Starting verification for: ${basedir}"
6+
7+
// Check basic structure
8+
println "Checking project directory exists: ${projectDir}"
9+
assert projectDir.exists() : "Project directory should exist: ${projectDir}"
10+
11+
println "Checking pom.xml..."
12+
assert new File(projectDir, "pom.xml").exists() : "pom.xml should exist"
13+
14+
println "Checking LICENSE..."
15+
assert new File(projectDir, "LICENSE").exists() : "LICENSE should exist"
16+
17+
println "Checking .gitignore..."
18+
assert new File(projectDir, ".gitignore").exists() : ".gitignore should exist"
19+
println "PASS: Basic structure validated"
20+
21+
// Check GitHub workflows
22+
println "Checking GitHub workflows..."
23+
assert new File(projectDir, ".github/workflows").exists() : ".github/workflows should exist"
24+
assert new File(projectDir, ".github/workflows/ci.yml").exists() : "CI workflow should exist"
25+
assert new File(projectDir, ".github/workflows/dependency-check.yml").exists() : "Dependency check workflow should exist"
26+
assert new File(projectDir, ".github/workflows/gitflow-release.yml").exists() : "Gitflow release workflow should exist"
27+
assert new File(projectDir, ".github/workflows/gitflow-hotfix.yml").exists() : "Gitflow hotfix workflow should exist"
28+
println "PASS: GitHub workflows validated"
29+
30+
// Check source directories
31+
println "Checking source directories..."
32+
assert new File(projectDir, "src/main/java/com/example/test/App.java").exists() : "Main App.java should exist"
33+
assert new File(projectDir, "src/test/java/com/example/test/AppTest.java").exists() : "Test AppTest.java should exist"
34+
println "PASS: Source directories validated"
35+
36+
println "VERIFICATION PASSED"
37+
return true
38+
} catch (AssertionError e) {
39+
println "ERROR: ASSERTION FAILED: ${e.message}"
40+
throw e
41+
} catch (Exception e) {
42+
println "ERROR: UNEXPECTED: ${e.message}"
43+
e.printStackTrace()
44+
throw e
45+
}

src/test/resources/projects/custom-package/archetype.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ groupId=com.mycompany
22
artifactId=custom-pkg-app
33
version=1.5.0
44
package=org.custompackage.application
5-
javaVersion=17
5+
javaVersion=17
6+
gitignore=.gitignore
7+
github=.github
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
clean test
1+
clean test
Lines changed: 86 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,89 @@
11
// Verify custom package parameter works correctly
22
def projectDir = new File(basedir, "project/custom-pkg-app")
33

4-
assert projectDir.exists()
5-
6-
// Check POM has correct groupId and artifactId
7-
def pomFile = new File(projectDir, "pom.xml")
8-
def pomContent = pomFile.text
9-
assert pomContent.contains("<groupId>com.mycompany</groupId>")
10-
assert pomContent.contains("<artifactId>custom-pkg-app</artifactId>")
11-
assert pomContent.contains("<version>1.5.0</version>")
12-
assert pomContent.contains("<maven.compiler.release>17</maven.compiler.release>")
13-
14-
// Check that package structure uses custom package, NOT groupId
15-
assert new File(projectDir, "src/main/java/org/custompackage/application/App.java").exists()
16-
assert new File(projectDir, "src/test/java/org/custompackage/application/AppTest.java").exists()
17-
18-
// Should NOT have the groupId package structure
19-
assert !new File(projectDir, "src/main/java/com/mycompany").exists()
20-
21-
// Check package declaration in source files
22-
def appFile = new File(projectDir, "src/main/java/org/custompackage/application/App.java")
23-
def appContent = appFile.text
24-
assert appContent.contains("package org.custompackage.application;")
25-
assert !appContent.contains("package com.mycompany;")
26-
27-
def testFile = new File(projectDir, "src/test/java/org/custompackage/application/AppTest.java")
28-
def testContent = testFile.text
29-
assert testContent.contains("package org.custompackage.application;")
30-
31-
// Check test.properties
32-
def testPropsFile = new File(projectDir, "src/test/resources/test.properties")
33-
def testPropsContent = testPropsFile.text
34-
assert testPropsContent.contains("app.test.java.version=17")
35-
assert testPropsContent.contains("app.test.version=1.5.0")
36-
assert testPropsContent.contains("app.test.name=custom-pkg-app-test")
37-
38-
// Check GitHub workflows exist
39-
assert new File(projectDir, ".github/workflows/ci.yml").exists()
40-
assert new File(projectDir, ".github/workflows/dependency-check.yml").exists()
41-
assert new File(projectDir, ".github/workflows/gitflow-release.yml").exists()
42-
assert new File(projectDir, ".github/workflows/gitflow-hotfix.yml").exists()
43-
44-
// Check .gitignore exists
45-
assert new File(projectDir, ".gitignore").exists()
46-
47-
println "Custom package test passed - package parameter correctly overrides groupId!"
48-
return true
4+
try {
5+
println "Starting verification for: ${basedir}"
6+
7+
println "Checking project directory exists: ${projectDir}"
8+
assert projectDir.exists() : "Project directory does not exist: ${projectDir}"
9+
10+
// Check POM has correct groupId and artifactId
11+
def pomFile = new File(projectDir, "pom.xml")
12+
println "Checking POM file: ${pomFile}"
13+
assert pomFile.exists() : "POM file does not exist: ${pomFile}"
14+
15+
def pomContent = pomFile.text
16+
assert pomContent.contains("<groupId>com.mycompany</groupId>") : "POM missing correct groupId"
17+
assert pomContent.contains("<artifactId>custom-pkg-app</artifactId>") : "POM missing correct artifactId"
18+
assert pomContent.contains("<version>1.5.0</version>") : "POM missing correct version"
19+
assert pomContent.contains("<maven.compiler.release>17</maven.compiler.release>") : "POM missing Java 17 compiler release"
20+
println "PASS: POM file validated"
21+
22+
// Check that package structure uses custom package, NOT groupId
23+
println "Checking custom package structure..."
24+
def appJavaFile = new File(projectDir, "src/main/java/org/custompackage/application/App.java")
25+
assert appJavaFile.exists() : "App.java does not exist at: ${appJavaFile}"
26+
27+
def testJavaFile = new File(projectDir, "src/test/java/org/custompackage/application/AppTest.java")
28+
assert testJavaFile.exists() : "AppTest.java does not exist at: ${testJavaFile}"
29+
30+
// Should NOT have the groupId package structure
31+
def wrongPackageDir = new File(projectDir, "src/main/java/com/mycompany")
32+
assert !wrongPackageDir.exists() : "Wrong package structure exists (should use custom package, not groupId): ${wrongPackageDir}"
33+
println "PASS: Custom package structure validated"
34+
35+
// Check package declaration in source files
36+
println "Checking package declarations..."
37+
def appContent = appJavaFile.text
38+
assert appContent.contains("package org.custompackage.application;") :
39+
"App.java has incorrect package declaration"
40+
assert !appContent.contains("package com.mycompany;") :
41+
"App.java contains wrong package declaration (com.mycompany)"
42+
43+
def testContent = testJavaFile.text
44+
assert testContent.contains("package org.custompackage.application;") :
45+
"AppTest.java has incorrect package declaration"
46+
println "PASS: Package declarations validated"
47+
48+
// Check test.properties
49+
def testPropsFile = new File(projectDir, "src/test/resources/test.properties")
50+
println "Checking test properties: ${testPropsFile}"
51+
assert testPropsFile.exists() : "test.properties does not exist: ${testPropsFile}"
52+
53+
def testPropsContent = testPropsFile.text
54+
assert testPropsContent.contains("app.test.java.version=17") :
55+
"test.properties missing java.version=17"
56+
assert testPropsContent.contains("app.test.version=1.5.0") :
57+
"test.properties missing version=1.5.0"
58+
assert testPropsContent.contains("app.test.name=custom-pkg-app-test") :
59+
"test.properties missing name=custom-pkg-app-test"
60+
println "PASS: Test properties validated"
61+
62+
// Check GitHub workflows exist
63+
println "Checking GitHub workflows..."
64+
assert new File(projectDir, ".github/workflows/ci.yml").exists() :
65+
"ci.yml does not exist"
66+
assert new File(projectDir, ".github/workflows/dependency-check.yml").exists() :
67+
"dependency-check.yml does not exist"
68+
assert new File(projectDir, ".github/workflows/gitflow-release.yml").exists() :
69+
"gitflow-release.yml does not exist"
70+
assert new File(projectDir, ".github/workflows/gitflow-hotfix.yml").exists() :
71+
"gitflow-hotfix.yml does not exist"
72+
println "PASS: GitHub workflows exist"
73+
74+
// Check .gitignore exists
75+
def gitignoreFile = new File(projectDir, ".gitignore")
76+
println "Checking .gitignore: ${gitignoreFile}"
77+
assert gitignoreFile.exists() : ".gitignore does not exist: ${gitignoreFile}"
78+
println "PASS: .gitignore exists"
79+
80+
println "VERIFICATION PASSED"
81+
return true
82+
} catch (AssertionError e) {
83+
println "ERROR: ASSERTION FAILED: ${e.message}"
84+
throw e
85+
} catch (Exception e) {
86+
println "ERROR: UNEXPECTED: ${e.message}"
87+
e.printStackTrace()
88+
throw e
89+
}

src/test/resources/projects/default-package/archetype.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ groupId=org.mycompany
22
artifactId=default-pkg-app
33
version=2.0.0
44
package=org.mycompany
5-
javaVersion=17
5+
javaVersion=17
6+
gitignore=.gitignore
7+
github=.github

0 commit comments

Comments
 (0)