Skip to content

Adds an option to the action to run in "fix" mode#84

Merged
wu-sheng merged 3 commits intoapache:mainfrom
ryanmrichard:allow_fix
Nov 2, 2021
Merged

Adds an option to the action to run in "fix" mode#84
wu-sheng merged 3 commits intoapache:mainfrom
ryanmrichard:allow_fix

Conversation

@ryanmrichard
Copy link
Contributor

This PR is a small change which adds an additional, optional, input to the action called mode. My goal with this change is to make it so CI pipelines can automatically apply the licenses to PRs which lack them (applying the changes would be handled by a different action like this one). I looked around and did not see any mention of such functionality; apologies if I missed it.

Some additional notes:

  • mode can take one of two values: check or fix. I set the default to check to preserve existing behavior.
  • I have also updated the README with the new input description.
  • I see from the diff that my IDE removed some trailing spaces; if you really want those back I can redo the changes with vim or something
  • I have tested that this works as intended with one of my own repositories; if you want proper unit tests I will need guidance/help on how to go about doing that.

@kezhenxu94 kezhenxu94 added this to the 0.3.0 milestone Nov 2, 2021
Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

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

@ryanmrichard thank you very much for the patch.

can you please also add some doc to mention that users need to use other GitHub Action to commit the fixed changes and the exit code of fix mode is always 0 so they cannot rely on the exit code to block the CI status?

@ryanmrichard
Copy link
Contributor Author

@kezhenxu94 I added a subsection detailing fix mode usage per your request.

Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

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

Thanks!!!

if any of the processed files are missing license headers. If `mode` is set to
`fix`, the action will instead apply the license header to any processed file
that is missing a license header. The fixed files can then be pushed back to the
pull request using another GitHub action. For example:
Copy link
Member

Choose a reason for hiding this comment

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

So, one action would commit and push, then make the CI failing, right? Just confirming. Then maintainers should rerun the CI task to make it passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wu-sheng The SkyWalking-Eyes action will edit the files in place. The subsequent "add-and-commit" action will use git to commit the changed files back to the PR. The action I linked to has a couple returns (see here); if you wanted to, you could add a step to the action which errs if the "add-and-commit" action makes a commit. Automating the re-run is not straightforward because GitHub doesn't like workflows triggering other workflows, so the maintainer will probably need to manually re-run the failed workflow.

In practice I usually don't worry about this becasue there's usually other changes needed to the PR; so when the PR author submits those changes (which will necessarily need to be synched with the automatic commit) they'll re-trigger CI.

@wu-sheng wu-sheng merged commit 3d3f488 into apache:main Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants