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

Add option to use GitHub Actions for CI #449

Merged
merged 35 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8b1a5d7
add github actions workflow configuration to the template and add a q…
tepickering Feb 21, 2020
7b3f717
flesh out comments in workflow config file
tepickering Feb 21, 2020
95bce37
fix to only use var from tox-env since tox is smart enough to figure …
tepickering Feb 21, 2020
9d3c29d
don't install numpy in actions, let tox handle it. need to specify th…
tepickering Feb 21, 2020
070f212
remove oldestdeps from env list. update step name.
tepickering Feb 21, 2020
16d329b
add note to template_changes; tell cookiecutter to not render anythin…
tepickering Feb 21, 2020
7e8bf28
add coverage command to tox.ini to create xml output appropriate for …
tepickering Jun 8, 2020
6e44fb1
remove python36 from actions matrix; update actions to use v2 for che…
tepickering Jun 8, 2020
334e177
remove redundant step in actions doc_test
tepickering Jun 9, 2020
18fbe15
add build_docs back as a separate step in the actions workflow
tepickering Jun 9, 2020
5664926
merge upstream changes; fix conflict in TEMPLATE_CHANGES.md
tepickering Nov 16, 2020
90c6fd0
remove travis config
tepickering Nov 16, 2020
e104a31
edit TEMPLATE_CHANGES to more clearly reflect move to Actions for all…
tepickering Nov 16, 2020
64f7fdb
renameactions ci workflow to be more generalized
tepickering Nov 16, 2020
17c03c0
add scheduled weekly test to check documentation links
tepickering Nov 16, 2020
f8c8971
refactor core ci workflow to more closely match what is now used in a…
tepickering Nov 16, 2020
e7d866b
remove more references to travis; add .vscode to .gitignore
tepickering Nov 16, 2020
322683b
remove travis question from cookiecutter.json
tepickering Nov 17, 2020
6e8ca55
Revert "remove more references to travis; add .vscode to .gitignore"
tepickering Nov 17, 2020
c0e1aaf
remove reference to travis in QUESTIONS.rst
tepickering Nov 17, 2020
95675a9
remove reference to travis in rendered.yml
tepickering Nov 17, 2020
026de85
comment out section for uploading to codecov in the default workflow …
tepickering Nov 17, 2020
8497d53
expunge travis bit in post_gen_project.py
tepickering Nov 17, 2020
fa6fa76
update docs to reflect the move from travis to github actions as the …
tepickering Nov 17, 2020
677370c
bump supported python versions up a notch. include 3.9 for future-pro…
tepickering Nov 17, 2020
da62bd1
fix typos in ape17.rst
tepickering Nov 17, 2020
d92e94d
fix typos in nextsteps.rst
tepickering Nov 17, 2020
f5fde9e
fix post_gen_project.py to only remove the template workflows
tepickering Nov 17, 2020
40833b3
include fix from astropy/astropy#11054 to prevent double-runs when PR…
tepickering Nov 17, 2020
7caea3c
change coverage step to use contains instead of endsWith
tepickering Nov 17, 2020
2fc7f51
change master to main to reflect new github default; add commented bi…
tepickering Nov 17, 2020
3b016ec
more changes to reflect github's change to main as the default branch…
tepickering Nov 17, 2020
0e47911
add PR number for migration away from travis in template
tepickering Nov 17, 2020
88a818e
flesh out some comments in the ci_tests.yml workflow
tepickering Nov 17, 2020
fd8a4d3
fix some grammer and spelling
tepickering Nov 18, 2020
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
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.
tepickering marked this conversation as resolved.
Show resolved Hide resolved
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]
tepickering marked this conversation as resolved.
Show resolved Hide resolved

- 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.
tepickering marked this conversation as resolved.
Show resolved Hide resolved

- 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.6", "3.7", "3.8"],
tepickering marked this conversation as resolved.
Show resolved Hide resolved
"_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
tepickering marked this conversation as resolved.
Show resolved Hide resolved
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.
tepickering marked this conversation as resolved.
Show resolved Hide resolved

Step 14 - Update ReadTheDocs configuration
------------------------------------------
Expand Down
43 changes: 19 additions & 24 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
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
tepickering marked this conversation as resolved.
Show resolved Hide resolved
##############

Github now provides an integrated CI service called `Github Actions <https://docs.github.com/en/free-pro-team@latest/actions>`__.
tepickering marked this conversation as resolved.
Show resolved Hide resolved
The default workflows in ``.github/workflows`` show how to set up perform integration testing
tepickering marked this conversation as resolved.
Show resolved Hide resolved
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 ``master`` branch
tepickering marked this conversation as resolved.
Show resolved Hide resolved
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.
tepickering marked this conversation as resolved.
Show resolved Hide resolved
#. ``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
4 changes: 2 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ 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_dir('.github')
tepickering marked this conversation as resolved.
Show resolved Hide resolved

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
79 changes: 79 additions & 0 deletions {{ cookiecutter.package_name }}/.github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 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, pull_request]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also include @saimn 's patch in astropy/astropy#11054 so Actions won't also run on forks when PR is opened?

Copy link
Contributor Author

@tepickering tepickering Nov 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this keeps the template in-line with what astropy is doing so definitely worth including.


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 }}
Copy link
Member

@nstarman nstarman Nov 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone kindly gave me this piece of code to allow for skipping CI. Passing it forward.

if: "!(contains(github.event.head_commit.message, '[skip ci]') || contains(github.event.head_commit.message, '[ci skip]'))"

Copy link
Member

@pllim pllim Nov 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that still work? It didn't work for me when I tried at astropy/astropy#11044 . In fact, I dumped the whole github.event context out and couldn't find any head_commit in it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested it recently. It worked when I first added it and doesn't NOT work. But I see 11044 is more recent than my last test, so I guess it doesn't work anymore 👎 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i had this in the template originally, but took it out because it's no longer a reliable method of doing this. i would prefer to leave this alone until either it's supported natively (actions/runner#774) or there's an official action published that will do this properly. a 3rd party action exists, https://github.com/marketplace/actions/ci-skip-action, and seems to work well. astropy may wish to make their own version of this if native support is not forthcoming.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this worked for me in photutils when I tested it:
https://github.com/astropy/photutils/blob/master/.github/workflows/ci_tests.yml#L18

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, no work astropy/photutils#1121

strategy:
matrix:
include:
- name: Code style checks
tepickering marked this conversation as resolved.
Show resolved Hide resolved
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: "endsWith(matrix.toxenv, '-cov')"
tepickering marked this conversation as resolved.
Show resolved Hide resolved
# uses: codecov/codecov-action@v1
# with:
# file: ./coverage.xml
Loading