Add check of component versions to CI #414
Conversation
19019f2 to
6348c55
Compare
Codecov Report
@@ Coverage Diff @@
## main #414 +/- ##
==========================================
+ Coverage 59.42% 62.23% +2.80%
==========================================
Files 38 45 +7
Lines 1119 1234 +115
==========================================
+ Hits 665 768 +103
- Misses 454 466 +12
Continue to review full report at Codecov.
|
269fe3f to
20d3a74
Compare
Signed-off-by: dblock <dblock@dblock.org>
Signed-off-by: dblock <dblock@dblock.org>
20d3a74 to
4d26e0f
Compare
Signed-off-by: dblock <dblock@dblock.org>
4d26e0f to
146c11d
Compare
Signed-off-by: dblock <dblock@dblock.org>
146c11d to
bf10dc5
Compare
Signed-off-by: dblock <dblock@dblock.org>
Signed-off-by: dblock <dblock@dblock.org>
80f1279 to
b8d4b04
Compare
| from abc import ABC, abstractmethod | ||
|
|
||
|
|
||
| class Check(ABC): |
There was a problem hiding this comment.
[Nit] This class seems like it is doing double duty, its got a description of a git repo, version and build target information as well as an interface for validation something about the check itself. Could resolve by making it a VersionCheck, or BuildCheck, or breaking them data fields into another object.
There was a problem hiding this comment.
Good point. I'll refactor this separately since it's the same pattern in build_workflow and needs to be addressed at the same time.
| self.dependencies = self.__get_dependencies() | ||
|
|
||
| def __get_dependencies(self): | ||
| cmd = " ".join( |
There was a problem hiding this comment.
[Optional] Seems like there is shared constructions between CheckGradleProperties. Might be useful to centralize concepts around gradle in one place such as having GradleCmd(self, target=':dependencies') vs GradleCmd(self, target='properties') where self is a Check or VersionCheck subclass
There was a problem hiding this comment.
I suppose if we do more gradle commands for sure.
|
|
||
| @abstractmethod | ||
| def check(self): | ||
| logging.info(f"Checking {self.component.name}, {self.__class__.__name__}.") |
There was a problem hiding this comment.
[Nit] Reshape, rename to __perform_check is abstract does the checking, add concrete check that does logging around the __perform_check call for consistency.
There was a problem hiding this comment.
Good suggestion, but I actually don't want this logging most of the time, this method should just be a pass.
| def check(self): | ||
| cmd = " ".join( | ||
| [ | ||
| "./gradlew publishToMavenLocal", |
There was a problem hiding this comment.
I understand right now only two components will use this check, but this feels like we are getting closer and closer to simply running a build with
./bundle-workflow/build.sh manifests/opensearch-1.1.0.yml.
Each component that uses this is essentially doing a full build of that component.
What if we just run the full build if there is a change to a manifest file?
Something like.
on:
pull_request:
paths:
- manifests/*.yml
There was a problem hiding this comment.
You have a point, however this is actually quite far from a full build, only some gradle runs to extract properties. Once we have maven we don't need to publish OpenSearch and common-utils to maven local, so this CI will be much faster.
If we start building everything we're going to start running out of space on workers, it will take 2 hours on GHA, etc.
There was a problem hiding this comment.
I added running CI on manifests only in PRs, that's a good idea.
| runs-on: ubuntu-latest | ||
| env: | ||
| PYTHON_VERSION: 3.7 | ||
| JDK_VERSION: 14 |
There was a problem hiding this comment.
If we are not backporting java 11 to 1.0 branch, can we start with 11 here and make a separate job for the 1.0 manifests?
There was a problem hiding this comment.
Everything is still on 14.
Signed-off-by: dblock <dblock@dblock.org>
Signed-off-by: dblock <dblock@dblock.org>
Signed-off-by: dblock <dblock@dblock.org>
saratvemulapalli
left a comment
There was a problem hiding this comment.
I took one pass at it.
Couple of questions, overall it looks good to me.
|
|
||
| pipenv run isort . | ||
| pipenv run black . | ||
| git status -s | grep -e "[MA?]\s.*.py" | cut -c4- | xargs pipenv run black |
There was a problem hiding this comment.
Trust me. It just picks all .py files that are added or modified, minus the deleted ones. It's a dev readme anyway, so you're supposed to parse regexp in your head ;)
| f"./gradlew {self.gradle_project or ''}:dependencies", | ||
| f"-Dopensearch.version={self.opensearch_version}", | ||
| f"-Dbuild.snapshot={str(self.snapshot).lower()}", | ||
| '| grep -e "---"', |
There was a problem hiding this comment.
Just trying to understand:
Looks like we are only checking opensearch and its version. Why not just look for compile time dependencies instead of all of them?
Also for next steps, we should verify plugin dependencies on other plugins and make sure their versions also match the manifest.
There was a problem hiding this comment.
Do you know how to get just those? I can open a separate PR for improving this.
There was a problem hiding this comment.
Yeah a simple way is to do something like ./gradlew :dependencies --configuration compile
Eg: From our fav plugin AD
~anomaly-detection$ ./gradlew :dependencies --configuration compile
> Configure project :
=======================================
OpenSearch Build Hamster says Hello!
Gradle Version : 6.6.1
OS Info : Linux 5.4.0-1037-aws (amd64)
JDK Version : 14 (JDK)
JAVA_HOME : /usr/lib/jvm/java-14-openjdk-amd64
Random Testing Seed : DFA8FDF8CA53A245
In FIPS 140 mode : false
=======================================
> Task :dependencies
------------------------------------------------------------
Root project - OpenSearch anomaly detector plugin
------------------------------------------------------------
compile - Dependencies for source set 'main' (deprecated, use 'implementation' instead). (n)
+--- org.opensearch:opensearch:1.0.0-rc1 (n)
+--- org.opensearch:common-utils:1.0.0.0-rc1 (n)
+--- com.google.guava:guava:29.0-jre (n)
+--- org.apache.commons:commons-math3:3.6.1 (n)
+--- com.google.code.gson:gson:2.8.6 (n)
+--- com.yahoo.datasketches:sketches-core:0.13.4 (n)
+--- com.yahoo.datasketches:memory:0.12.2 (n)
+--- commons-lang:commons-lang:2.6 (n)
+--- software.amazon.randomcutforest:randomcutforest-core:1.0 (n)
+--- software.amazon.randomcutforest:randomcutforest-serialization-json:1.0 (n)
+--- org.opensearch.client:opensearch-rest-client:1.0.0-rc1 (n)
+--- org.jacoco:org.jacoco.agent:0.8.5 (n)
\--- org.jacoco:org.jacoco.ant:0.8.5 (n)
Description
Introduce checks into CI that verify that the versions of dependent components match OpenSearch, where possible. With this change most components go through CI checks when they get changed in the manifest to ensure that they have the correct versions. For example, this change would have caught #410.
PropertiesFilewhich can now be instantiated empty, from aDictor a file.gradlew dependencies, parses the tree and loads as PropertiesFilegradlew properties, loads as PropertiesFileA handful of components (alerting, performance-analyzer-rc and security) don't have these checks enabled because they have maven or non-standard gradle commands, and don't respond to things like
./gradlew properties. Will follow-up via #437.Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.