Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[run]
branch = True
source =
cijoe.core
cijoe.cli
cijoe.fio
cijoe.gha
cijoe.linux
cijoe.qemu
cijoe.system_imaging
76 changes: 70 additions & 6 deletions .github/workflows/verify_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ defaults:
run:
shell: bash

# This is needed for 'guestmount' / 'libguestfs'
env:
LIBGUESTFS_BACKEND: direct

jobs:
format:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -86,6 +82,10 @@ jobs:
needs: format
runs-on: ubuntu-latest

# This is needed for 'guestmount' / 'libguestfs'
env:
LIBGUESTFS_BACKEND: direct

container:
image: ghcr.io/refenv/cijoe-docker:latest
options: --privileged
Expand Down Expand Up @@ -133,8 +133,15 @@ jobs:

- name: Run it!
run: |
cd cijoe-example-${{ matrix.usage_example }}
cijoe --monitor -l
cd cijoe-example-${{ matrix.usage_example}}
coverage run \
--data-file=../.coverage.${{ matrix.usage_example}} \
--rcfile=../repository/.coveragerc \
$(which cijoe) --monitor -l

- name: Coverage report
run: |
coverage report --data-file=.coverage.${{ matrix.usage_example}}

- name: Upload report
if: always()
Expand All @@ -144,6 +151,15 @@ jobs:
path: cijoe-example-${{ matrix.usage_example }}/cijoe-output/*
if-no-files-found: error

- name: Upload coverage files
if: always()
uses: actions/upload-artifact@v4.3.0
with:
name: report-coverage-${{ matrix.usage_example }}
path: .coverage.${{ matrix.usage_example}}
if-no-files-found: error


publish:
if: startsWith(github.ref, 'refs/tags/v')
needs:
Expand Down Expand Up @@ -172,3 +188,51 @@ jobs:
run: |
make release

publish-coverage:
runs-on: ${{ matrix.os }}
needs: [examples, unittest]
container:
image: ghcr.io/refenv/cijoe-docker:latest
options: --privileged

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.12']

steps:
- name: Grab source
uses: actions/checkout@v4.2.2
with:
path: repository

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.2.0
with:
python-version: ${{ matrix.python-version }}

- name: Build and install cijoe from source
run: |
pipx uninstall cijoe
cd repository
make deps info build install
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Download all artifacts
uses: actions/download-artifact@v4.1.8
with:
# If you omit 'name', all artifacts from previous jobs are downloaded.
path: ./all_artifacts

- name: Show downloaded artifacts
run: |
find all_artifacts -name '.coverage*' -exec coverage debug data {} \;
coverage combine \
--rcfile=repository/.coveragerc \
all_artifacts/report-coverage**/.coverage**
coverage report \
--debug=trace,config \
--rcfile=repository/.coveragerc
- name: Coveralls upload
uses: coverallsapp/github-action@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.coverage
cijoe-output*
tags
selftest_results
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ BUILD=pyproject-build
PIPX=pipx
PYTEST="$(shell pipx environment -V PIPX_LOCAL_VENVS)/${PROJECT_NAME}/bin/pytest"
PYTHON_SYS=python3
PYTHON_VENV="$(shell pipx environment -V PIPX_LOCAL_VENVS)/${PROJECT_NAME}/bin/python3"
TWINE=twine
CIJOE_VERSION=$(shell cd src; python3 -c "from cijoe import core;print(core.__version__)")

Expand Down Expand Up @@ -42,7 +41,6 @@ info:
${PIPX} --version || true
${PYTEST} --version || true
${PYTHON_SYS} --version || true
${PYTHON_VENV} --version || true
${TWINE} --version || true
@echo "## ${PROJECT_NAME}: make info [DONE]"

Expand Down Expand Up @@ -123,7 +121,8 @@ endef
install:
@echo "## ${PROJECT_NAME}: make install"
@${PIPX} install dist/*.tar.gz --include-deps --force --python python3
@${PIPX} inject cijoe coverage --include-apps --force
@${PIPX} inject cijoe coverage --include-apps --include-deps --force
@${PIPX} inject cijoe pytest-cov --force
@echo "## ${PROJECT_NAME}: make install [DONE]"

define uninstall-help
Expand All @@ -143,7 +142,7 @@ endef
.PHONY: test
test:
@echo "## ${PROJECT_NAME}: make test"
${PYTEST} --pyargs cijoe.core.selftest --config src/cijoe/core/configs/example_config_default.toml -v -s
${PYTEST} --cov --pyargs cijoe.core.selftest --config src/cijoe/core/configs/example_config_default.toml -v -s
@echo "## ${PROJECT_NAME}: make test [DONE]"

define examples-help
Expand Down
13 changes: 11 additions & 2 deletions src/cijoe/core/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,17 @@ def load(self):
if not self.content_has_script_func():
return ["Missing script_entry() function in ast"]

mod_name = str(Path(self.path).resolve().stem)
mod_path = str(Path(self.path).resolve())
path = Path(self.path).resolve()

mod_path = str(path)
mod_name = ".".join(
[
path.parent.parent.parent.stem, # This should be cijoe
path.parent.parent.stem, # This should be the "package" name
path.parent.stem, # This should be "scripts"
path.stem, # This is the name of the module
]
)

parent_path = str(Path(self.path).resolve().parent)
if parent_path not in sys.path:
Expand Down
Loading