Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #449 from tepickering/add_github_actions
Browse files Browse the repository at this point in the history
Add option to use GitHub Actions for CI
  • Loading branch information
pllim committed Nov 18, 2020
2 parents c76dcc5 + fd8a4d3 commit 589d874
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 223 deletions.
2 changes: 1 addition & 1 deletion QUESTIONS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ a description of each of the prompts.
9. ``use_compiled_extensions``: Whether you plan to use compiled extensions in your package
10. ``edit_on_github_extension``: Set to ``True`` to enable the edit on GitHub sphinx extension.
11. ``github_project``: This is the GitHub identifier for the edit on GitHub extension and the changelog link extension.
12. ``use_travis_ci``: If ``'y'`` the template will include an example ``.travis.yml`` file for the Travis CI service.
12. ``use_gh_actions``: If ``'y'`` the template will include an example ``.github/workflows/tox-tests.yml`` file for the GitHub Actions CI service.
13. ``use_read_the_docs``: If ``'y'`` the ``read_the_docs.yml`` and ``.rtd-environment.yml`` files will be included for using conda on Read the Docs.
14. ``sphinx_theme``: The value of the ``html_theme`` variable in the sphinx configuration file.
15. ``required_dependencies``: Comma-separated list of required dependencies
Expand Down
4 changes: 3 additions & 1 deletion TEMPLATE_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ be copied over manually if desired.
- Moved as much as possible of the setup.py configuration to setup.cfg, and now require
setuptools>=30.3. [#375]

- Removed Appveyor CI option. Use ``os: windows`` in Travis CI. [#420]
- Removed Appveyor CI option. Use ``os: windows-latest`` in GitHub Actions. [#420]

- Refactored the template to follow the recommendations in APE 17:
https://github.com/astropy/astropy-APEs/blob/master/APE17.rst [#438]

- Switch to using GitHub Actions for CI; remove Travis config. [#449]

- Added cron job for RST link checking [#482]

2.1 (unreleased)
Expand Down
7 changes: 5 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
"include_example_code": "y",
"edit_on_github_extension": "False",
"github_project": "astropy/astropy",
"use_travis_ci": "y",
"use_gh_actions": "y",
"use_read_the_docs": "y",
"sphinx_theme": "astropy-bootstrap",
"_parent_project": "astropy",
"required_dependencies": "astropy",
"optional_dependencies": "",
"minimum_python_version": ["3.6", "3.7", "3.8"]
"minimum_python_version": ["3.7", "3.8", "3.9"],
"_copy_without_render": [
".github"
]
}
9 changes: 4 additions & 5 deletions docs/ape17.rst
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,10 @@ recommended approach is to use the tox file to set up the different
configurations you want to use, and to then keep the CI configuration as simple
as possible.

If you use Travis CI, a good place to start is the ``.travis.yml`` file
generated in :ref:`Step 0 <step-rerender>`, and you can then see if any previous customizations you had
made need to be copied over. This file shows how one can configure Travis to use
tox, optionally using conda via ci-helpers to set up Python on MacOS X and
Windows.
GitHub now has an integrated CI service, GitHub Actions. If you wish to use Actions, a good place to start
is the ``.github/workflows/ci_tests.yml`` file generated in :ref:`Step 0 <step-rerender>`. You can then
see if any previous customizations you had made need to be copied over. This file shows how one can configure
Actions to use tox to test different environments with different versions of Python on different platforms.

Step 14 - Update ReadTheDocs configuration
------------------------------------------
Expand Down
45 changes: 20 additions & 25 deletions docs/nextsteps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,32 @@ Setting Up Continuous Integration

`Continuous Integration
<https://github.com/astropy/astropy/wiki/Continuous-Integration>`__ (CI)
services, like Travis CI, continuously test your package
for each commit. Every pull requests against your main repository will be
automatically tested, and failing tests will be flagged by these services.

Travis CI
#########

You should register your package on https://travis-ci.org and modify the
``.travis.yml`` file to your needs. The default ``.travis.yml`` file contains a
large number of builds, against various versions of Python, Astropy, and
numpy, and you should choose the ones relevant to your project. Full documentation
of the ``.travis.yml`` file can be found on the
`Travis CI <https://docs.travis-ci.com/user/for-beginners/>`__ website.

There are many `example build configuations
<https://github.com/astropy/astropy/wiki/travis-ci-test-status>`__ for
``.travis.yml``. Generally you should aim to always have your ``master`` branch
work with the latest stable and latest development version of astropy (i.e. the
services continuously test your package
for each commit. Every pull request against your main repository will be
automatically tested and failing tests will be flagged by these services.

GitHub Actions
##############

GitHub now provides an integrated CI service called `GitHub Actions <https://docs.github.com/en/free-pro-team@latest/actions>`__.
The default workflows in ``.github/workflows`` show how to set up integration testing
upon every push or pull request, ``ci_tests.yml``, and how to run scheduled tests via cron, ``ci_cron_weekly.yml``.
The default ``ci_tests.yml`` file contains a large number of builds against various versions of Python, astropy, and
numpy, and you should choose the ones relevant to your project. Generally, you should aim to always have your
``main`` branch work with the latest stable and latest development version of astropy (i.e., the
astropy git master branch) and the same versions of python and numpy supported
by astropy. The template ``.travis.yml`` covers those versions; in some
by astropy. The template ``ci_tests.yml`` covers those versions; in some
circumstances you may need to limit the versions your package covers.

Coveralls
#########
Codecov
#######

Coveralls is a web interface to monitoring what lines of code in your project
Codecov is a web interface to monitoring what lines of code in your project
are executed by your test suite.

If you register your package with `coveralls.io <https://coveralls.io/>`_, you
will need to uncomment the coveralls line in the ``.travis.yml`` file to enable
upload of your coverage statistics to coveralls.
If you register your package with `codecov.io <https://codecov.io/>`_, you
will need to uncomment the codecov section in the ``ci_tests.yml`` file under
``.github/workflows`` to enable upload of your coverage statistics to codecov.

Read the Docs
#############
Expand Down
2 changes: 1 addition & 1 deletion docs/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ a description of each of the prompts:
#. ``use_compiled_extensions``: Whether you plan to use compiled extensions in your package
#. ``edit_on_github_extension``: Set to ``True`` to enable the edit on GitHub sphinx extension.
#. ``github_project``: This is the GitHub identifier for the edit on GitHub extension and the changelog link extension.
#. ``use_travis_ci``: If ``'y'`` the template will include an example ``.travis.yml`` file for the Travis CI service.
#. ``use_gh_actions``: If ``'y'`` the template will include an example ``.github/workflows/tox-tests.yml`` file for the GitHub Actions CI service.
#. ``use_read_the_docs``: If ``'y'`` the ``read_the_docs.yml`` and ``.rtd-environment.yml`` files will be included for using conda on Read the Docs.
#. ``sphinx_theme``: The value of the ``html_theme`` variable in the sphinx configuration file.
#. ``required_dependencies``: Comma-separated list of required dependencies
Expand Down
2 changes: 1 addition & 1 deletion docs/updating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ settings configured to your package and then pull the changes into your package.

#. **Edit the files** until the changes shown by `` git diff`` are the ones you want to have in your package.

#. **Merge the changes** Either by a Pull Request or by merging the ``update_template`` branch into your master branch.
#. **Merge the changes** Either by a Pull Request or by merging the ``update_template`` branch into your ``main`` branch.


Using git Update
Expand Down
5 changes: 3 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def process_license(license_name):

process_license('{{ cookiecutter.license }}')

if '{{ cookiecutter.use_travis_ci }}' != 'y':
remove_file('.travis.yml')
if '{{ cookiecutter.use_gh_actions }}' != 'y':
remove_file('.github/workflows/ci_tests.yml')
remove_file('.github/workflows/ci_cron_weekly.yml')

if '{{ cookiecutter.use_read_the_docs }}' != 'y':
remove_file('.rtd-environment.yml')
Expand Down
2 changes: 1 addition & 1 deletion rendered.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ default_context:
use_compiled_extensions: "y"
edit_on_github_extension: "False"
github_project: "astropy/astropy"
use_travis_ci: "y"
use_gh_actions: "y"
use_read_the_docs: "y"
sphinx_theme: "astropy-bootstrap"
minimum_python_version: "3.6"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# GitHub Actions workflow that runs on a cron schedule.

name: Cron Scheduled CI Tests

on:
schedule:
# run at 6am UTC on Mondays
- cron: '0 6 * * 1'

jobs:
# Testing links in documents is a good example of something to run on a schedule
# to catch links that stop working for some reason.
doc_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python to build docs with sphinx
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install base dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Check links in docs using tox
run: |
tox -e linkcheck
86 changes: 86 additions & 0 deletions {{ cookiecutter.package_name }}/.github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# GitHub Actions workflow for testing and continuous integration.
#
# This file performs testing using tox and tox.ini to define and configure the test environments.

name: CI Tests

on:
push:
branches:
- main # GitHub now defaults to 'main' as the name of the primary branch. Change this as needed.
# tags: # run CI if specific tags are pushed
pull_request:
# branches: # only build on PRs against 'main' if you need to further limit when CI is run.
# - main

jobs:
# Github Actions supports ubuntu, windows, and macos virtual environments:
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
ci_tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Code style checks
os: ubuntu-latest
python: 3.x
toxenv: codestyle

- name: Python 3.7 with minimal dependencies
os: ubuntu-latest
python: 3.7
toxenv: py37-test

- name: Python 3.8 with all optional dependencies and coverage checking
os: ubuntu-latest
python: 3.8
toxenv: py38-test-alldeps-cov

- name: OS X - Python 3.8 with all optional dependencies
os: macos-latest
python: 3.8
toxenv: py38-test-alldeps

- name: Windows - Python 3.8 with all optional dependencies
os: windows-latest
python: 3.8
toxenv: py38-test-alldeps

# - name: Python 3.7 with oldest supported version of all dependencies
# os: ubuntu-16.04
# python: 3.7
# toxenv: py37-test-oldestdeps

# - name: Python 3.8 with latest dev versions of key dependencies
# os: ubuntu-latest
# python: 3.8
# toxenv: py38-test-devdeps

# - name: Test building of Sphinx docs
# os: ubuntu-latest
# python: 3.x
# toxenv: build_docs

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up python ${{ matrix.python }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install base dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox codecov
- name: Test with tox
run: |
tox -e ${{ matrix.toxenv }}
# This is an example of how to upload coverage to codecov
# - name: Upload coverage to codecov
# if: "contains(matrix.toxenv, '-cov')"
# uses: codecov/codecov-action@v1
# with:
# file: ./coverage.xml
Loading

0 comments on commit 589d874

Please sign in to comment.