Skip to content

Commit

Permalink
CI: Enable UTF-8 on Windows and test main black too
Browse files Browse the repository at this point in the history
  • Loading branch information
ichard26 committed Dec 18, 2021
1 parent 2b64e1d commit 3e9e08f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
name: tests / ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
needs: [pre-commit]
env:
PYTHONIOENCODING: utf-8

strategy:
fail-fast: true
Expand All @@ -51,5 +53,10 @@ jobs:
python -m pip install pip wheel --upgrade
python -m pip install nox
- name: Run nox smoke-tests session
- name: Run nox smoke-tests session (latest PyPI black)
run: nox --force-color --verbose -s smoke-tests-${{ matrix.python }}

- name: Run nox smoke-tests session (main black)
run: >
nox --force-color --verbose -s smoke-tests-${{ matrix.python }} --reuse-existing-virtualenvs
-- --black-req git+https://github.com/psf/black.git
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ clear the cache with the `--clear-cache` flag (before the command!).
If you're using diff-shades in CI, `--dump-html` might come in handy saving a
copy of all emitted output. Unfortunately it behaves poorly with progress bars
so don't use this w/ `analyze`. Additionally, `--no-color` and `--force-color`
exist to override rich's terminal and color support detection (say for GHA
where colors are supported but rich doesn't know that).
exist to override rich's color support detection (say for GHA where colors are
supported but rich doesn't know that).

## Contributing

Expand Down
29 changes: 27 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys
from pathlib import Path
from typing import Optional

import nox

Expand All @@ -10,11 +12,32 @@
nox.options.error_on_external_run = True


def get_option(session: nox.Session, name: str) -> Optional[str]:
assert name.startswith("--")
if name in session.posargs:
index = session.posargs.index(name)
try:
value = session.posargs[index + 1]
except IndexError:
session.warn(f"[WARN] missing argument to {name}")
else:
del session.posargs[index : index + 1]
assert isinstance(value, str)
return value

return None


@nox.session(name="smoke-tests", python=SUPPORTED_PYTHONS)
def smoke_tests(session: nox.Session) -> None:
session.install(".")
session.run("diff-shades", "--version")
session.install("black")
black_req = get_option(session, "--black-req")
if black_req:
session.install(black_req)
else:
session.install("black")

tmp = Path(session.create_tmp())
target = str(tmp / "fake-devnull")
cache = str(tmp / "cache")
Expand All @@ -23,7 +46,9 @@ def smoke_tests(session: nox.Session) -> None:
log = str(tmp / "log.html")
short_file = "src/diff_shades/__init__.py"

base = ["diff-shades", "--force-color"]
base = ["diff-shades"]
if "--force-color" in sys.argv:
base.append("--force-color")
session.run(*base, "analyze", target, "-s", "diff-shades", "-w", cache)
session.run(*base, "analyze", target, "-s", "diff-shades", "-w", cache, "--", "-l", "100")
session.run(*base, "analyze", target, "-s", "diff-shades", "-s", "ptr", "-w", cache)
Expand Down

0 comments on commit 3e9e08f

Please sign in to comment.