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

add function to automate badge update #360

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

benvanwerkhoven
Copy link
Contributor

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 the print_call_to_action function. If you want I'm happy to rename the module from print_call_to_action.py to just call_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 to tests/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

# make a new temporary directory and cd into it
cd $(mktemp -d --tmpdir howfairis.XXXXXX)

# get a copy of the repo
git clone https://github.com/fair-software/howfairis .

# checkout the work from this branch 
git checkout <this branch>

# create a virtual environment named venv3
python3 -m venv venv3

# activate the virtual environment
source venv3/bin/activate

# update pip and friends
python3 -m pip install --upgrade pip wheel setuptools

# install runtime dependencies
python3 -m pip install .

# and, if you need it, the development tools
python3 -m pip install .[dev]

Keep what you need from below, extend as necessary

# run the unit tests
pytest

# tests against a live infrastructure
pytest livetests/

# cli tests
bash clitests/script.sh

# run linter
prospector

# import style
isort --check-only howfairis

# any additional steps for checking
# I have added a test for the code to tests/test_cli.py which is ran by pytest, but if you'd like to do a 'live' test you can do a pull request to change the README.rst with the wrong badge on this repo:
git clone [email protected]:benvanwerkhoven/gh-actions-test-release.git
And the GitHub action workflow will correct the badge automatically after the pull request has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant