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

[ci] only checkout with tags for non-tag runs #2017

Closed
wants to merge 5 commits into from

Conversation

sneakers-the-rat
Copy link
Collaborator

Fix: #2007

@pkalita-lbl basically did all the work for this -

/usr/bin/git -c protocol.version=2 fetch --prune --progress --no-recurse-submodules --depth=100 origin +4977f426cf4f3971cd66ea0dbae8fc0d039c7799:refs/tags/v1.7.6

  Error: fatal: Cannot fetch both 4977f426cf4f3971cd66ea0dbae8fc0d039c7799 and refs/tags/v1.7.6 to refs/tags/v1.7.6

compared to

/usr/bin/git -c protocol.version=2 fetch --prune --progress --no-recurse-submodules --depth=100 origin +4977f426cf4f3971cd66ea0dbae8fc0d039c7799:refs/remotes/origin/main

I've never actually used refspec syntax like that before, but the docs are here:

so basically the second one works because it will fetch that commit and create a ref under the usual refs/remotes/origin/main and since the --no-tags flag isn't given, it will also grab the remote ref for the tag into /refs/tags/v1.7.6 - two refs to two refs. the second one fails because it is fetching the commit and the tag into the same ref /refs/tags/v1.7.6. That's because a tag push is a separate event from a commit push (the linked examples are from the commit vs tag push for a given commit) and thus has the tag ref as the current {{github.ref}}.

since the purpose for the change in the first place was to make sure we have tags, and the tag-triggered actions by definition fetch the tag, introducing a switch that only fetches tags when the action is triggered by a commit. doing it this way vs. adding an additional run command bc of the extremely mild overhead of adding an extra step.

opening this PR not as a draft while still working on it so that CI runs bc it's a CI-based PR, sry for the notifs.

theoretically this should apply to all CI actions but docker is the only action that runs on a new tag. unsure why that is, just fixing it.

@sneakers-the-rat sneakers-the-rat added the devops poetry, setuptools, actions, etc. related changes label Mar 23, 2024
@sneakers-the-rat
Copy link
Collaborator Author

sneakers-the-rat commented Mar 23, 2024

OK so i don't want to commit a tag that looks like a version without asking first because that might trigger some unwanted deploy, but i do need to push a tag in order to trigger the bug.

so i made a temporary tag test-tag-remove-me that demonstrates this PR solves the checkout problem: https://github.com/linkml/linkml/actions/runs/8399144254/job/23004877707?pr=2017

it introduces another problem, presumably because the tag name no longer is a semver, and that metadata extraction step looks like it needs the tag to be. that should not happen in the normal conditions that this action would be run in, but again i don't want to test that by myself rn.

So I am reverting the changes here that were needed to trigger the tag build outside of main and saying this PR is ready for review - whether y'all want to test it by pushing a semver tag or building the docker image without deploying it, up to y'all.

Copy link

codecov bot commented Mar 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.69%. Comparing base (a2e7c63) to head (7ef8531).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2017      +/-   ##
==========================================
- Coverage   80.70%   80.69%   -0.02%     
==========================================
  Files         104      104              
  Lines       11620    11622       +2     
  Branches     2909     2910       +1     
==========================================
  Hits         9378     9378              
- Misses       1700     1701       +1     
- Partials      542      543       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sneakers-the-rat
Copy link
Collaborator Author

Alright it looks like my conditional gh action test

fetch-tags: ${{ github.event_name == 'push' && ! contains(github.ref, 'refs/tags/') }}

which should be false if it's a tag push but true otherwise doesn't work. so we're back to the old behavior of fetch-tags being false for the docker build, which means that the python package inside of it won't have a meaningful linkml version, but it will if we only deploy the image on the tagged builds.

that's about as much time as i have for solving a docker problem! up to y'all whether we want to leave it like that or just take that line out. won't be offended if you close this and just PR removing the line, idrc about the docker stuff!

@pkalita-lbl
Copy link
Contributor

Did you consider this?

uses: actions/checkout@v4
with:
  fetch-depth: 0

According to the docs:

0 indicates all history for all branches and tags.

That's what we use on other projects I work on, and it seems to work fine. I was actually surprised to see we weren't already using it here. I believe that would make the dynamic versioning correct for both tag-based and non-tag-based builds. The downside is perhaps a slightly slower checkout? I'm not sure you'd even really notice in practice.

@sneakers-the-rat
Copy link
Collaborator Author

Hell ya the only reason I didn't was bc it wasnt already like that and I didnt want to be the one to blast the full clone if we were trying to sip resources for some reason. Feel free to edit/close this PR and do that :)

@pkalita-lbl
Copy link
Contributor

I had trouble updating this branch (probably my fault) so I just created a PR on a new branch: #2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devops poetry, setuptools, actions, etc. related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker build failing for release tags
2 participants