Hi, we are at the brink of deploying our first project with Polylith but we hit a snag.
We've tagged our first commit with: v0
Our pipeline has tagged the latest commit with stable-develop
Now when we've merged to our main branch we ask polylith for the latest changes since release:
clojure -M:poly ws get:changes:changed-or-affected-projects since:release skip:dev color-mode:none
However, it is returning nothing.
If I cleanly checkout the project in a new directory I get the same behaviour. However interestingly if I remove the stable-develop tag (`git tag -d stable-develop`) and run the detect changes again then I get the changed projects.
So it seems there is some sort of conflict with the tags for us. But we cannot figure out what we are doing wrong. These are our tagging patterns:
:tag-patterns {:stable "stable-*"
:release "v[0-9]*"}Hi @furkan3ayraktar. Just wondering if you had the time yet to look at this
Hey, sorry, I didn't have time to look at it. I'm OOO until the end of April. @tengstrand, can you fork this repo and take a look at it? I don't think it is something specifically for me to look at. Feels like there is a straightforward bug
I can have a look.
Hi @jannick.joosten!
The problem is that it finds the tag "stable-develop" before it finds "v0".
The tag pattern "v[0-9]*" returns "v", because "develop" contains a v, and it matches "v" in any place in the string:
(re-find (re-pattern "v[0-9]*") "stable-develop")
To solve the problem, you have to change your regex to "^v[0-9]*", so that "v" has to come first in the string, e.g. this returns nil:
(re-find (re-pattern "^v[0-9]*") "stable-develop")
...but this returns "v0":
(re-find (re-pattern "^v[0-9]*") "v0")
It also means that "stable-*" matches any string that contains "stable-", but I guess that hasn't caused any problems. The strange thing is that no one has discovered or reported this problem for years!
When I change to this, it works:
:tag-patterns {:stable "^stable-*"
:release "^v[0-9]*"}
I will post a note about this in the main channel, and also create an issue.Thank you so much! I feel stupid now as I walked through the tagging code and did not notice at all that it matched anywhere in the string. Maybe everyone has a different version/tagging strategy. But thanks for checking it out!
Thanks for the reply. We have the following workflow: all changes made to our system will be pushed to a development branch. The CI pipeline deploys the changes to a staging environment and tags it as stable-develop. After we want to release it to our customers we make a pull request to our main branch and all commits end up on the main branch, so we get the following git history on the main branch:
046216f Merge pull request - release to prod
37a40b9 (tag: stable-develop) fix something
... then a bunch of commits adding a project and the features
1cfdbe2 (tag: v0) workspace created
So if we do a diff on the last commit we would get no changes since it's just a merge commit.
But if I would do a since:release I would expect it to find all changed project since the v0 tag, which are all project currently listed. However it short circuits and returns all the changed projects since the stable-develop tag. If I run info on the repo with the since:release flag prints the info since the stable tag.
So I'm rather confused what I'm missing here. Hopefully this made our situation more clear?I think you mentioned something about this before @furkan3ayraktar?
No, my problem was that Polylith thought the very first commit of a Git repository as stable. Another issue we faced at some point was that the GitHub action configuration we used was not fetching the whole git history but instead fetching the bare minimum, which caused the poly tool to fail to recognise tags. @jannick.joosten, could you create a minimal GitHub repository showing this problem so we can examine it and determine what is wrong?
Sure I'll create one later today
@furkan3ayraktar Here it is: https://github.com/Zatura24/PolylithTest. If you now checkout the main branch and run the info since:release command you will see that it does not show any changes to the projects, while the first release tag has been added to the workspace before any project was added.
If you run it with info since:previous-release or remove the stable-develop tag (and run info since:release) you will see that it lists the changed projects.
Additionally if I run it against since:previous-release it does work, but to our knowledge we should not use that because we tag the release with a new version after we've detected our changes
Maybe also good to note is that we use the cljs-support branch of polylith
Hmm looking at the documentation, and the polylith repository I seem conflicted. In the polylith repository I see the following:
• test
• deploy
• mark-as-stable
• add-version-tag
So tagging happens after retrieving the changed projects. They retrieve changed projects with previous-release
However this seems to conflict with the documentation in both the documents in the CI docs (https://cljdoc.org/d/polylith/clj-poly/0.2.21/doc/ci/continuous-integration), which states that if you want to retrieve the changed projects before you tag you should use release
In the polylith case they also only run tagging on master, so the stable-master and vx.y.z tags are always pointing to the same commit.
In our case since our development branch has its on own stable tag which we use to determine which projects should be deployed to a staging environment, stable-develop is always ahead of our vxxx tag.
You can experiment with the diff command to see which changes the poly tool recognises. For example, if I go to the polylith repo and give the sha for the latest commit, it returns no rows diff since:7d8f41c. But if I go back two commits with diff since:fe9de5d it returns:
doc/test-runners.adoc
examples/mix-example/deps.edn
examples/mix-example/projects/clj-project/deps.edn
examples/mix-example/projects/cljs-project/deps.edn
examples/mix-example/projects/cljs-project/resources/cljs_project/tests.edn
examples/mix-example/workspace.edn
examples/test-runners/deps.edn
examples/test-runners/projects/kaocha-override-global/deps.edn
examples/test-runners/projects/multiple-test-runners/deps.edn
And if I do ws get:changes:changed-or-affected-projects since:fe9de5d skip:dev color-mode:none it returns an empty vector, because no projects have been changed.