Skip to content

Commit

Permalink
Add review remarks part II.
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Atkinson <opensource@LukasAtkinson.de>
  • Loading branch information
Spacetown and latk committed Dec 15, 2021
1 parent 527f185 commit fd987c3
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 36 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/deploy.yml
Expand Up @@ -35,6 +35,15 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('noxfile.py', 'doc/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install GCC
run: |
sudo apt update
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/test.yml
Expand Up @@ -128,18 +128,21 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('noxfile.py', 'doc/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python3 -m pip install nox codecov
- name: Lint files
run: |
nox --non-interactive --session lint
- name: Check format of files
if: ${{ ( matrix.python-version != 'pypy3' ) }}
# Currently fail of this job is OK.
continue-on-error: true
run: |
nox --non-interactive --session black
- name: Test with pytest
run: |
nox --non-interactive --session "tests_compiler(${{ matrix.gcc }})" -- --archive_differences
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Expand Up @@ -244,7 +244,7 @@ The QA process (``python3 -m nox``) consists of multiple parts:

The tests are in the ``gcovr/tests`` directory.
You can run the tests with ``python3 -m nox --session tests``
for the default GCC version (used from environment ``CC``iv availabele, else gcc-5.
for the default GCC version (specified via ``CC`` environment variable, defaults to gcc-5).
You can also select the gcc version if you run the tests with e.g.
``python3 -m nox --session tests_compiler(gcc-8)``.

Expand Down
4 changes: 2 additions & 2 deletions admin/Dockerfile.qa
Expand Up @@ -11,7 +11,7 @@ RUN \

WORKDIR /gcovr

ENV CC=$CC CXX=$CXX GCOVR_ISOLATED_TEST=zkQEVaBpXF1i
ENV CC=$CC CXX=$CXX GCOVR_ISOLATED_TEST=zkQEVaBpXF1i NOX_ENV_DIR=/gcovr/.nox-containerized.$CC.uid_$USERID

RUN \
python3 -m pip install --no-cache-dir nox
Expand All @@ -29,4 +29,4 @@ ENV LC_ALL=C.UTF-8 LANG=C.UTF-8

CMD ( echo docker | sudo -S -p "Running chmod with sudo..." chown -R docker:docker /gcovr/gcovr ) && \
echo "\ndone\nStarting test..." && \
python3 -m nox --envdir /tmp/envs --non-interactive
python3 -m nox --envdir $NOX_ENV_DIR --non-interactive
8 changes: 7 additions & 1 deletion doc/README.txt
Expand Up @@ -3,14 +3,20 @@ sphinx.

The necessary python packages have to be installed, e.g. with pip:

pip install nox
pip install -r requirements.txt

The command

make html

creates the documentation in the folder build/html.

If you're using nox you can alos call:

nox -s doc

This will install the reuirements in a virtual environment and run the make process.

When updating for a new gcovr version,
the screenshots will have to be regenerated.
If you have wkhtmltopdf installed, run
Expand Down
52 changes: 26 additions & 26 deletions noxfile.py
Expand Up @@ -17,7 +17,7 @@
nox.options.sessions = ["qa"]


def set_environment(session: nox.session, cc: str, check: bool = True) -> None:
def set_environment(session: nox.Session, cc: str, check: bool = True) -> None:
if check and (shutil.which(cc) is None):
session.env["CC_REFERENCE"] = cc
cc = "gcc"
Expand All @@ -38,7 +38,7 @@ def set_environment(session: nox.session, cc: str, check: bool = True) -> None:


@nox.session(python=False)
def qa(session: nox.session) -> None:
def qa(session: nox.Session) -> None:
"""Run the quality tests."""
session_id = "lint"
session.log(f"Notify session {session_id}")
Expand All @@ -52,7 +52,7 @@ def qa(session: nox.session) -> None:


@nox.session
def lint(session: nox.session) -> None:
def lint(session: nox.Session) -> None:
"""Run the lint (flake8 and black)."""
session.install("flake8")
# Black installs under Pypy but doesn't necessarily run (cf psf/black#2559).
Expand All @@ -66,31 +66,31 @@ def lint(session: nox.session) -> None:

if platform.python_implementation() == "CPython":
if session.posargs:
session.run("python", "-m", "black", *session.posargs)
else:
session.run(
"python", "-m", "black", "--diff", "--check", *BLACK_CONFORM_FILES
)
session.run("python", "-m", "black", "--diff", *DEFAULT_TEST_DIRECTORIES)
session.run("python", "-m", "black", "--diff", *args)
else:
session.log(
f"Skip black because of platform {platform.python_implementation()}."
)


@nox.session
def black(session: nox.session) -> None:
def black(session: nox.Session) -> None:
"""Run black, a code formatter and format checker."""
session.install("black")
if session.posargs:
args = session.posargs
session.run("python", "-m", "black", *session.posargs)
else:
raise RuntimeError("Please add the files to format as argument.")
session.run("python", "-m", "black", *args)
session.run(
"python", "-m", "black", "--diff", "--check", *BLACK_CONFORM_FILES
)
session.run("python", "-m", "black", "--diff", *DEFAULT_TEST_DIRECTORIES)


@nox.session
def doc(session: nox.session) -> None:
def doc(session: nox.Session) -> None:
"""Generate the documentation."""
session.install("-r", "doc/requirements.txt")
session.install("-e", ".")
Expand All @@ -99,15 +99,15 @@ def doc(session: nox.session) -> None:


@nox.session(python=False)
def tests(session: nox.session) -> None:
def tests(session: nox.Session) -> None:
"""Run the tests with the default GCC version."""
session_id = f"tests_compiler({GCC_VERSION2USE})"
session.log(f"Notify session {session_id}")
session.notify(session_id)


@nox.session(python=False)
def tests_all_compiler(session: nox.session) -> None:
def tests_all_compiler(session: nox.Session) -> None:
"""Run the tests with all GCC versions."""
for version in GCC_VERSIONS:
session_id = f"tests_compiler({version})"
Expand All @@ -117,7 +117,7 @@ def tests_all_compiler(session: nox.session) -> None:

@nox.session
@nox.parametrize("version", [nox.param(v, id=v) for v in GCC_VERSIONS])
def tests_compiler(session: nox.session, version: str) -> None:
def tests_compiler(session: nox.Session, version: str) -> None:
"""Run the test with a specifiv GCC version."""
session.install(
"jinja2",
Expand Down Expand Up @@ -154,15 +154,15 @@ def tests_compiler(session: nox.session, version: str) -> None:


@nox.session
def build_wheel(session: nox.session) -> None:
def build_wheel(session: nox.Session) -> None:
"""Build a wheel."""
session.install("wheel", "twine")
session.run("python", "setup.py", "sdist", "bdist_wheel")
session.run("twine", "check", "dist/*", external=True)


@nox.session
def upload_wheel(session: nox.session) -> None:
def upload_wheel(session: nox.Session) -> None:
"""Upload the wheel."""
session.install("twine")
session.run("twine", "upload", "dist/*", external=True)
Expand All @@ -174,15 +174,15 @@ def docker_container_id(version: str) -> str:


@nox.session(python=False)
def docker_qa_build(session: nox.session) -> None:
def docker_qa_build(session: nox.Session) -> None:
"""Build the docker container for the default GCC version."""
session_id = f"docker_qa_build_compiler({GCC_VERSION2USE})"
session.log(f"Notify session {session_id}")
session.notify(session_id)


@nox.session(python=False)
def docker_qa_build_all_compiler(session: nox.session) -> None:
def docker_qa_build_all_compiler(session: nox.Session) -> None:
"""Build the docker containers vor all GCC versions."""
for version in GCC_VERSIONS:
session_id = f"docker_qa_build_compiler({version})"
Expand All @@ -192,7 +192,7 @@ def docker_qa_build_all_compiler(session: nox.session) -> None:

@nox.session(python=False)
@nox.parametrize("version", [nox.param(v, id=v) for v in GCC_VERSIONS])
def docker_qa_build_compiler(session: nox.session, version: str) -> None:
def docker_qa_build_compiler(session: nox.Session, version: str) -> None:
"""Build the docker container for a specific GCC version."""
set_environment(session, version, False)
session.run(
Expand All @@ -214,15 +214,15 @@ def docker_qa_build_compiler(session: nox.session, version: str) -> None:


@nox.session(python=False)
def docker_qa_run(session: nox.session) -> None:
def docker_qa_run(session: nox.Session) -> None:
"""Run the docker container for the default GCC version."""
session_id = f"docker_qa_run_compiler({GCC_VERSION2USE})"
session.log(f"Notify session {session_id}")
session.notify(session_id)


@nox.session(python=False)
def docker_qa_run_all_compiler(session: nox.session) -> None:
def docker_qa_run_all_compiler(session: nox.Session) -> None:
"""Run the docker container for the all GCC versions."""
for version in GCC_VERSIONS:
session_id = f"docker_qa_run_compiler({version})"
Expand All @@ -232,10 +232,10 @@ def docker_qa_run_all_compiler(session: nox.session) -> None:

@nox.session(python=False)
@nox.parametrize("version", [nox.param(v, id=v) for v in GCC_VERSIONS])
def docker_qa_run_compiler(session: nox.session, version: str) -> None:
def docker_qa_run_compiler(session: nox.Session, version: str) -> None:
"""Run the docker container for a specific GCC version."""
set_environment(session, version, False)
session.env["NOX_POSARGS"] = " ".join([repr(a) for a in session.posargs])
session.env["NOX_POSARGS"] = shlex.join(session.posargs)
session.run(
"docker",
"run",
Expand All @@ -252,15 +252,15 @@ def docker_qa_run_compiler(session: nox.session, version: str) -> None:


@nox.session(python=False)
def docker_qa(session: nox.session) -> None:
def docker_qa(session: nox.Session) -> None:
"""Build and run the docker container for the default GCC version."""
session_id = f"docker_qa_compiler({GCC_VERSION2USE})"
session.log(f"Notify session {session_id}")
session.notify(session_id)


@nox.session(python=False)
def docker_qa_all_compiler(session: nox.session) -> None:
def docker_qa_all_compiler(session: nox.Session) -> None:
"""Build and run the docker container for the all GCC versions."""
for version in GCC_VERSIONS:
session_id = f"docker_qa_compiler({version})"
Expand All @@ -270,7 +270,7 @@ def docker_qa_all_compiler(session: nox.session) -> None:

@nox.session(python=False)
@nox.parametrize("version", [nox.param(v, id=v) for v in GCC_VERSIONS])
def docker_qa_compiler(session: nox.session, version: str) -> None:
def docker_qa_compiler(session: nox.Session, version: str) -> None:
"""Build and run the docker container for a specific GCC version."""
session_id = "docker_qa_build_compiler({})".format(version)
session.log(f"Notify session {session_id}")
Expand Down

0 comments on commit fd987c3

Please sign in to comment.