Skip to content

Commit

Permalink
Fix packaging of templates (#741)
Browse files Browse the repository at this point in the history
- Fix setup.py because of changed template paths.
- Run each output format to check if wheel contains all needed files.
- Add check of wheel to deploy workflow.
- Do not add whole gvovr namespace to bundled app because of test directories. Only the writers need to be included via command line because there are templates.
  • Loading branch information
Spacetown committed Mar 8, 2023
1 parent 7093d2b commit 3fa0cd4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ jobs:
- name: Test bundle of app
run: |
nox --non-interactive --session bundle_app
- name: Build
- name: Build wheel
run: |
nox --non-interactive --session build_wheel
- name: Check wheel
run: |
nox --non-interactive --session check_wheel
- name: Upload distribution
if: ${{ success() }}
uses: actions/upload-artifact@v3
Expand Down
39 changes: 30 additions & 9 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@

BLACK_PINNED_VERSION = "black==22.3.0"

OUTPUT_FORMATS = [
"cobertura",
"coveralls",
"csv",
"html-details",
"json",
"sonarqube",
"txt",
]

nox.options.sessions = ["qa"]


Expand Down Expand Up @@ -266,11 +276,15 @@ def build_wheel(session: nox.Session) -> None:
def check_wheel(session: nox.Session) -> None:
"""Check the wheel and do a smoke test, should not be used directly."""
session.install("wheel", "twine")
session.chdir(f"{session.cache_dir}/dist")
session.run("twine", "check", "*", external=True)
session.install(glob.glob("*.whl")[0])
with session.chdir(f"{session.cache_dir}/dist"):
session.run("twine", "check", "*", external=True)
session.install(glob.glob("*.whl")[0])
session.run("python", "-m", "gcovr", "--help", external=True)
session.run("gcovr", "--help", external=True)
session.log("Run all transformations to check if all the modules are packed")
with session.chdir(session.create_tmp()):
for format in OUTPUT_FORMATS:
session.run("gcovr", f"--{format}", f"out.{format}", external=True)


@nox.session
Expand Down Expand Up @@ -301,7 +315,7 @@ def bundle_app(session: nox.Session) -> None:
"./pyinstaller",
"--onefile",
"--collect-all",
"gcovr",
"gcovr.writer",
"-n",
executable,
*session.posargs,
Expand All @@ -313,11 +327,18 @@ def bundle_app(session: nox.Session) -> None:
@nox.session
def check_bundled_app(session: nox.Session) -> None:
"""Run a smoke test with the bundled app, should not be used directly."""
session.chdir("build")
session.run("bash", "-c", "./gcovr --help", external=True)
session.log("Run HTML all transformations to check if all the modules are packed")
for format in ["txt", "html", "cobertura", "sonarqube", "csv", "coveralls"]:
session.run("bash", "-c", f"./gcovr --{format} out.{format}", external=True)
with session.chdir("build"):
# bash here is needed to be independent from the file extension (Windows).
session.run("bash", "-c", "./gcovr --help", external=True)
session.log("Run all transformations to check if all the modules are packed")
session.create_tmp()
for format in OUTPUT_FORMATS:
session.run(
"bash",
"-c",
f"./gcovr --{format} $TMPDIR/out.{format}",
external=True,
)


def docker_container_os(session: nox.Session) -> str:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
packages=find_packages(include=["gcovr*"], exclude=["gcovr.tests"]),
install_requires=["jinja2", "lxml", "pygments"],
package_data={
"gcovr": ["templates/*.css", "templates/*.html"],
"gcovr": ["writer/html/templates/*.css", "writer/html/templates/*.html"],
},
entry_points={
"console_scripts": [
Expand Down

0 comments on commit 3fa0cd4

Please sign in to comment.