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

New strategy StrategyForceLatestVersions #271

Merged
merged 26 commits into from
Jun 3, 2024

Conversation

Michaelpalacce
Copy link
Collaborator

@Michaelpalacce Michaelpalacce commented May 16, 2024

Description

This strategy will force you to upload the same or newer version of a package, otherwise it will fail the build, allowing us for
better CI/CD pipelines, where we can ensure that the latest versions are always used on the server.

Checklist

  • I have added relevant error handling and logging messages to help troubleshooting
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation, relevant usage information (if applicable)
  • I have updated CHANGELOG.md with a short summary of the changes introduced
  • I have tested against live environment, if applicable
  • I have synced any structure and/or content vRA-NG improvements with vra-ng and ts-vra-ng archetypes (if applicable)
  • I have my changes rebased and squashed to the minimal number of relevant commits. Notice: don't squash all commits
  • I have added a descriptive commit message with a short title, including a Fixed #XXX - or Closed #XXX - prefix to auto-close the issue

Testing

Here are the outputs:

[INFO] STRATEGY| INFO | Apply Configuration strategies for import
[INFO] STRATEGY| PASS | Source.Version > Destination.Version
[INFO] PACKAGE | SKIP | com.vmware.pscoe.library.ts.logging (2.1.0) > (2.1.0)
[INFO] PACKAGE | PASS | com.vmware.pscoe.library.ecmascript (2.38.2-SNAPSHOT) > (2.38.2-SNAPSHOT)
[INFO] PACKAGE | FAIL | com.test.test (1.0.3-SNAPSHOT) > (1.0.5-SNAPSHOT)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  34.178 s
[INFO] Finished at: 2024-05-16T18:18:24+03:00
[INFO] STRATEGY| INFO | Apply Configuration strategies for import
[INFO] STRATEGY| PASS | Source.Version > Destination.Version
[INFO] PACKAGE | SKIP | com.vmware.pscoe.library.ts.logging (2.1.0) > (2.1.0)
[INFO] PACKAGE | PASS | com.vmware.pscoe.library.ecmascript (2.38.2-SNAPSHOT) > (2.38.2-SNAPSHOT)
[INFO] PACKAGE | PASS | com.test.test (1.0.5-SNAPSHOT) > (1.0.4-SNAPSHOT)
[INFO] Package | IMPORT | com.vmware.pscoe.library.ecmascript-2.38.2-SNAPSHOT.package
[INFO] Package | IMPORT | com.test.test-1.0.5-SNAPSHOT.package
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] STRATEGY| INFO | Apply Configuration strategies for import
[INFO] STRATEGY| PASS | Source.Version > Destination.Version
[INFO] PACKAGE | SKIP | com.vmware.pscoe.library.ts.logging (2.1.0) > (2.1.0)
[INFO] PACKAGE | PASS | com.vmware.pscoe.library.ecmascript (2.38.2-SNAPSHOT) > (2.38.2-SNAPSHOT)
[INFO] PACKAGE | PASS | com.test.test (1.0.4-SNAPSHOT) > (1.0.4-SNAPSHOT)
[INFO] Package | IMPORT | com.vmware.pscoe.library.ecmascript-2.38.2-SNAPSHOT.package
[INFO] Package | IMPORT | com.test.test-1.0.4-SNAPSHOT.package
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Release Notes

This strategy will force you to upload the same or newer version of a package, otherwise it will fail the build, allowing us for
better CI/CD pipelines, where we can ensure that the latest versions are always used on the server.

The new strategy can be triggered by passing -Dvro.forceImportLatestVersions=true. It is by default set to true.

Example usage:

mvn clean package vrealize:push -DincludeDependencies=true -Dvro.forceImportLatestVersions=true -DskipTests -PDevLab

@Michaelpalacce Michaelpalacce requested a review from a team as a code owner May 16, 2024 15:38
@vmware vmware deleted a comment from vmwclabot May 16, 2024
gu74tu added 9 commits May 16, 2024 18:41
This property acts similar to the default strategy, but will throw if
we try to import a version that is not the latest one.

Signed-off-by: Stefan Genov <stefan.genov@ing.com>
Signed-off-by: Stefan Genov <stefan.genov@ing.com>
Signed-off-by: Stefan Genov <stefan.genov@ing.com>
Signed-off-by: Stefan Genov <stefan.genov@ing.com>
Will be needed for the new strategy

Signed-off-by: Stefan Genov <stefan.genov@ing.com>
Will now force you to upload the same or newer version
of an artifact, or the build will fail

Signed-off-by: Stefan Genov <stefan.genov@ing.com>
Signed-off-by: Stefan Genov <stefan.genov@ing.com>
Signed-off-by: Stefan Genov <stefan.genov@ing.com>
This should be refactored to be a switch statement probably or better
yet have a map of strategies and allow the user to set the one they want
to use. But I fear I will break backwards compatibility if I do that.

Signed-off-by: Stefan Genov <stefan.genov@ing.com>
@vmware vmware deleted a comment from vmwclabot May 16, 2024
CHANGELOG.md Outdated
@@ -1,3 +1,7 @@
### Enhancements

* [vro] Added new strategy StrategyForceLatestVersions that will force you to upload a newer or same version of artifacts, otherwise the build will fail. New property has been introduced `-Dvro.forceImportLatestVersions={{BOOLEAN}}` that is set by default to true
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the release.md it says the strategy is by default to false: "It is by default set to false." I think it looks as if false is the actual value but could you double check and update the changelog?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh... good catch 😆 should be by default to false

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, that would be great as it is also backwards compatible

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that was the main philosophy 😮‍💨 even tho I think some improvements to the way strategies work are needed if we are to add more

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmmm if you have specific idea for that maybe we can try to implement and release together with Anton's typescript update as major version

The StrategyForceLatestVersions  will now no longer upload the same
version of the artifact if it's not a -SNAPSHOT

Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
It was incorrectly stating that the default forceImportLatestVersions is
set to true, it is false for backwards compatability

Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
That check makes no sense

Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Alexander Kantchev <akantchev@vmware.com>
@joroaf joroaf self-requested a review May 23, 2024 12:52
CHANGELOG.md Outdated Show resolved Hide resolved
Signed-off-by: Alexander Kantchev <akantchev@vmware.com>
Signed-off-by: Alexander Kantchev <akantchev@vmware.com>
…stVersions, updated unit tests, added support for the package import flag in the installer

Signed-off-by: Alexander Kantchev <akantchev@vmware.com>
Signed-off-by: Alexander Kantchev <akantchev@vmware.com>
Signed-off-by: Alexander Kantchev <akantchev@vmware.com>
Signed-off-by: Alexander Kantchev <akantchev@vmware.com>
Signed-off-by: Alexander Kantchev <akantchev@vmware.com>
@pe1pip
Copy link
Contributor

pe1pip commented May 30, 2024

would it be possible to just exclude the com.vmware.pscoe.library.ecmascript from this policy? We have a few environments with newer versions of this lib that we are currently using, for example due to the use of newer BT versions for some packages that we decided against for other packages.

Copy link
Collaborator

@joroaf joroaf left a comment

Choose a reason for hiding this comment

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

As we agreed, we can disable this strategy's default behavior. We are going to introduce new version 3 where this strategy will be enabled by default.

@akantchev akantchev merged commit 0b4944c into main Jun 3, 2024
13 checks passed
@akantchev akantchev deleted the feature/force-latest-strategy branch June 3, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants