Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into jq/next-release
Browse files Browse the repository at this point in the history
  • Loading branch information
jquast committed Sep 23, 2023
2 parents 8b4bc91 + 552040b commit 9aeb0fe
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 3 deletions.
150 changes: 150 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: CI

on:
push:
branches: [master]
tags: ["*"]
pull_request:
branches: [master]
workflow_dispatch:

env:
# https://force-color.org/
FORCE_COLOR: "1"
# https://pip.pypa.io/en/stable/topics/configuration/#environment-variables
# https://pip.pypa.io/en/stable/cli/pip/#cmdoption-disable-pip-version-check
PIP_DISABLE_PIP_VERSION_CHECK: "1"
# https://pip.pypa.io/en/stable/cli/pip/#cmdoption-no-python-version-warning
PIP_NO_PYTHON_VERSION_WARNING: "1"

jobs:
tests:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy-2.7"
- "pypy-3.7"
- "pypy-3.8"
- "pypy-3.9"
- "pypy-3.10"
include:
- os: ubuntu-22.04
python-version: "pypy-3.6"
- os: ubuntu-20.04
python-version: "3.6"
- os: ubuntu-20.04
python-version: "3.5"
- os: ubuntu-20.04
container: python:2.7-buster
python-version: "2.7"

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

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip
if: '! matrix.container'

- name: Prepare tox
shell: bash
run: |
V=${{ matrix.python-version }}
if [[ "$V" = pypy-* ]]; then
V=$(echo $V | tr -d .-)
IS_PYPY=1
else
V=py$(echo $V | tr -d .)
IS_PYPY=0
fi
echo IS_PYPY=$IS_PYPY >>$GITHUB_ENV
echo TOX_PYTHON=$V >>$GITHUB_ENV
if [[ ${{ matrix.python-version }} = *2.7 ]]; then
python -m pip install tox
else
python -Im pip install tox
fi
- name: Run tests
shell: bash
run: |
if [[ ${{ matrix.python-version }} = *2.7 ]]; then
python -m tox -e ${{ env.TOX_PYTHON }}
else
python -Im tox -e ${{ env.TOX_PYTHON }}
fi
- name: Rename coverage data
shell: bash
run: |
if test -f .coverage; then
mv .coverage{,.${{ matrix.os }}.${{ env.TOX_PYTHON }}.$(date +"%Y-%m-%d_%H%M%S")}
fi
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage.*
if-no-files-found: ignore

coverage:
name: Combine & check coverage.
runs-on: ubuntu-latest
needs: tests

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version-file: .python-version-default
cache: pip

- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: coverage-data

- name: Combine coverage data
run: |
python -Im pip install coverage[toml]
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
python -Im coverage xml
# Report and write to summary.
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

- name: Fail if coverage is <100%.
run: |
# Report again and fail if under 100%.
python -Im coverage report --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov
if: ${{ failure() }}
1 change: 1 addition & 0 deletions .python-version-default
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
21 changes: 20 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = update, compile, autopep8, docformatter, isort, pylint, flake8, pydocstyle, docs, py{26, 27, 34, 35, 36, 37, 38, 39, 310, 311, 312}
envlist = update, compile, autopep8, docformatter, isort, pylint, flake8, pydocstyle, docs, py{27, 35, 36, 37, 38, 39, 310, 311, 312}, pypy{27, 36, 37, 38, 39, 310}
skip_missing_interpreters = true
# https://tox.wiki/en/4.11.3/faq.html#testing-end-of-life-python-versions
requires = virtualenv<20.22.0
Expand Down Expand Up @@ -53,6 +53,7 @@ ignore = E402,E501,F401,W503,W504
branch = True
source = wcwidth
parallel = True
relative_files = True

[coverage:report]
omit = tests/*
Expand Down Expand Up @@ -94,12 +95,30 @@ commands = {[base]pip_compile_command} requirements-tests37.in -o requirements-t
[testenv:py38]
deps = -r requirements-tests37.txt

[testenv:pypy38]
deps = -r requirements-tests37.txt

[testenv:py37]
deps = -r requirements-tests37.txt

[testenv:pypy37]
deps = -r requirements-tests37.txt

[testenv:py36]
deps = -r requirements-tests36.txt

[testenv:pypy36]
deps = -r requirements-tests36.txt

[testenv:py35]
deps = -r requirements-tests37.in

[testenv:py27]
deps = -r requirements-tests37.in

[testenv:pypy27]
deps = -r requirements-tests37.in

[testenv:update]
basepython = python3.12
usedevelop = true
Expand Down
6 changes: 4 additions & 2 deletions wcwidth/wcwidth.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ def _wcmatch_version(given_version):
_return_str = not _PY3 and isinstance(given_version, str)

if _return_str:
unicode_versions = [ucs.encode() for ucs in list_versions()]
# avoid list-comprehension to work around a coverage issue:
# https://github.com/nedbat/coveragepy/issues/753
unicode_versions = list(map(lambda ucs: ucs.encode(), list_versions()))
else:
unicode_versions = list_versions()
latest_version = unicode_versions[-1]
Expand Down Expand Up @@ -375,4 +377,4 @@ def _wcmatch_version(given_version):
# is, 4.1 is returned for given 4.9.9, where 4.1 and 5.0 are available.
if cmp_next_version > cmp_given:
return unicode_version
assert False, ("Code path unreachable", given_version, unicode_versions)
assert False, ("Code path unreachable", given_version, unicode_versions) # pragma: no cover

0 comments on commit 9aeb0fe

Please sign in to comment.