Skip to content

Move away from TravisCI #857

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Features
--------

* Testing setup with ``unittest`` and ``python setup.py test`` or ``pytest``
* Travis-CI_: Ready for Travis Continuous Integration testing
* Tox_ testing: Setup to easily test for Python 3.6, 3.7, 3.8
* GitHub Actions testing: Setup to easily test for Python 3.12 and 3.13
* Sphinx_ docs: Documentation ready for generation with, for example, `Read the Docs`_
* bump2version_: Pre-configured version bumping with a single command
* Auto-release to PyPI_ when you push a new tag to master (optional)
Expand Down Expand Up @@ -64,11 +63,8 @@ Generate a Python package project::
Then:

* Create a repo and put it there.
* Add the repo to your Travis-CI_ account.
* Install the dev requirements into a virtualenv. (``pip install -r requirements_dev.txt``)
* Register_ your project with PyPI.
* Run the Travis CLI command ``travis encrypt --add deploy.password`` to encrypt your PyPI password in Travis config
and activate automated deployment on PyPI when you push a new tag to master branch.
* Add the repo to your `Read the Docs`_ account + turn on the Read the Docs service hook.
* Release your package by pushing a new tag to master.
* Add a ``requirements.txt`` file that specifies the packages you will need for
Expand Down Expand Up @@ -133,7 +129,6 @@ I also accept pull requests on this, if they're small, atomic, and if they
make my own packaging experience better.


.. _Travis-CI: http://travis-ci.org/
.. _Tox: http://testrun.org/tox/
.. _Sphinx: http://sphinx-doc.org/
.. _Read the Docs: https://readthedocs.io/
Expand Down
1 change: 0 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"pypi_username": "{{ cookiecutter.github_username }}",
"version": "0.1.0",
"use_pytest": "n",
"use_pypi_deployment_with_travis": "y",
"add_pyup_badge": "n",
"command_line_interface": ["Typer", "Argparse", "No command-line interface"],
"create_author_file": "y",
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Advanced Features
.. toctree::
:maxdepth: 2

travis_pypi_setup
console_script_setup


Expand Down
5 changes: 1 addition & 4 deletions docs/prompts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ project_name
The name of your new Python package project. This is used in documentation, so spaces and any characters are fine here.

project_slug
The namespace of your Python package. This should be Python import-friendly. Typically, it is the slugified version of project_name. Note: your PyPi project and Travis links will use project_slug, so change those in the README afterwards.
The namespace of your Python package. This should be Python import-friendly. Typically, it is the slugified version of project_name. Note: your PyPI project links will use project_slug, so change those in the README afterwards.

project_short_description
A 1-sentence description of what your Python package does.
Expand All @@ -40,9 +40,6 @@ The following package configuration options set up different features for your p
use_pytest
Whether to use `pytest <https://docs.pytest.org/en/latest/>`_

use_pypi_deployment_with_travis
Whether to use PyPI deployment with `Travis <https://travis-ci.org/>`_.

add_pyup_badge
Whether to include a `pyup <https://github.com/pyupio/pyup>`_ badge

Expand Down
62 changes: 0 additions & 62 deletions docs/travis_pypi_setup.rst

This file was deleted.

27 changes: 6 additions & 21 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ If you don't know what to enter, press Enter to stick with the defaults.
Step 3: Create a GitHub Repo
----------------------------

Go to your GitHub account and create a new repo named ``mypackage``, where ``mypackage`` matches the ``[project_slug]`` from your answers to running cookiecutter. This is so that Travis CI and pyup.io can find it when we get to Step 5.
Go to your GitHub account and create a new repo named ``mypackage``, where ``mypackage`` matches the ``[project_slug]`` from your answers to running cookiecutter. This is so that pyup.io can find it when we get to Step 7.

You will find one folder named after the ``[project_slug]``. Move into this folder, and then setup git to use your GitHub repo and upload the code:

Expand Down Expand Up @@ -98,29 +98,14 @@ Your virtualenv should still be activated. If it isn't, activate it now. Install
pip install -r requirements_dev.txt


Step 5: Set Up Travis CI
------------------------

`Travis CI com`_ is a continuous integration tool used to prevent integration problems. Every commit to the master branch will trigger automated builds of the application.

Login using your Github credentials. It may take a few minutes for Travis CI to load up a list of all your GitHub repos. They will be listed with boxes to the left of the repo name, where the boxes have an ``X`` in them, meaning it is not connected to Travis CI.

Add the public repo to your Travis CI account by clicking the ``X`` to switch it "on" in the box next to the ``mypackage`` repo. Do not try to follow the other instructions, that will be taken care of next.

In your terminal, your virtualenv should still be activated. If it isn't, activate it now. Run the Travis CLI tool to do your Travis CI setup:

.. code-block:: bash

travis encrypt --add deploy.password

This will:
Step 5: Set Up GitHub Actions CI
--------------------------------

