You're welcome to contribute, though I can't promise the experience will be as smooth as I'd like it to. I'll let you figure out most of it, though feel free to ask for help on anything you're stuck.
- Python3.11
- Use Poetry
- Launch tests with
pytest, config is in setup.cfg black,isort,flake8and once mypy will work with 3.10, we'll use it. There'spre-commit, so you can install hooks withpre-commit install.docker. Classic stuff.
Use:
$ source ./dev-envThis should take care of everything and will display instructions. Feel free to read the script yourself to see what it does.
You'll need a GitHub token to test the action locally. You have 3 choices:
- Before launching
dev-env, copydev-env-vars.disttodev-env-varsand set your token - After launching
dev-env, runtoken-from-ghto reuse yourghtoken for the action (you may need to define additional scopes withgh auth refresh --scope=...) - After launching
dev-env, runcreate-tokento interactively create a personnal access token (feel free to then save it todev-env-vars)
$ # Either push (compute & post badge), pull_request (compute comment) or workflow_run (post comment)
$ export GITHUB_EVENT_NAME=workflow_run
$ # Used only for push to test that the current branch is the repo default branch
$ export GITHUB_REF=
$ # Used only for workflow_run, set to a pull_request run id
$ export GITHUB_PR_RUN_ID=xxx
$ # Used only in pull_request to compute diff coverage
$ export GITHUB_BASE_REF=master
$ # Used everywhere
$ export GITHUB_REPOSITORY=py-cov-action/python-coverage-comment-action-v3-example
$ # Used everywhere. Generate at https://github.com/settings/tokens/new?scopes=repo&description=test%20python-coverage-comment-action
$ export GITHUB_TOKEN=Then either launch with poetry run coverage_comment or through docker.
To run the end-to-end tests, you'll need:
ghinstalled- 2 envvars
COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1andCOVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_2containing personnal access tokens for 2 distinct users. You may omit the 2nd user but some tests won't run. Use this link to generate tokens with the proper configuration. It's a good idea to not use your main GitHub user for this because the tests do some destructive actions (like deleting repos). - Make sure you don't have a repository named "python-coverage-comment-action-end-to-end"
(that would be a leftover of a previous test). If you do, delete it with
gh repo delete python-coverage-comment-action-end-to-end. - Please be aware that the tests will launch
gh auth setup-gitwhich might be surprising if you usehttpsremotes (sadly, settingGIT_CONFIG_GLOBALseems not to be enough to isolate tests.)