Skip to content

Commit 3f67a3e

Browse files
authored
Merge pull request #1051 from python-cmd2/github_actions
Use GitHub Actions for CI
2 parents cd37707 + 631eaa9 commit 3f67a3e

File tree

16 files changed

+141
-146
lines changed

16 files changed

+141
-146
lines changed

.appveyor.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

CODEOWNERS renamed to .github/CODEOWNERS

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# -------------------------------------------------
2+
# CODEOWNERS - For automated review request for
3+
# high impact files.
4+
#
5+
# Important: The order in this file cascades.
6+
#
7+
# https://help.github.com/articles/about-codeowners
8+
# -------------------------------------------------
9+
110
# Lines starting with '#' are comments.
211
# Each line is a file pattern followed by one or more owners.
312
# Owners of code are automatically nominated to review PRs involving that code.
@@ -60,7 +69,8 @@ tests/test_transcript.py @kotfu
6069
tests_isolated/test_commandset/* @anselor
6170

6271
# Top-level project stuff
63-
CONTRIBUTING.md @tleonhardt @kotfu
6472
setup.py @tleonhardt @kotfu
6573
tasks.py @kotfu
6674

75+
# GitHub stuff
76+
.github/* @tleonhardt
File renamed without changes.

CONTRIBUTING.md renamed to .github/CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ how to do it.
458458

459459
7. Creating the PR causes our continuous integration (CI) systems to automatically run all of the
460460
unit tests on all supported OSes and all supported versions of Python. You should watch your PR
461-
to make sure that all unit tests pass on TravisCI (Linux), AppVeyor (Windows), and VSTS (macOS).
461+
to make sure that all unit tests pass on every version of Python for each of Linux, Windows, and
462+
macOS.
462463

463464
8. If any unit tests fail, you should look at the details and fix the failures. You can then push
464465
the fix to the same branch in your fork. The PR will automatically get updated and the CI system

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# For documentation on GitHub Actions Workflows, see:
2+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
3+
name: CI
4+
5+
on: [push, pull_request]
6+
7+
jobs:
8+
ci:
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, macos-latest, windows-latest]
12+
python-version: [3.6, 3.7, 3.8, 3.9]
13+
fail-fast: false
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@v2 # https://github.com/actions/checkout
17+
with:
18+
# Only a single commit is fetched by default, for the ref/SHA that triggered the workflow.
19+
# Set fetch-depth: 0 to fetch all history for all branches and tags.
20+
fetch-depth: 0 # Needed for setuptools_scm to work correctly
21+
- name: Set up Python
22+
uses: actions/setup-python@v2 # https://github.com/actions/setup-python
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install python prerequisites
26+
run: pip install -U --user pip setuptools setuptools-scm nox
27+
- name: Run tests and post coverage results
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: python -m nox --non-interactive --session tests-${{ matrix.python-version }} # Run nox for a single version of Python

.github/workflows/doc.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# For documentation on GitHub Actions Workflows, see:
2+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
3+
name: Doc
4+
5+
on: [push, pull_request]
6+
7+
jobs:
8+
doc:
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest]
12+
python-version: [3.9]
13+
fail-fast: false
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@v2 # https://github.com/actions/checkout
17+
with:
18+
# Only a single commit is fetched by default, for the ref/SHA that triggered the workflow.
19+
# Set fetch-depth: 0 to fetch all history for all branches and tags.
20+
fetch-depth: 0 # Needed for setuptools_scm to work correctly
21+
- name: Set up Python
22+
uses: actions/setup-python@v2 # https://github.com/actions/setup-python
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install python prerequisites
26+
run: pip install -U --user pip setuptools setuptools-scm nox
27+
- name: Sphinx documentation build
28+
run: python -m nox --non-interactive --session docs

.github/workflows/lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# For documentation on GitHub Actions Workflows, see:
2+
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
3+
name: Lint
4+
5+
on: [push, pull_request]
6+
7+
jobs:
8+
lint:
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest]
12+
python-version: [3.9]
13+
fail-fast: false
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@v2 # https://github.com/actions/checkout
17+
with:
18+
# Only a single commit is fetched by default, for the ref/SHA that triggered the workflow.
19+
# Set fetch-depth: 0 to fetch all history for all branches and tags.
20+
fetch-depth: 0 # Needed for setuptools_scm to work correctly
21+
- name: Set up Python
22+
uses: actions/setup-python@v2 # https://github.com/actions/setup-python
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install python prerequisites
26+
run: pip install -U --user pip setuptools setuptools-scm flake8
27+
- name: Lint
28+
run: python -m flake8 . --count --ignore=E252,W503 --max-complexity=26 --max-line-length=127 --show-source --statistics ;

.travis.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
include LICENSE README.md CHANGELOG.md CONTRIBUTING.md noxfile.py Pipfile
1+
include LICENSE README.md CHANGELOG.md noxfile.py Pipfile
22
recursive-include examples *
33
recursive-include tests *
44
recursive-include docs *
55
recursive-exclude docs/_build *
6-
exclude .appveyor.yml .gitignore .travis.yml azure-pipelines.yml CODEOWNERS tasks.py
6+
exclude .github .gitignore azure-pipelines.yml tasks.py

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
cmd2: a tool for building interactive command line apps
22
=======================================================
33
[![Latest Version](https://img.shields.io/pypi/v/cmd2.svg?style=flat-square&label=latest%20stable%20version)](https://pypi.python.org/pypi/cmd2/)
4-
[![Build status](https://img.shields.io/travis/python-cmd2/cmd2.svg?style=flat-square&label=unix%20build)](https://travis-ci.org/python-cmd2/cmd2)
5-
[![Appveyor build status](https://img.shields.io/appveyor/ci/FedericoCeratto/cmd2.svg?style=flat-square&label=windows%20build)](https://ci.appveyor.com/project/FedericoCeratto/cmd2)
4+
[![GitHub Actions](https://github.com/python-cmd2/cmd2/workflows/CI/badge.svg)](https://github.com/python-cmd2/cmd2/actions?query=workflow%3ACI)
65
[![Azure Build status](https://python-cmd2.visualstudio.com/cmd2/_apis/build/status/python-cmd2.cmd2?branch=master)](https://python-cmd2.visualstudio.com/cmd2/_build/latest?definitionId=1&branch=master)
76
[![codecov](https://codecov.io/gh/python-cmd2/cmd2/branch/master/graph/badge.svg)](https://codecov.io/gh/python-cmd2/cmd2)
87
[![Documentation Status](https://readthedocs.org/projects/cmd2/badge/?version=latest)](http://cmd2.readthedocs.io/en/latest/?badge=latest)

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414
# Run the pipeline with multiple Python versions
1515
strategy:
1616
matrix:
17-
Python35:
18-
python.version: '3.5'
19-
NOXSESSION: 'tests-3.5'
2017
Python36:
2118
python.version: '3.6'
2219
NOXSESSION: 'tests-3.6'
@@ -26,6 +23,9 @@ jobs:
2623
Python38:
2724
python.version: '3.8'
2825
NOXSESSION: 'tests-3.8'
26+
Python39:
27+
python.version: '3.9'
28+
NOXSESSION: 'tests-3.9'
2929
# Increase the maxParallel value to simultaneously run the job for all versions in the matrix (max 10 for free open-source)
3030
maxParallel: 4
3131

cmd2/cmd2.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4001,36 +4001,11 @@ def do_history(self, args: argparse.Namespace) -> Optional[bool]:
40014001
readline.clear_history()
40024002
return
40034003

4004-
# If an argument was supplied, then retrieve partial contents of the history
4005-
cowardly_refuse_to_run = False
4006-
if args.arg:
4007-
# If a character indicating a slice is present, retrieve
4008-
# a slice of the history
4009-
arg = args.arg
4010-
arg_is_int = False
4011-
try:
4012-
int(arg)
4013-
arg_is_int = True
4014-
except ValueError:
4015-
pass
4016-
4017-
if '..' in arg or ':' in arg:
4018-
# Get a slice of history
4019-
history = self.history.span(arg, args.all)
4020-
elif arg_is_int:
4021-
history = [self.history.get(arg)]
4022-
elif arg.startswith(r'/') and arg.endswith(r'/'):
4023-
history = self.history.regex_search(arg, args.all)
4024-
else:
4025-
history = self.history.str_search(arg, args.all)
4026-
else:
4027-
# If no arg given, then retrieve the entire history
4028-
cowardly_refuse_to_run = True
4029-
# Get a copy of the history so it doesn't get mutated while we are using it
4030-
history = self.history.span(':', args.all)
4004+
# If an argument was supplied, then retrieve partial contents of the history, otherwise retrieve it all
4005+
history = self._get_history(args)
40314006

40324007
if args.run:
4033-
if cowardly_refuse_to_run:
4008+
if not args.arg:
40344009
self.perror("Cowardly refusing to run all previously entered commands.")
40354010
self.perror("If this is what you want to do, specify '1:' as the range of history.")
40364011
else:
@@ -4070,6 +4045,32 @@ def do_history(self, args: argparse.Namespace) -> Optional[bool]:
40704045
for hi in history:
40714046
self.poutput(hi.pr(script=args.script, expanded=args.expanded, verbose=args.verbose))
40724047

4048+
def _get_history(self, args: argparse.Namespace) -> List[HistoryItem]:
4049+
"""If an argument was supplied, then retrieve partial contents of the history; otherwise retrieve entire history."""
4050+
if args.arg:
4051+
# If a character indicating a slice is present, retrieve a slice of the history
4052+
arg = args.arg
4053+
arg_is_int = False
4054+
try:
4055+
int(arg)
4056+
arg_is_int = True
4057+
except ValueError:
4058+
pass
4059+
4060+
if '..' in arg or ':' in arg:
4061+
# Get a slice of history
4062+
history = self.history.span(arg, args.all)
4063+
elif arg_is_int:
4064+
history = [self.history.get(arg)]
4065+
elif arg.startswith(r'/') and arg.endswith(r'/'):
4066+
history = self.history.regex_search(arg, args.all)
4067+
else:
4068+
history = self.history.str_search(arg, args.all)
4069+
else:
4070+
# Get a copy of the history so it doesn't get mutated while we are using it
4071+
history = self.history.span(':', args.all)
4072+
return history
4073+
40734074
def _initialize_history(self, hist_file):
40744075
"""Initialize history using history related attributes
40754076

noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import nox
22

33

4-
@nox.session(python=['3.7'])
4+
@nox.session(python=['3.9'])
55
def docs(session):
66
session.install('sphinx',
77
'sphinx-rtd-theme',
@@ -15,7 +15,7 @@ def docs(session):
1515
'-d', '{}/doctrees'.format(tmpdir), '.', '{}/html'.format(tmpdir))
1616

1717

18-
@nox.session(python=['3.5.2', '3.5.3', '3.5', '3.6', '3.7', '3.8', '3.9'])
18+
@nox.session(python=['3.6', '3.7', '3.8', '3.9'])
1919
@nox.parametrize('plugin', [None,
2020
'ext_test',
2121
'template',

plugins/template/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ tiered testing strategy to accomplish this objective.
210210
- [pytest](https://pytest.org) runs the unit tests
211211
- [nox](https://nox.thea.codes/en/stable/) runs the unit tests on multiple versions
212212
of python
213-
- [AppVeyor](https://www.appveyor.com/) and [TravisCI](https://travis-ci.com)
214-
run the tests on the various supported platforms
213+
- [GitHub Actions](https://github.com/features/actions) runs the tests on the various
214+
supported platforms
215215

216216
This plugin template is set up to use the same strategy.
217217

@@ -307,9 +307,7 @@ $ nox
307307

308308
### Run unit tests on multiple platforms
309309

310-
[AppVeyor](https://github.com/marketplace/appveyor) and
311-
[TravisCI](https://docs.travis-ci.com/user/getting-started/) offer free plans
312-
for open source projects.
310+
[GitHub Actions](https://github.com/features/actions) offers free plans for open source projects
313311

314312

315313
## Packaging and Distribution

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]

tests/test_completion.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,6 @@ def test_path_completion_doesnt_match_wildcards(cmd2_app, request):
491491
# Currently path completion doesn't accept wildcards, so will always return empty results
492492
assert cmd2_app.path_complete(text, line, begidx, endidx) == []
493493

494-
@pytest.mark.skipif(sys.platform == 'win32', reason="getpass.getuser() does not work on Windows in AppVeyor because "
495-
"no user name environment variables are set")
496494
def test_path_completion_complete_user(cmd2_app):
497495
import getpass
498496
user = getpass.getuser()

0 commit comments

Comments
 (0)