add function to automate badge update #360
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
List of related issues or pull requests
Refs: #ISSUE_NUMBER
Describe the changes made in this pull request
I've made a very small addition to howfairis to make it possible to automate updating the fair-software.eu badge inside a project's README. The goal is to use howfairis inside a GitHub action that checks the compliance and directly updates the badge instead of failing the workflow.
To this end, the command line option "-a" or "--auto" has been added. As well as one function
automate_call_to_action
that has been adapted from theprint_call_to_action
function. If you want I'm happy to rename the module fromprint_call_to_action.py
to justcall_to_action.py
or something similar, since the module does more than just printing now.I have added a test for
automate_call_to_action
totests/test_cli.py
.I have also tested the automation of using "howfairis --auto" inside a GitHub action workflow. The test repository is here:
https://github.com/benvanwerkhoven/gh-actions-test-release
The workflow file that automatically updates the badge is here:
https://github.com/benvanwerkhoven/gh-actions-test-release/blob/main/.github/workflows/update-fair-software-badge.yml
You can see the "actions user" has updated the README automatically:
https://github.com/benvanwerkhoven/gh-actions-test-release/commits/main
To test this I also had to modify the howfairis-github-action. I can make a pull request for those additions later. I think it would be nice to support a user-specified option in that action to allow the user to enable this automation.
It would work even slightly better if howfairis could be run in a local git repository. Because even if your local files are different howfairis only checks what's on github. In reality, only the check "has_open_repository" really needs the GitHub URL and even that could be extracted from local files using 'git remote -v'. This point is not really related to the pull request, I'll create a separate issue to discuss this idea.
Instructions to review the pull request
Keep what you need from below, extend as necessary