* Encrypt your PyPI password in your Travis config.
* Activate automated deployment on PyPI when you push a new tag to master branch.
`GitHub Actions`_ is a continuous integration tool used to prevent integration problems. Every pull request or commit to the master branch will trigger a workflow that runs automated tests.

See :ref:`travis-pypi-setup` for more information.
Files describing the workflow are stored in the ``.github/workflows`` directory. See the documentation link at the top of the workflow file for more information.

.. _`Travis CI com`: https://travis-ci.com/
.. _`GitHub Actions`: https://docs.github.com/en/actions


Step 6: Set Up Read the Docs
Expand Down
47 changes: 0 additions & 47 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,40 +115,6 @@ def test_bake_with_apostrophe_and_run_tests(cookies):
run_inside_dir('python setup.py test', str(result.project)) == 0


# def test_bake_and_run_travis_pypi_setup(cookies):
# # given:
# with bake_in_temp_dir(cookies) as result:
# project_path = str(result.project)
#
# # when:
# travis_setup_cmd = ('python travis_pypi_setup.py'
# ' --repo audreyr/cookiecutter-pypackage'
# ' --password invalidpass')
# run_inside_dir(travis_setup_cmd, project_path)
# # then:
# result_travis_config = yaml.load(
# result.project.join(".travis.yml").open()
# )
# min_size_of_encrypted_password = 50
# assert len(
# result_travis_config["deploy"]["password"]["secure"]
# ) > min_size_of_encrypted_password


def test_bake_without_travis_pypi_setup(cookies):
with bake_in_temp_dir(
cookies,
extra_context={'use_pypi_deployment_with_travis': 'n'}
) as result:
result_travis_config = yaml.load(
result.project.join(".travis.yml").open(),
Loader=yaml.FullLoader
)
assert "deploy" not in result_travis_config
assert "python" == result_travis_config["language"]
# found_toplevel_files = [f.basename for f in result.project.listdir()]


def test_bake_without_author_file(cookies):
with bake_in_temp_dir(
cookies,
Expand Down Expand Up @@ -244,19 +210,6 @@ def test_not_using_pytest(cookies):
# )
# assert result.project is not None
# project_path = str(result.project)
#
# # when:
# travis_setup_cmd = ('python travis_pypi_setup.py'
# ' --repo audreyr/cookiecutter-pypackage'
# ' --password invalidpass')
# run_inside_dir(travis_setup_cmd, project_path)
#
# # then:
# result_travis_config = yaml.load(
# open(os.path.join(project_path, ".travis.yml"))
# )
# assert "secure" in result_travis_config["deploy"]["password"],\
# "missing password config in .travis.yml"


def test_bake_with_no_console_script(cookies):
Expand Down
50 changes: 50 additions & 0 deletions {{cookiecutter.project_slug}}/.github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will install Python dependencies, run tests and lint.
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python

name: Test Python application

on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]

permissions:
contents: read

jobs:
build:
strategy:
matrix:
# Test all supported Python versions under Ubuntu
os: [ubuntu-latest]
python-version: ['3.12', '3.13']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
ruff check --select=E9,F63,F7,F82
# exit-zero treats all errors as warnings
ruff check --exit-zero --statistics
- name: Install project
run: |
pip install .
- name: Run tests
run: |
{% if cookiecutter.use_pytest == 'y' -%}
pytest
{% else %}
python -m unittest
{%- endif %}
30 changes: 0 additions & 30 deletions {{cookiecutter.project_slug}}/.travis.yml

This file was deleted.

9 changes: 5 additions & 4 deletions {{cookiecutter.project_slug}}/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check
https://travis-ci.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/pull_requests
and make sure that the tests pass for all supported Python versions.
3. The pull request should work for Python 3.12 and 3.13.
Tests run in GitHub Actions on every pull request to the main branch, make sure that the tests pass for all supported Python versions.

Tips
----
Expand All @@ -129,7 +128,9 @@ $ bump2version patch # possible: major / minor / patch
$ git push
$ git push --tags

Travis will then deploy to PyPI if tests pass.
You can set up a `GitHub Actions workflow`_ to automatically deploy your package to PyPI when you push a new tag.

.. _`GitHub Actions workflow`: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python#publishing-to-pypi

Code of Conduct
---------------
Expand Down
3 changes: 0 additions & 3 deletions {{cookiecutter.project_slug}}/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
.. image:: https://img.shields.io/pypi/v/{{ cookiecutter.project_slug }}.svg
:target: https://pypi.python.org/pypi/{{ cookiecutter.project_slug }}

.. image:: https://img.shields.io/travis/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}.svg
:target: https://travis-ci.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}

.. image:: https://readthedocs.org/projects/{{ cookiecutter.project_slug | replace("_", "-") }}/badge/?version=latest
:target: https://{{ cookiecutter.project_slug | replace("_", "-") }}.readthedocs.io/en/latest/?version=latest
:alt: Documentation Status
Expand Down