travis2gha
is a Python program that I wrote in order to automate the switch from Travis to GitHub Actions for my Python projects. When run in a clone of a GitHub repository containing a setuptools-based Python project, it performs the following tasks:
- Create a GitHub workflow
.github/workflows/test.yml
for runningtox -e py
against an array of Python versions (determined automatically from the Python project's classifiers) with coverage stats uploaded to Codecov, along with running zero or more custom tox testenvs (without coverage) against specific Python versions as specified on the command line. The workflow is configured to run on pushes, on pull requests, and once a day in the middle of the night. - Replace the Travis status badge in
README.rst
with a GitHub Actions status badge - Delete
.travis.yml
Now that I'm done with it, this repository merely serves as a example & template for others. It is not (and does not try to be) appropriate for general use. If you need the project to do something even slightly differently, you are encouraged to fork the code and make it your own.
travis2gha
requires Python 3.8 or higher. Just use pip for Python 3 (You have pip, right?) to install travis2gha
and its dependencies:
python3 -m pip install git+https://github.com/jwodder/travis2gha.git
travis2gha run [<options>]
Perform all of the steps listed above.
- --no-pytest-cov Indicates that passing
--cov-report=xml
to the tox run is not an option and that the XML coverage must be generated externally
- --testenv NAME_PYVER [Specify
NAME
andPYVER
as separate arguments] Configure the generated workflow to also run
tox -e NAME
against Python versionPYVER
. This option can be specified multiple times.
travis2gha workflow [<options>]
Output a GitHub Actions workflow for the current repository. This is the same workflow that would be generated by the run
command.
- --no-pytest-cov Indicates that passing
--cov-report=xml
to the tox run is not an option and that the XML coverage must be generated externally
- -o, --outfile FILE Save the workflow to the given file. By default, the
workflow is printed to standard output.
- --testenv NAME_PYVER [Specify
NAME
andPYVER
as separate arguments] Configure the generated workflow to also run
tox -e NAME
against Python versionPYVER
. This option can be specified multiple times.
travis2gha secrets [<options>]
Create specified workflow secrets in the GitHub repository. This was used in a previous version of this package until I realized that the workflow step it was enabling was redundant. However, the command remains for future reference.
This command relies on a secrets file for creating secrets in a repository. This file is an INI format file containing the following sections:
[auth]
Must contain a
token
option giving a GitHub OAuth token to use to set the repository's secrets over the GitHub API[secrets]
Each option in this section specifies a secret to create with the given name & value.
- -S, --secrets FILE INI file containing [auth]token and [secrets] sections.
Run
travis2gha secrets --help
to see the default location of this file for your system.