Skip to content

Support subfolders for distribution types for build and assemble locally and in Jenkins #1807

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

Merged
merged 84 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
991cd26
Support subfolders for distribution types for build and assemble
tianleh Mar 23, 2022
83eb362
fix syntax
tianleh Mar 23, 2022
bc44952
update upload logic
tianleh Mar 23, 2022
75c4fd7
add distribution
tianleh Mar 23, 2022
c973af0
fix uploadMinSnapshotsToS3
tianleh Mar 23, 2022
e7a8870
temp comment out most plugins to speed up test
tianleh Mar 23, 2022
1fbd817
modify
tianleh Mar 23, 2022
0455372
fix min paths
tianleh Mar 23, 2022
32b2411
test against tar for now
tianleh Mar 23, 2022
dda7241
address comments
tianleh Mar 23, 2022
52ab94f
add security
tianleh Mar 23, 2022
4914b33
add pa
tianleh Mar 23, 2022
231c46c
bring back all
tianleh Mar 23, 2022
8664744
fix file extension
tianleh Mar 24, 2022
75bb9dd
add dot
tianleh Mar 24, 2022
96ff4cd
use my repo for snapshot
tianleh Mar 24, 2022
ff8f987
set multiple stages
tianleh Mar 24, 2022
336f7a7
fix names
tianleh Mar 24, 2022
1861acb
fix var
tianleh Mar 24, 2022
539f2c7
double quotes
tianleh Mar 24, 2022
8d22cdb
fix min extensions
tianleh Mar 25, 2022
b9c329c
fix env name
tianleh Mar 25, 2022
d59fe6f
add rpm file
tianleh Mar 25, 2022
053c5ae
fix name
tianleh Mar 25, 2022
7eb9d94
undo osd
tianleh Mar 25, 2022
9b3d9ac
move distribution to beginning
tianleh Mar 25, 2022
235323b
fix url
tianleh Mar 25, 2022
18ca805
remove extra whitespaces
tianleh Mar 25, 2022
13a3d8a
add text
tianleh Mar 25, 2022
8f420e2
use 1.3 branch
tianleh Mar 26, 2022
267c368
fix syntax
tianleh Mar 26, 2022
b1aa311
fix syntax
tianleh Mar 26, 2022
4327a80
use quotes
tianleh Mar 26, 2022
d5471eb
remove rpm snapshot
tianleh Mar 26, 2022
ce96e28
add tests and use peter's own account
tianleh Mar 26, 2022
1fb9674
fix more python tests
tianleh Mar 26, 2022
e4b0800
fix style
tianleh Mar 26, 2022
2b57883
fix missing types
tianleh Mar 26, 2022
e4a59ab
remove wrong import
tianleh Mar 26, 2022
45a7164
fix ut of TestArchiveAssembleUpload
tianleh Mar 26, 2022
f80ae3d
fix ut of TestAssembleUpload
tianleh Mar 26, 2022
3ae0ef2
fix ut of TestBuildAssembleUpload
tianleh Mar 26, 2022
8d6a742
fix ut of TestBuildManifest
tianleh Mar 26, 2022
4eadbaf
fix ut of TestPromoteArtifacts
tianleh Mar 26, 2022
093f6cf
fix TestUploadMinSnapshotsToS3
tianleh Mar 26, 2022
897f054
fix ut of TestArchiveAssembleUpload
tianleh Mar 26, 2022
bedea56
fix ut of TestBuildAssembleUpload
tianleh Mar 26, 2022
08b02e1
combine updates after tests are done
tianleh Mar 28, 2022
d64c504
fix syntax
tianleh Mar 28, 2022
30ecc8b
reset to 1.3.0 main
tianleh Mar 30, 2022
3dfef38
create a new stage for upload index.json file
tianleh Mar 30, 2022
ee2c3cb
fix syntax
tianleh Mar 30, 2022
be015fc
add agent
tianleh Mar 30, 2022
737aaa4
pass path directly
tianleh Mar 30, 2022
1ea28a4
fix groovy tests
tianleh Mar 30, 2022
3178105
fix groovy tests
tianleh Mar 30, 2022
0c04eb9
add comment
tianleh Mar 30, 2022
2488252
update how tests use path
tianleh Mar 30, 2022
82de277
run osd rpm
tianleh Mar 31, 2022
da4873a
fix
tianleh Mar 31, 2022
4ece942
fix tests
tianleh Mar 31, 2022
7204bb6
fix style
tianleh Mar 31, 2022
8f0e118
fix archive logic
tianleh Mar 31, 2022
bb5cdb0
fix unzipped
tianleh Mar 31, 2022
14c34cd
use new image
tianleh Apr 1, 2022
9c4c926
fix syntax
tianleh Apr 1, 2022
b53b5b4
fix docker
tianleh Apr 2, 2022
ecdacc5
revert
tianleh Apr 2, 2022
5273a67
remove commented code
tianleh Apr 4, 2022
5c0cd78
add distribution to archived-builds.zip
tianleh Apr 4, 2022
6f6d3a7
fix copyArtifacts
tianleh Apr 4, 2022
7d97520
undo manifest
tianleh Apr 4, 2022
b5e4877
restore official repo name
tianleh Apr 4, 2022
97f0c3f
fix failed ut
tianleh Apr 4, 2022
e526302
fix ut
tianleh Apr 4, 2022
7b50b43
update docker build and notification
tianleh Apr 4, 2022
8cf4349
fix echo
tianleh Apr 4, 2022
1c5cbc7
hardcode to test again
tianleh Apr 4, 2022
a1fddbd
fix
tianleh Apr 4, 2022
50b8578
restore manifest
tianleh Apr 4, 2022
e6869c0
fix test
tianleh Apr 4, 2022
f3c4a68
fix ut
tianleh Apr 4, 2022
4bf24d3
add ut for UploadIndexFile
tianleh Apr 4, 2022
ec73193
fix tst
tianleh Apr 7, 2022
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ out.txt
/dist/
/test-results/

/rpm/
/tar/
/zip/

/.vscode/

.project
Expand Down
294 changes: 268 additions & 26 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile

Large diffs are not rendered by default.

281 changes: 249 additions & 32 deletions jenkins/opensearch/distribution-build.jenkinsfile

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/assemble_workflow/bundle_file_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class BundleFileLocation(BundleLocation):
def __init__(self, path: str, filename: str) -> None:
super().__init__(path, filename)
def __init__(self, path: str, filename: str, distribution: str) -> None:
super().__init__(path, filename, distribution)

def join(self, *args: str) -> str:
return os.path.join(self.path, *args)
7 changes: 4 additions & 3 deletions src/assemble_workflow/bundle_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@


class BundleLocation(abc.ABC):
def __init__(self, path: str, filename: str) -> None:
def __init__(self, path: str, filename: str, distribution: str) -> None:
self.path = path
self.filename = filename
self.distribution = distribution

@abc.abstractmethod
def join(self, *args: str) -> str:
pass

def get_build_location(self, target_name: str) -> str:
return self.join("builds", self.filename, target_name)
return self.join(self.distribution, "builds", self.filename, target_name)

def get_bundle_location(self, target_name: str) -> str:
return self.join("dist", self.filename, target_name)
return self.join(self.distribution, "dist", self.filename, target_name)
4 changes: 2 additions & 2 deletions src/assemble_workflow/bundle_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
class BundleLocations:

@classmethod
def from_path(cls, url_path: str, file_path: str, filename: str) -> BundleLocation:
return BundleUrlLocation(url_path, filename) if url_path else BundleFileLocation(file_path, filename)
def from_path(cls, url_path: str, file_path: str, filename: str, distribution: str) -> BundleLocation:
return BundleUrlLocation(url_path, filename, distribution) if url_path else BundleFileLocation(file_path, filename, distribution)
4 changes: 2 additions & 2 deletions src/assemble_workflow/bundle_url_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class BundleUrlLocation(BundleLocation):
def __init__(self, path: str, filename: str) -> None:
super().__init__(path, filename)
def __init__(self, path: str, filename: str, distribution: str) -> None:
super().__init__(path, filename, distribution)

def join(self, *args: str) -> str:
sub_path = "/".join(args)
Expand Down
2 changes: 1 addition & 1 deletion src/build_workflow/build_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self) -> None:
type=str,
choices=self.SUPPORTED_DISTRIBUTIONS,
help="Distribution to build.",
default=None,
default="tar",
dest="distribution"
)

Expand Down
2 changes: 1 addition & 1 deletion src/build_workflow/builder_from_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def build(self, build_recorder: BuildRecorder) -> None:
f"-q {self.target.qualifier}" if self.target.qualifier else None,
f"-p {self.target.platform}",
f"-a {self.target.architecture}",
f"-d {self.target.distribution}" if self.target.distribution and (self.component.name in DISTRIBUTION_SUPPORTED_COMPONENTS) else None,
f"-d {self.target.distribution}" if self.component.name in DISTRIBUTION_SUPPORTED_COMPONENTS else None,
f"-s {str(self.target.snapshot).lower()}",
f"-o {self.output_path}",
]
Expand Down
19 changes: 16 additions & 3 deletions src/jenkins/BuildManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ class BuildManifest implements Serializable {
String version
String platform
String architecture
String distribution

Build(Map data) {
this.id = data.id
this.name = data.name
this.version = data.version
this.platform = data.platform
this.architecture = data.architecture
this.distribution = data.distribution
}

String getFilename() {
Expand All @@ -31,7 +33,17 @@ class BuildManifest implements Serializable {
String getFilenameWithExtension(String platform = null, String architecture = null) {
String resolvedPlatform = platform ?: this.platform
String resolvedArchitecture = architecture ?: this.architecture
return "${this.getFilename()}-${this.version}-${resolvedPlatform}-${resolvedArchitecture}.${resolvedPlatform == 'windows' ? 'zip' : 'tar.gz'}"
return "${this.getFilename()}-${this.version}-${resolvedPlatform}-${resolvedArchitecture}.${getExtension()}"
}

String getExtension() {
if (this.distribution == 'zip') {
return 'zip'
} else if (this.distribution == 'rpm') {
return 'rpm'
} else {
return 'tar.gz'
}
}

String getPackageName() {
Expand All @@ -40,7 +52,7 @@ class BuildManifest implements Serializable {
this.version,
this.platform,
this.architecture,
].join('-') + '.tar.gz'
].join('-') + '.' + getExtension()
}
}

Expand Down Expand Up @@ -87,7 +99,8 @@ class BuildManifest implements Serializable {
this.build.version,
buildNumber,
this.build.platform,
this.build.architecture
this.build.architecture,
this.build.distribution
].join("/")
}

Expand Down
4 changes: 2 additions & 2 deletions src/paths/assemble_output_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@


class AssembleOutputDir(OutputDir):
def __init__(cls, filename: str, cwd: str = None, makedirs: bool = True) -> None:
super().__init__("dist", filename, cwd, makedirs)
def __init__(cls, filename: str, distribution: str, cwd: str = None, makedirs: bool = True) -> None:
super().__init__("dist", filename, distribution, cwd, makedirs)
4 changes: 2 additions & 2 deletions src/paths/build_output_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@


class BuildOutputDir(OutputDir):
def __init__(self, filename: str, cwd: Optional[str] = None, makedirs: bool = True) -> None:
super().__init__("builds", filename, cwd, makedirs)
def __init__(self, filename: str, distribution: str, cwd: Optional[str] = None, makedirs: bool = True) -> None:
super().__init__("builds", filename, distribution, cwd, makedirs)
3 changes: 2 additions & 1 deletion src/paths/output_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@


class OutputDir(ABC):
def __init__(cls, parent_dir: str, filename: str, cwd: Optional[str] = None, makedirs: bool = True) -> None:
def __init__(cls, parent_dir: str, filename: str, distribution: str, cwd: Optional[str] = None, makedirs: bool = True) -> None:
cls.dir = os.path.join(
cwd or os.getcwd(),
distribution,
parent_dir,
filename
)
Expand Down
4 changes: 2 additions & 2 deletions src/run_assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def main() -> int:
build = build_manifest.build
artifacts_dir = os.path.dirname(os.path.realpath(args.manifest.name))

output_dir = AssembleOutputDir(build.filename).dir
output_dir = AssembleOutputDir(build.filename, build.distribution).dir

logging.info(f"Bundling {build.name} ({build.architecture}) on {build.platform} into {output_dir} ...")

bundle_recorder = BundleRecorder(
build,
output_dir,
artifacts_dir,
BundleLocations.from_path(args.base_url, os.getcwd(), build.filename)
BundleLocations.from_path(args.base_url, os.getcwd(), build.filename, build.distribution)
)

with Bundles.create(build_manifest, artifacts_dir, bundle_recorder, args.keep) as bundle:
Expand Down
2 changes: 1 addition & 1 deletion src/run_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main():
manifest.to_file(args.ref_manifest)
exit(0)

output_dir = BuildOutputDir(manifest.build.filename).dir
output_dir = BuildOutputDir(manifest.build.filename, args.distribution).dir

with TemporaryDirectory(keep=args.keep, chdir=True) as work_dir:
logging.info(f"Building in {work_dir.name}")
Expand Down
1 change: 1 addition & 0 deletions tests/data/opensearch-build-1.1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build:
id: c3ff7a232d25403fa8cc14c97799c323
name: OpenSearch
version: 1.1.0
distribution: tar
components:
- artifacts:
dist:
Expand Down
Loading