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 command to create a release group release #1409

Merged
merged 10 commits into from
Apr 25, 2024

Conversation

JeffreyHuynh1
Copy link
Contributor

@JeffreyHuynh1 JeffreyHuynh1 commented Apr 15, 2024

Overview

The CLI should offer a way to create release group release from the command line

Acceptance criteria

  • There is a way to create a release group release from the CLI.

Testing plan

example .fossa.yml:

releaseGroup:
  title: example-title
  release: example-release-title
  releaseGroupProjects:
    - projectLocator: custom+1/git@github.com/example
      projectRevision: 12345 
      projectBranch: main

Create a release group release:

  • fossa release-group create-release --title example-title --release example-release-title --project-locator custom+1/git@github.com/example --project-revision 12345 --project-branch main
  • fossa release-group create-release -c /path/to/.fossa.yml/

Risks

Metrics

References

Checklist

  • I added tests for this PR's change (or explained in the PR description why tests don't make sense).
  • If this PR introduced a user-visible change, I added documentation into docs/.
  • If this PR added docs, I added links as appropriate to the user manual's ToC in docs/README.ms and gave consideration to how discoverable or not my documentation is.
  • If this change is externally visible, I updated Changelog.md. If this PR did not mark a release, I added my changes into an # Unreleased section at the top.
  • If I made changes to .fossa.yml or fossa-deps.{json.yml}, I updated docs/references/files/*.schema.json AND I have updated example files used by fossa init command. You may also need to update these if you have added/removed new dependency type (e.g. pip) or analysis target type (e.g. poetry).
  • If I made changes to a subcommand's options, I updated docs/references/subcommands/<subcommand>.md.

@JeffreyHuynh1 JeffreyHuynh1 marked this pull request as ready for review April 15, 2024 16:44
@JeffreyHuynh1 JeffreyHuynh1 requested a review from a team as a code owner April 15, 2024 16:44
@JeffreyHuynh1 JeffreyHuynh1 requested a review from spatten April 15, 2024 16:45
Copy link
Contributor

@spatten spatten left a comment

Choose a reason for hiding this comment

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

The code is looking good.

I'd like to see a more thorough test plan, though. The test plan only tests with one project being added to the release group and does not test any of the failure cases. I.e. it would be good to test what happens if you try to create a release group while missing the --project-branch flag. It would also be good to specifically test with multiple projects being added.

We should also test the delete command that was added in this PR

## Example

```bash
fossa release-group create-release --title example-release-group --release example-release --project-locator custom+1/example --project-revision 1234 --project-branch main --project-locator custom+1/example2 --project-revision 5678 --project-branch main
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should explicitly document that you can have mulitple groups of project-locator, project-revision and project-branch args, and that the sets of args are grouped together based on their order.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was able to create a new release group with a branch that did not exist. Is this a bug or is it expected?

fossa release-group create-release --title "Test release group" --release example-release-title-3 --project-locator custom+24987/2779 --project-revision 1625011087 --project-branch master --project-locator custom+24987/4361-repro --project-revision 1657063285 --project-branch does-not-exist

This successfully created the release. You can see it here on the scottpatten.ca org: https://app.fossa.com/projects/group/1396/projects

When I click through on the "4361-repro" project, I see a "Branch does not exist" error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was able to create a new release group with a branch that did not exist. Is this a bug or is it expected?

This is expected behavior, I brought it up with Core and filed a ticket: https://fossa.atlassian.net/browse/CORE-3155

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should explicitly document that you can have multiple groups of project-locator, project-revision and project-branch args, and that the sets of args are grouped together based on their order.

Good point, I can see this being confusing to readers. There documentation on how those 3 flags are grouped together here and documentation on providing multiple instances of these flags here. It's all kind of spread apart so I can write a consolidate blurb as well as adding context on the grouping order.

Copy link
Contributor

@ryanlink ryanlink Apr 19, 2024

Choose a reason for hiding this comment

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

whoa.... all those locator-specific args are required? is there no way to match strings and just create a release called example-release within an existing example-release-group? (I realize I'm probably oversimplifying) cc @vishal-thenge

It seems like if fossa analyze --release-group-name 'MY_RG' --release-group-release 'MY_RELEASE' is possible, we should also decouple creating releases and release groups from project locators, revisions, and branches.

Copy link
Contributor

Choose a reason for hiding this comment

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

@JeffreyHuynh1 makes sense, although conceptually I can't understand why releases are inherently tied to projects instead of standalone containers. I guess that's why empty releases can't exist, which CORE-3189 was proposed to fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ryanlink 100% . When Core has implemented a way to support empty releases, we will be able to remove the requirement of having a project added to a release in the CLI.

Copy link
Member

Choose a reason for hiding this comment

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

@ryanlink by "match strings" do you mean infer the revision and project name that the user wants to add to the release group?
At the very least we have to offer a way for a user to create a release group with all of these flags, but maybe there's a way we can make it easier for users who have analyzed a project recently.
I'm not sure if this is possible or if we want to do this, but what about a flag like --most-recently-analyzed-revision that pulls the local data from the last time fossa analyze was run to populate --revision and --locator. Would that solve what you're looking for?

Copy link
Contributor

@ryanlink ryanlink Apr 19, 2024

Choose a reason for hiding this comment

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

@zlav

do you mean infer the revision and project name that the user wants to add to the release group?

no, I meant in the case where they just want to create a new release version within an RG for subsequent use in a fossa analyze command... but wasn't thinking about the fact that you can't currently create an empty release in the core app.

however, this does support Nexthink's request for fossa analyze --release-group-name XXX -release-group-release ZZZ to create the release ZZZ within the RG if it doesn't already exist.

@JeffreyHuynh1 copying here from Slack - can we add this reference to the docs?

You can run fossa analyze --json and get the data you need https://github.com/fossas/fossa-cli/blob/master/docs/references/subcommands/analyze.md#printing-project-metadata (project locator, etc.)

Copy link
Contributor

Choose a reason for hiding this comment

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

and this may be out of scope for this PR, but echoing @vishal-thenge 's request:

if we only have a projectLocator; but not: projectRevision & projectBranch to fossa release-group; can we add support to default them to the i) default branch & ii) latest revision ?

@JeffreyHuynh1
Copy link
Contributor Author

JeffreyHuynh1 commented Apr 17, 2024

I'd like to see a more thorough test plan, though. The test plan only tests with one project being added to the release group and does not test any of the failure cases. I.e. it would be good to test what happens if you try to create a release group while missing the --project-branch flag. It would also be good to specifically test with multiple projects being added.

We should also test the delete command that was added in this PR

The delete command was added in prior a PR. We have tests for it here: https://github.com/fossas/fossa-cli/blob/master/test/App/Fossa/ReleaseGroup/DeleteSpec.hs

@JeffreyHuynh1 JeffreyHuynh1 requested a review from spatten April 18, 2024 22:48
@spatten
Copy link
Contributor

spatten commented Apr 22, 2024

  * Or are you suggesting a more detailed manual testing plan?

I was suggesting a more detailed manual testing plan. Sorry for the confusion :)

Copy link
Contributor

@spatten spatten left a comment

Choose a reason for hiding this comment

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

This all looks good to me!

I added one optional comment on the docs, but nothing blocking

@JeffreyHuynh1 JeffreyHuynh1 merged commit 0479bae into master Apr 25, 2024
16 checks passed
@JeffreyHuynh1 JeffreyHuynh1 deleted the create-release-group-release branch April 25, 2024 19:46
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.

4 participants