Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add method to get component names from test manifest #361

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ out.txt
.classpath
bin/*


logback.log
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jacocoTestReport {
}
}

String version = '6.0.0'
String version = '6.1.0'

task updateVersion {
doLast {
Expand Down
27 changes: 16 additions & 11 deletions src/jenkins/BuildManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package jenkins

class BuildManifest implements Serializable {

class Build implements Serializable {

String id
String name
String version
Expand Down Expand Up @@ -57,6 +58,7 @@
this.architecture,
].join('-') + '.' + getExtension()
}

}

class Components extends HashMap<String, Component> {
Expand All @@ -67,9 +69,11 @@
this[component.name] = component
}
}

}

class Component implements Serializable {

String name
String version
String ref
Expand Down Expand Up @@ -103,25 +107,25 @@
buildNumber,
this.build.platform,
this.build.architecture
].join("/")
].join('/')
}

public String getArtifactRoot(String jobName, String buildNumber) {
return [
this.getArtifactRootWithoutDistribution(jobName, buildNumber),
this.build.distribution
].join("/")
].join('/')
}

public String getIndexFileRoot(String jobName) {
return [
jobName,
this.build.version,
"index",
'index',
this.build.platform,
this.build.architecture,
this.build.distribution
].join("/")
].join('/')
}

public String getArtifactRootUrlWithoutDistribution(String publicArtifactUrl = 'https://ci.opensearch.org/ci/dbc', String jobName, String buildNumber) {
Expand All @@ -144,7 +148,7 @@
'builds',
this.build.getFilename(),
'manifest.yml'
].join("/")
].join('/')
}

public String getBundleManifestUrl(String publicArtifactUrl = 'https://ci.opensearch.org/ci/dbc', String jobName, String buildNumber) {
Expand All @@ -153,7 +157,7 @@
'dist',
this.build.getFilename(),
'manifest.yml'
].join("/")
].join('/')
}

public String getArtifactUrl(String publicArtifactUrl = 'https://ci.opensearch.org/ci/dbc', String jobName, String buildNumber) {
Expand All @@ -162,7 +166,7 @@
'dist',
this.build.getFilename(),
this.build.getFilenameWithExtension()
].join("/")
].join('/')
}

public String getArtifactArchitecture() {
Expand All @@ -182,7 +186,7 @@
}

public String getMinArtifact() {
components.get(build.name.replace(' ','-'))?.artifacts?.get("dist")?.first()
components.get(build.name.replace(' ', '-'))?.artifacts?.get('dist')?.first()
}

public String getCommitId (String name) {
Expand All @@ -191,11 +195,12 @@

public ArrayList getNames() {
def componentsName = []
this.components.each{key, value -> componentsName.add(key)}
this.components.each { key, value -> componentsName.add(key) }

Check warning on line 198 in src/jenkins/BuildManifest.groovy

View check run for this annotation

Codecov / codecov/patch

src/jenkins/BuildManifest.groovy#L198

Added line #L198 was not covered by tests
return componentsName
}

public String getRepo(String name) {
return this.components.get(name).repository
}

}
34 changes: 34 additions & 0 deletions src/jenkins/TestManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,64 @@
package jenkins

class TestManifest {

class Ci implements Serializable {
class Image implements Serializable {

String name
String args

Image(Map data) {
this.name = data.name
this.args = data.args
}

}

Image image

Ci(Map data) {
this.image = new TestManifest.Ci.Image(data.image)
}

}

class Components extends HashMap<String, Component> {

Components(ArrayList data) {
data.each { item ->
Component component = new Component(item)
this[component.name] = component
}
}

}

class Component implements Serializable {

String name

Component(Map data) {
this.name = data.name
}

}

String name

Ci ci
Components components

TestManifest(Map data) {
this.name = data.name
this.ci = data.ci ? new TestManifest.Ci(data.ci) : null
this.components = data.components ? new TestManifest.Components(data.components) : null
Copy link
Member

Choose a reason for hiding this comment

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

A bit confusion.
Isnt data.components is already the components from TestManifest?

Copy link
Member Author

Choose a reason for hiding this comment

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

No it was only present in buildManifest class not the Test Manifest class.

Copy link
Member

Choose a reason for hiding this comment

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

Ok got it.

}

public ArrayList getComponentNames() {
def componentsName = []
this.components.each { key, value -> componentsName.add(key) }
return componentsName

Check warning on line 70 in src/jenkins/TestManifest.groovy

View check run for this annotation

Codecov / codecov/patch

src/jenkins/TestManifest.groovy#L68-L70

Added lines #L68 - L70 were not covered by tests
}

}
Loading