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

Refactor to remove portions of code that are not used by Chocolatey (CU-ENGTASKS-616) #20

Merged
merged 7 commits into from
Sep 15, 2022

Conversation

corbob
Copy link
Member

@corbob corbob commented May 13, 2022

Description Of Changes

Remove code that is not being used in Chocolatey components

Motivation and Context

A line of code removed is a line of code debugged. As well as the need to ensure that we're testing the code as much as possible. Chocolatey can't test the code for sections we don't use.

Testing

This is how I have tested it... This is based upon my development layout where all git repositories are cloned into C:/code_local The below scripts don't care about that part, but they do care that every repository is within a single folder.

Clone all of the repositories:

This PowerShell script will do a shallow clone of every repository required save for the Rhino.Licensing repository (you must be authenticated to GitLab through https):

@(
'https://github.com/chocolatey/choco'
'https://gitlab.com/chocolatey/collaborators/choco-licensed'
'https://gitlab.com/chocolatey/licensing-administration/licensing-services'
'https://gitlab.com/chocolatey/licensing-administration/chocolatey-pro-server-simple'
'https://gitlab.com/chocolatey/central-management/choco-licensed-management-ui'
'https://gitlab.com/chocolatey/collaborators/choco-licensed-services'
'https://github.com/chocolatey/ChocolateyGUI'
'https://gitlab.com/chocolatey/collaborators/chocolateygui-licensed'
) | % { git clone $_ --depth=1 }

Clean Repositories

If you already have all of the repositories cloned down, as long as you're in the master/develop branch you can use this script to clean them all:

BEWARE: This script will delete any files not tracked by the repository, as well as all modified files tracked by the repository.

$repos = @(
    'choco'
    'choco-licensed'
    'license-generator'
    'licensing-services'
    'chocolatey-pro-server-simple'
    'choco-licensed-management-ui'
    'choco-licensed-services'
    'ChocolateyGUI'
    'chocolateygui-licensed'
)
foreach ( $repo in $repos ) {
    push-location ./$repo
    git clean -xdf
    git restore .
    Pop-Location
}

Build all of the things

In an administrative PowerShell terminal, run the script ./BuildAll.ps1. This will take upwards of an hour, and will build all components that depend on Rhino.Licensing providing their Chocolatey packages in C:\CodeDrops

Testing all the things

Now comes the actual testing of the things. The testing that I have undertaken up to this point is to build all the things mentioned above. I have also copied all of the packages from C:\CodeDrops to a Test Kitchen environment where I have ran the CCM Test kitchen against it with all of the tests.

I have also run choco install chocolateygui chocolateygui-licensed on that environment and ensured that GUI installs as expected. I am unable to launch GUI with a large message box regarding --allow-unofficial, but I believe that's related to the custom Chocolatey.Lib.

Change Types Made

  • Bug fix (non-breaking change)
  • Feature / Enhancement (non-breaking change)
  • Breaking change (fix or feature that could cause existing functionality to change)
  • PowerShell code changes.

Related Issue

Fixes #18

Change Checklist

  • Requires a change to the documentation
  • Documentation has been updated
  • Tests to cover my changes, have been added
  • All new and existing tests passed.
  • PowerShell v2 compatibility checked.

@corbob corbob marked this pull request as draft May 21, 2022 00:20
@corbob corbob force-pushed the cleanup branch 2 times, most recently from cccc170 to 14b5fa6 Compare May 25, 2022 21:39
@corbob corbob changed the title Cleanup Refactor to remove portions of code that are not used by Chocolatey May 26, 2022
@corbob corbob requested a review from gep13 May 26, 2022 00:00
@corbob corbob self-assigned this May 26, 2022
@corbob corbob marked this pull request as ready for review May 26, 2022 00:01
@corbob corbob marked this pull request as draft May 26, 2022 00:21
@corbob
Copy link
Member Author

corbob commented May 26, 2022

I thought this was ready, but I did a spot check of the license files, and all of the expired ones were created with SHA1 (even though they claim to be not SHA1 😂 ). I'll add in the code used to create the files and add some notes to add them to the project in the next few days.

@corbob corbob marked this pull request as ready for review May 26, 2022 16:08
@corbob corbob changed the title Refactor to remove portions of code that are not used by Chocolatey Refactor to remove portions of code that are not used by Chocolatey (CU-ENGTASKS-616) May 27, 2022
@choco-bot
Copy link

@corbob
Copy link
Member Author

corbob commented May 27, 2022

@gep13 this should be ready for review now. The only issue I've encountered is that I can't launch GUI with my custom build of Chocolatey.lib.

Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

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

There is a comment in line that I think we need to address, either to remove it, or add the other numbers. Happy to discuss.

src/Rhino.Licensing/LicenseType.cs Show resolved Hide resolved
@pauby pauby requested a review from gep13 July 26, 2022 13:18
Remove the projects and libraries that are not used anymore.
Remove the license types that Chocolatey doesn't use.

This includes Floating and Subscription licenses.
Removes validating with a server (subscription).
Also removes the license reassertion that's caused issues in the past.
Update to use the new Chocolatey.Cake.Recipe version.
Suppress creation of SolutionVersion.cs
Update Readme with current information about running tests.
Update tests to split out generation and validation.
Created xml files to verify aspects of generation and validation.
Updated readme with instructions to generate test license files.
Add a script that will build every project that  depend on Rhino.Licensing.
We use the int for the database, this ensures we don't accidentally
change that mapping.
Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

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

LGTM!

@gep13 gep13 merged commit 75149c1 into chocolatey:master Sep 15, 2022
@gep13
Copy link
Member

gep13 commented Sep 15, 2022

@corbob thanks for getting all this pulled together! This will hopefully make the maintenance of this much easier going forward!

@corbob corbob deleted the cleanup branch September 15, 2022 19:41
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.

Remove portions of code that are not used by Chocolatey
5 participants