feat: tag recipes with abra #99

Merged
decentral1se merged 5 commits from knoflook/abra:recipe-release into main 2021-09-29 12:39:36 +00:00
Owner

This will close coop-cloud/organising#135

what do we have so far:

  • tag the current commit with a user-specified tag
  • support --major, --minor and --patch as flags for generating the new tag
  • generate the new tag based on repo tag history and differences in compose.yml
  • bonus: think of a way to convert versions bound to something (think 6.0-alpine) to semver automatically
  • push the changes (only with a --push flag I guess?)
  • warn the user about a possible version conflict¹
  • add the +a.b.c part signifying the main app version

that's it. There is some code to get the last tag object from the repo but honestly the git library is difficult for me to grasp. Now to be able to compute a new version we need to:

  • checkout the repository to the last tag
  • create a new recipe object and parse compose.yml
  • get the versions of containers from the newly parsed compose.yml (previous version)
  • do the math

I hope I'll do this by the end of this week but no promises. The git library is sparsely documented, and uses weird stuff like iterators and own types to deal with simple problems like listing tags.

This will close coop-cloud/organising#135 what do we have so far: - [x] tag the current commit with a user-specified tag - [x] support `--major`, `--minor` and `--patch` as flags for generating the new tag - [ ] generate the new tag based on repo tag history and differences in compose.yml - [x] bonus: think of a way to convert versions bound to something (think 6.0-alpine) to semver automatically - [x] push the changes (only with a --push flag I guess?) - [ ] warn the user about a possible version conflict¹ - [x] add the +a.b.c part signifying the main app version that's it. There is some code to get the last tag object from the repo but honestly the git library is difficult for me to grasp. Now to be able to compute a new version we need to: - checkout the repository to the last tag - create a new recipe object and parse compose.yml - get the versions of containers from the newly parsed compose.yml (previous version) - do the math I hope I'll do this by the end of this week but no promises. The git library is sparsely documented, and uses weird stuff like iterators and own types to deal with simple problems like listing tags.
knoflook added 1 commit 2021-09-22 14:15:00 +00:00
continuous-integration/drone/pr Build is failing Details
48d28c8dd1
feat: tag recipes with abra
decentral1se requested changes 2021-09-23 11:51:41 +00:00
decentral1se left a comment
Owner

Great stuff. I tried running ./abra recipe release keycloak and it didn't work though?

Great stuff. I tried running `./abra recipe release keycloak` and it didn't work though?
@ -0,0 +35,4 @@
Action: func(c *cli.Context) error {
recipe := internal.ValidateRecipe(c)
directory := path.Join(config.APPS_DIR, recipe.Name)
Owner

This block is all done in internal.ValidateRecipe(c) already.

This block is all done in `internal.ValidateRecipe(c)` already.
knoflook marked this conversation as resolved
@ -0,0 +45,4 @@
tag := c.Args().Get(1)
if tag == "" {
for name, version := range images {
if !isSemver(version) {
Owner

The thing is, most versions are not strictly semver so we'd only be able to cover a tiny amount of the recipes we have. But we've already got tagcmp which can handle discovering what is a patch/minor/major upgrade and these formats are supported. So then we just need to check if it IsParsable?

The thing is, most versions are not strictly semver so we'd only be able to cover a tiny amount of the recipes we have. But we've already got `tagcmp` which can handle discovering what is a patch/minor/major upgrade and [these formats](https://git.coopcloud.tech/coop-cloud/tagcmp#types-of-versions-supported) are supported. So then we just need to check if it [`IsParsable`](https://git.coopcloud.tech/coop-cloud/tagcmp/src/branch/main/godoc.md#user-content-func-isparsable)?
knoflook marked this conversation as resolved
@ -0,0 +66,4 @@
if err != nil {
logrus.Fatal(err)
}
// TODO: This is some magic and I have no idea what's going on but it does the job. Re-write if this looks stupid to you. Copied from the docs /knoflook
Owner

(from recipe.EnsureVersion)

repo, err := git.PlainOpen(directory)
if err != nil {
    return err
}

tags, err := repo.Tags()
if err != nil {
    return nil
}
(from `recipe.EnsureVersion`) ```golang repo, err := git.PlainOpen(directory) if err != nil { return err } tags, err := repo.Tags() if err != nil { return nil } ```
knoflook marked this conversation as resolved
knoflook added 1 commit 2021-09-23 16:27:28 +00:00
Author
Owner

moved to tagcmp. I feel like this code is a big hack but it works 🤷

moved to tagcmp. I feel like this code is a big hack but it works 🤷
knoflook added 1 commit 2021-09-23 16:33:04 +00:00
continuous-integration/drone/pr Build is passing Details
cd179175f5
refactor: dont' create the same objects twice
knoflook added 1 commit 2021-09-23 16:52:31 +00:00
continuous-integration/drone/pr Build is passing Details
9faefd2592
feat: push the new tag with --push
knoflook added 1 commit 2021-09-24 08:48:18 +00:00
Author
Owner

I talked to @3wordchant and they said this is already useful so I guess we can merge these changes @decentral1se? Next step would be to add commits and then automatic tag computation but this will be a bit of a challenge and might take some more time. Also I'm not sure how to go about having multiple images changing versions in one commit. I guess it would make the most sense to just use the most important version change i.e.
nextcloud 21.0.3 -> 21.0.4
mariadb 10.5 -> 10.6
1.2.3+21.0.3 -> 1.3.0+21.0.4

I talked to @3wordchant and they said this is already useful so I guess we can merge these changes @decentral1se? Next step would be to add commits and then automatic tag computation but this will be a bit of a challenge and might take some more time. Also I'm not sure how to go about having multiple images changing versions in one commit. I guess it would make the most sense to just use the most important version change i.e. nextcloud 21.0.3 -> 21.0.4 mariadb 10.5 -> 10.6 1.2.3+21.0.3 -> 1.3.0+21.0.4
decentral1se changed title from WIP: feat: tag recipes with abra to feat: tag recipes with abra 2021-09-29 12:39:30 +00:00
decentral1se merged commit 2076c566bb into main 2021-09-29 12:39:36 +00:00
Sign in to join this conversation.
No description provided.