Skip to content

Commit

Permalink
Fix CI errors.
Browse files Browse the repository at this point in the history
Remove doc/requirements.txt
  • Loading branch information
Spacetown committed Sep 22, 2021
1 parent 7e05689 commit 0214fb7
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 52 deletions.
6 changes: 5 additions & 1 deletion .editorconfig
Expand Up @@ -11,6 +11,10 @@ trim_trailing_whitespace = true
[*.py]
indent_size = 4

# for the makefiles use tabs
[makefile]
indent_style = tab

# for the web templates, use more compact indent
[gcovr/templates/*]
indent_size = 2
indent_size = 2
9 changes: 4 additions & 5 deletions .github/workflows/deploy.yml
Expand Up @@ -44,20 +44,19 @@ jobs:
uses: seanmiddleditch/gha-setup-ninja@master
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Lint with flake8
run: |
python -m nox --session lint
python -m nox --non-interactive --session lint
- name: Test with pytest
run: |
python -m nox --session "tests_version($CC)"
python -m nox --non-interactive --session "tests_version($CC)"
- name: Generate documentation
run: |
python -m nox --session doc
python -m nox --non-interactive --session doc
- name: Build
run: |
python -m nox --session build_wheel
python -m nox --non-interactive --session build_wheel
- name: Upload distribution
if: ${{ success() }}
uses: actions/upload-artifact@v2
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/test.yml
Expand Up @@ -131,20 +131,19 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install nox codecov
- name: Lint files
run: |
python3 -m nox --session lint
python3 -m 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: |
python -m nox --session black
python -m nox --non-interactive --session black
- name: Test with pytest
run: |
python -m nox --session "tests_version(${{ matrix.gcc }})"
python -m nox --non-interactive --session "tests_version(${{ matrix.gcc }})"
- name: Upload pytest test results
if: ${{ failure() }}
uses: actions/upload-artifact@v2
Expand All @@ -171,15 +170,14 @@ jobs:
steps:
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install nox
- uses: actions/checkout@v2
- name: Build Docker
run: |
python3 -m nox --session "docker_qa_build_version(${{ matrix.gcc }})"
python3 -m nox --non-interactive --session "docker_qa_build_version(${{ matrix.gcc }})"
- name: Run Docker
run: |
python3 -m nox --session "docker_qa_run_version(${{ matrix.gcc }})"
python3 -m nox --non-interactive --session "docker_qa_run_version(${{ matrix.gcc }})"
- name: Upload pytest test results
if: ${{ failure() }}
uses: actions/upload-artifact@v2
Expand Down
3 changes: 1 addition & 2 deletions admin/Dockerfile.qa
Expand Up @@ -14,7 +14,6 @@ WORKDIR /gcovr
ENV CC=$CC CXX=$CXX GCOVR_ISOLATED_TEST=zkQEVaBpXF1i

RUN \
python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir nox

# Create new user "docker" and set password to "docker"
Expand All @@ -30,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 ) && \
echo "" && \
python3 -m nox
python3 -m nox --non-interactive
4 changes: 0 additions & 4 deletions doc/requirements.txt

This file was deleted.

98 changes: 65 additions & 33 deletions noxfile.py
@@ -1,4 +1,5 @@
import os
import platform
import shutil
import nox

Expand All @@ -19,15 +20,18 @@
]


def set_environment(session, cc, check=True):
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"
cxx = "g++"
gcov = "gcov"
else:
cxx = cc.replace("clang", "clang++").replace("gcc", "g++")
gcov = cc.replace("clang", "llvm-cov").replace("gcc", "gcov")
if cc.startswith("clang"):
gcov = cc.replace("clang", "llvm-cov") + " gcov"
else:
gcov = cc.replace("gcc", "gcov")
session.env["GCOVR_TEST_SUITE"] = "1"
session.env["CC"] = cc
session.env["CFLAGS"] = "--this_flag_does_not_exist"
Expand All @@ -37,30 +41,37 @@ def set_environment(session, cc, check=True):


@nox.session
def qa(session):
def qa(session: "nox.session") -> None:
for session_id in nox.options.sessions:
session.log("Notify session {}".format(session_id))
session.notify(session_id)


@nox.session
def lint(session):
session.install("flake8", "black")
def lint(session: "nox.session") -> None:
session.install("flake8")
if platform.python_implementation() == "CPython":
session.install("black")
if session.posargs:
args = session.posargs
else:
args = DEFAULT_TEST_DIRECTORIES
session.run("flake8", *args)

if session.posargs:
session.run("python", "-m", "black", *session.posargs)
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)
else:
session.run("python", "-m", "black", "--diff", "--check", *BLACK_CONFORM_FILES)
session.run("python", "-m", "black", "--diff", *DEFAULT_TEST_DIRECTORIES)
session.log(f"Skip black because of platform {platform.python_implementation}.")


@nox.session
def black(session):
def black(session: "nox.session") -> None:
session.install("black")
if session.posargs:
args = session.posargs
Expand All @@ -70,21 +81,26 @@ def black(session):


@nox.session
def doc(session):
session.install("-r", "doc/requirements.txt")
def doc(session: "nox.session") -> None:
session.install(
"sphinx",
"sphinx_rtd_theme",
"sphinxcontrib-autoprogram==0.1.5 ; python_version=='3.6'",
"sphinxcontrib-autoprogram>=0.1.5 ; python_version>='3.7'",
)
session.install("-e", ".")
session.run("bash", "-c", "cd doc && make html O=-W", external=True)


@nox.session
def tests(session):
def tests(session: "nox.session") -> None:
session_id = "tests_version({})".format(GCC_VERSION2USE)
session.log("Notify session {}".format(session_id))
session.notify(session_id)


@nox.session
def tests_all_versions(session):
def tests_all_versions(session: "nox.session") -> None:
for version in GCC_VERSIONS:
session_id = "tests_version({})".format(version)
session.log("Notify session {}".format(session_id))
Expand All @@ -93,54 +109,68 @@ def tests_all_versions(session):

@nox.session
@nox.parametrize("version", [nox.param(v, id=v) for v in GCC_VERSIONS])
def tests_version(session, version):
def tests_version(session: "nox.session", version: str) -> None:
session.install(
"jinja2",
"lxml",
"pygments == 2.7.4",
"pygments==2.7.4",
"pytest",
"pytest-cov",
"cmake",
"yaxmldiff",
)
coverage_args = []
if os.environ.get("USE_COVERAGE") == "true":
session.install("pytest-cov")
coverage_args = ["--cov=gcovr", "--cov-branch"]
session.install("-e", ".")
set_environment(session, version)
session.log("Print tool versions")
session.run("python", "--version")
session.run(session.env["CC"], "--version", external=True)
session.run(session.env["CXX"], "--version", external=True)
session.run(
session.env["GCOV"].replace(" gcov", "")
if "llvm-cov" in session.env["GCOV"]
else session.env["GCOV"],
"--version",
external=True,
)

session.run("bash", "-c", "cd gcovr/tests && make --silent clean", external=True)
args = ["-m", "pytest"]
if os.environ.get("USE_COVERAGE") == "true":
args += ["--cov=gcovr", "--cov-branch"]
args += coverage_args
args += session.posargs
if "--" not in args:
args += ["--", "gcovr", "doc/examples"]
session.run("python", *args)


@nox.session
def build_wheel(session):
def build_wheel(session: "nox.session") -> None:
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):
def upload_wheel(session: "nox.session") -> None:
session.install("twine")
session.run("twine", "upload", "dist/*", external=True)


def docker_container_id(version):
def docker_container_id(version: str) -> None:
return "gcovr-qa-{}".format(version)


@nox.session
def docker_qa_build(session):
def docker_qa_build(session: "nox.session") -> None:
session_id = "docker_qa__build_version({})".format(GCC_VERSION2USE)
session.log("Notify session {}".format(session_id))
session.notify(session_id)


@nox.session
def docker_qa_build_all_versions(session):
def docker_qa_build_all_versions(session: "nox.session") -> None:
for version in GCC_VERSIONS:
session_id = "docker_qa_build_version({})".format(version)
session.log("Notify session {}".format(session_id))
Expand All @@ -149,8 +179,8 @@ def docker_qa_build_all_versions(session):

@nox.session
@nox.parametrize("version", [nox.param(v, id=v) for v in GCC_VERSIONS])
def docker_qa_build_version(session, version):
set_environment(session, version, True)
def docker_qa_build_version(session: "nox.session", version: str) -> None:
set_environment(session, version, False)
session.run(
"bash",
"-c",
Expand All @@ -176,14 +206,14 @@ def docker_qa_build_version(session, version):


@nox.session
def docker_qa_run(session):
def docker_qa_run(session: "nox.session") -> None:
session_id = "docker_qa_run_version({})".format(GCC_VERSION2USE)
session.log("Notify session {}".format(session_id))
session.notify(session_id)


@nox.session
def docker_qa_run_all_versions(session):
def docker_qa_run_all_versions(session: "nox.session") -> None:
for version in GCC_VERSIONS:
session_id = "docker_qa_run_version({})".format(version)
session.log("Notify session {}".format(session_id))
Expand All @@ -192,8 +222,8 @@ def docker_qa_run_all_versions(session):

@nox.session
@nox.parametrize("version", [nox.param(v, id=v) for v in GCC_VERSIONS])
def docker_qa_run_version(session, version):
set_environment(session, version, True)
def docker_qa_run_version(session: "nox.session", version: str) -> None:
set_environment(session, version, False)
session.run(
"bash",
"-c",
Expand All @@ -204,6 +234,8 @@ def docker_qa_run_version(session, version):
"--rm",
"-e",
"TESTOPTS",
"-e",
"CC",
"-v",
"{}:/gcovr".format(os.getcwd()),
docker_container_id(version),
Expand All @@ -214,7 +246,7 @@ def docker_qa_run_version(session, version):


@nox.session
def docker_qa(session):
def docker_qa(session: "nox.session") -> None:
session_id = "docker_qa_build_version({})".format(GCC_VERSION2USE)
session.log("Notify session {}".format(session_id))
session.notify(session_id)
Expand All @@ -224,7 +256,7 @@ def docker_qa(session):


@nox.session
def docker_qa_all_versions(session):
def docker_qa_all_versions(session: "nox.session") -> None:
for version in GCC_VERSIONS:
session_id = "docker_qa_build_version({})".format(version)
session.log("Notify session {}".format(session_id))
Expand All @@ -236,7 +268,7 @@ def docker_qa_all_versions(session):

@nox.session
@nox.parametrize("version", [nox.param(v, id=v) for v in GCC_VERSIONS])
def docker_qa_version(session, version):
def docker_qa_version(session: "nox.session", version: str) -> None:
session_id = "docker_qa_build_version({})".format(version)
session.log("Notify session {}".format(session_id))
session.notify(session_id)
Expand Down

0 comments on commit 0214fb7

Please sign in to comment.