From 0b445f08ddc7adb04963dda01ac407990969a8c1 Mon Sep 17 00:00:00 2001 From: Spacetown Date: Tue, 21 Sep 2021 22:27:26 +0200 Subject: [PATCH] Fix CI errors. Remove doc/requirements.txt --- .editorconfig | 6 ++- .github/workflows/deploy.yml | 9 ++-- .github/workflows/test.yml | 12 ++--- admin/Dockerfile.qa | 3 +- doc/requirements.txt | 4 -- noxfile.py | 98 ++++++++++++++++++++++++------------ 6 files changed, 80 insertions(+), 52 deletions(-) delete mode 100644 doc/requirements.txt diff --git a/.editorconfig b/.editorconfig index 6dc36f179..bc0fbcbe8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 \ No newline at end of file +indent_size = 2 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 89ffb3df6..c42380bbd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 049235115..b74c8afca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 diff --git a/admin/Dockerfile.qa b/admin/Dockerfile.qa index ec9f5c7fc..7491399c3 100644 --- a/admin/Dockerfile.qa +++ b/admin/Dockerfile.qa @@ -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" @@ -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 diff --git a/doc/requirements.txt b/doc/requirements.txt deleted file mode 100644 index 6da1ceef8..000000000 --- a/doc/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -sphinx -sphinx_rtd_theme -sphinxcontrib-autoprogram == 0.1.5 ; python_version == "3.6" -sphinxcontrib-autoprogram >= 0.1.5 ; python_version >= "3.7" diff --git a/noxfile.py b/noxfile.py index 4853d70ff..bdb498dde 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,5 @@ import os +import platform import shutil import nox @@ -19,7 +20,7 @@ ] -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" @@ -27,7 +28,10 @@ def set_environment(session, cc, check=True): 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" @@ -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 @@ -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)) @@ -93,22 +109,36 @@ 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"] @@ -116,31 +146,31 @@ def tests_version(session, version): @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)) @@ -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", @@ -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)) @@ -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", @@ -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), @@ -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) @@ -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)) @@ -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)