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

Fix changelog action workflow #1878

Closed

Conversation

blackbird7112
Copy link
Contributor

@blackbird7112 blackbird7112 commented Jan 26, 2022

Modify the git flow in the changelog action workflow

Description
This PR aims to solve the detached head issue raised by github actions when the tag triggers the workflow. The action first deletes the tag in the runner. Then the tag is recreated to point to the new commit. The change is then force pushed to origin.

Motivation and context
Fix for issue #1871

How has this been tested?

  • Testing pipeline.
  • Other.
    Tested by pushing tags to my fork

Type of change

  • Bug fix.
  • New feature.
  • Breaking change.
  • None of the above.

Checklist

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
    • (optional) I have built the documentation on my fork following the instructions.
  • I have assigned and requested two reviewers for this pull request.

@tardis-bot
Copy link
Contributor

Before a pull request is accepted, it must meet the following criteria:

  • Is the necessary information provided?
  • Is this a duplicate PR?
    • If a new PR is clearly a duplicate, ask how this PR is different from the original PR?
    • If this PR is about to be merged, close the original PR with a link to this new PR that solved the issue.
  • Does it pass existing tests and are new tests provided if required?
    • The test coverage should not decrease, and for new features should be close to 100%.
  • Is the code tidy?
    • No unnecessary print lines or code comments.

@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #1878 (275a9e3) into master (df8089c) will increase coverage by 0.23%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1878      +/-   ##
==========================================
+ Coverage   62.24%   62.47%   +0.23%     
==========================================
  Files          67       68       +1     
  Lines        6830     7134     +304     
==========================================
+ Hits         4251     4457     +206     
- Misses       2579     2677      +98     
Impacted Files Coverage Δ
...dis/tardis/montecarlo/montecarlo_numba/r_packet.py 44.44% <0.00%> (-4.21%) ⬇️
tardis/tardis/io/parsers/arepo.py 69.04% <0.00%> (ø)
...montecarlo/montecarlo_numba/calculate_distances.py 25.00% <0.00%> (+1.31%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df8089c...275a9e3. Read the comment docs.

@andrewfullard andrewfullard self-requested a review January 26, 2022 22:02
git tag -d ${{ github.ref_name }}
git tag -a ${{ github.ref_name }} -m "$GIT_TAG_MESSAGE"
git checkout master
git push --tags --force
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is a force push needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tag that we intend to rewrite will exist in the remote. The lack of a force push will give the error already exists. So to overwrite the tag we need a force push

@epassaro
Copy link
Member

This issue is related to the @tardis-bot token permissions and the fact our master branch is write protected.

@blackbird7112
Copy link
Contributor Author

@epassaro I am not sure about the permissions that the tardis bot has. But I don't think that it is alone responsible. I have made a testing branch in my fork to test this workflow. There I gave the default GITHUB_TOKEN to the workflow. Even in that case the workflow gives the detached head issue when it is triggered automatically by the tag condition. I have also observed in the tardis-sn/tardis repository that the changelog workflow always gave this error except when it was manually trigger or scheduled.

Upon enquire into the issue, I figured that the issue occurs due to the nature of how the checkout action works. When we consider a tag based trigger, the checkout action will perform the git checkout <tag-name> command and it does not checkout the branch as usual. So when we try to add a commit, it does not get appended to the branch. Instead it enters the detached head state. This is a good article that explains the problem.

So to deal with this, I have used this approach to modify and force push the tag to the repository. If you think we need to append to a branch as usual, then we need to figure out a different way to automatically trigger the workflow.

@blackbird7112
Copy link
Contributor Author

blackbird7112 commented Jan 28, 2022

Also I have updates the PR to use better git tag commands. I had used an unnecessary complicated approach before to deal with the tags due to the lack of good documentation on updating tags.

@wkerzendorf
Copy link
Member

wkerzendorf commented Feb 23, 2022

@epassaro (our infrastructure coordinator) can you review it and bring it to merge or close?

@epassaro
Copy link
Member

Hi @rohithvarma3000, thanks for your PR.

We're going to change the way we push changes from CI/CD to the repository and soon this action would not be needed anymore.

@epassaro epassaro closed this Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants