Hi everyone, We have deployed a CICD pipeline usi...
# general
s
Hi everyone, We have deployed a CICD pipeline using Pants. When the pipeline stops because of an error, we'd want the next run of the pipeline, that was triggered from a commit that contains a fix, to compare the code to the last time the pipeline passed successfully. The way Lerna addresses this in JS is by tagging git commits and compering the current commit to the latest tagged commit. Is there a similar functionality in Pants? Right now it seems that we need to address this ourselves and one would expect from Pants to do that. Thanks!
n
Every CI/CD setup is different, so I think it'd be hard for Pants to address it in a way to suit everyone. We use GitLab CI/CD at my company, and in our MR pipeline we simply do
--changed-since $CI_MERGE_REQUEST_DIFF_BASE_SHA
to run Pants on all files changed from the branch off point. I know Pants itself uses some git commands in the git hooks to do something similar.
❤️ 1
c
+1. We’re using Jenkins where I work, and there’s a env var provided by Jenkins with the git SHA of the last successful run.
👍 1
s
Thanks
h
Yeah I think
--changed-since=SHA_OF_PREVIOUS_COMMIT --changed-dependees=transitive
should get you there?
The
transitive
bit is to be sure you act on anything that depends on changed files, and not just on the changed files themselves
s
Actually we started with "sha of prev commit" but it has problem with the following edge case: 1. There's a new commit of apps A and B that fails because of app A. 2. A new commit is pushed to fix app A 3. Now the pipeline passes but doesn't detect that app B is changed and doesn't deploy it.
h
Right, so I should have said not "previous commit" but "commit of relevant known state"
👍 1
s
In that case we are on the same page. So my original question refers to the way Lerna handles caching of "sha of commit of relevant known state", and that is by using git tags.
n
Maybe
--changed-since=$(git describe --tags --abbrev=0)
? Should run on everything that's changed since the most recent git tag.
👌 1
💯 1
c
Or at least gives a good idea how to use tags for this in a generic manner. Great idea 😄
b
Clever!