Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smoke ci #71

Merged
merged 33 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3936ac5
common-exit-hook for Worker
PietroPasotti Sep 4, 2024
6d94170
test fix
PietroPasotti Sep 4, 2024
efe2396
vbump
PietroPasotti Sep 4, 2024
d0f2390
tests
PietroPasotti Sep 4, 2024
fb982bc
lint
PietroPasotti Sep 5, 2024
08ea874
Merge branch 'main' into holistic-worker-logic
PietroPasotti Sep 5, 2024
e8a7699
add CI to validate cosl against worker and coordinator (tempo only fo…
PietroPasotti Sep 5, 2024
e5abc1d
unified matrix
PietroPasotti Sep 5, 2024
b61524d
Merge branch 'holistic-worker-logic' of github.com:canonical/cos-lib …
PietroPasotti Sep 5, 2024
7799916
from main
PietroPasotti Sep 5, 2024
9d481d8
Merge branch 'main' into smoke-ci
PietroPasotti Sep 5, 2024
3bae581
fixed itest ci
PietroPasotti Sep 6, 2024
72afa3b
Merge remote-tracking branch 'origin/main' into smoke-ci
PietroPasotti Sep 6, 2024
5fe7874
verbose
PietroPasotti Sep 6, 2024
45de0b4
Merge branch 'main' into smoke-ci
PietroPasotti Sep 6, 2024
c5bb255
Merge branch 'main' into smoke-ci
PietroPasotti Sep 6, 2024
894446c
install git
PietroPasotti Sep 9, 2024
fabe4f8
Merge branch 'smoke-ci' of github.com:canonical/cos-lib into smoke-ci
PietroPasotti Sep 9, 2024
aa31ff5
pin scenario to <7 for now
PietroPasotti Sep 9, 2024
c2e2d92
install git once more
PietroPasotti Sep 9, 2024
1d16fdd
install git once more
PietroPasotti Sep 9, 2024
797a176
merge
PietroPasotti Sep 11, 2024
731ce68
uniformed coverage report
PietroPasotti Sep 11, 2024
9e3bd68
merge
PietroPasotti Sep 11, 2024
5e9af32
add yq
michaeldmitry Sep 12, 2024
b55b164
typing
PietroPasotti Sep 12, 2024
0b42ad7
Merge branch 'smoke-ci' of github.com:canonical/cos-lib into smoke-ci
PietroPasotti Sep 12, 2024
6e1d448
yqw
PietroPasotti Sep 12, 2024
7c1d917
silenced debug databag log if empty
PietroPasotti Sep 12, 2024
865f11b
vbump
PietroPasotti Sep 12, 2024
e5de169
using latest commit sha
PietroPasotti Sep 12, 2024
2206684
try with branch name
michaeldmitry Sep 12, 2024
921ef65
downgrade version + conditional run
michaeldmitry Sep 12, 2024
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
73 changes: 73 additions & 0 deletions .github/workflows/distributed-solutions-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Distributed Solutions Tests

on:
push:
branches:
- main
pull_request:
workflow_call:

jobs:
test-distributed-charms:
runs-on: ubuntu-latest
continue-on-error: true

strategy:
fail-fast: false
matrix:
include:
- repo: canonical/tempo-coordinator-k8s-operator
- repo: canonical/tempo-worker-k8s-operator

steps:
- name: Checkout the ${{ matrix.repo }} repository
uses: actions/checkout@v4
with:
fetch-depth: 1
repository: ${{ matrix.repo }}
ref: main

- name: Update 'cosl' dependency in test charm to this branch
run: |
sed -i -e "/^cosl[ ><=]/d" -e "/canonical\/cos-lib/d" -e "/#egg=cosl/d" requirements.txt
echo -e "\ngit+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY@${{ github.head_ref || github.ref_name }}#egg=cosl" >> requirements.txt

- name: Install dependencies (tox & yq)
run: pip install tox~=4.2 && sudo snap install yq

- name: Add charmcraft build dependencies (git)
run: yq e '.parts.charm.build-packages += ["git"]' -i charmcraft.yaml

- name: Run the charm's unit & scenario tests
id: unit
run: tox -e unit,scenario

- name: Run the charm's static analysis checks
id: static
run: tox -e static-charm,static-lib

- name: Setup Charmcraft's pip cache
uses: actions/cache@v4
with:
path: /home/runner/snap/charmcraft/common/cache/charmcraft/
key: charmcraft-cache-${{ github.job }}-${{ strategy.job-index }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: charmcraft-cache

- name: Get IP range
id: ip_range
run: |
echo "ip_range=$(ip -4 -j route get 2.2.2.2 | jq -r '.[] | .prefsrc')/32" >> $GITHUB_OUTPUT

- name: Setup operator environment (k8s)
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: 3.4/stable
provider: microk8s
channel: 1.26-strict/stable
microk8s-group: snap_microk8s
microk8s-addons: "hostpath-storage dns metallb:${{ steps.ip_range.outputs.ip_range }}"
charmcraft-channel: "2.x/stable"

- name: Run the charm's integration tests
run: tox -vve integration
if: steps.unit.outcome == 'success' && steps.static.outcome == 'success'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
results/
.tox/
.nox/
.coverage
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ include = ["py.typed"]
# Testing tools configuration
[tool.coverage.run]
branch = true
parallel = true
omit = ["tests/**", "lib/**"]

[tool.coverage.report]
show_missing = true
Expand Down
3 changes: 2 additions & 1 deletion src/cosl/coordinated_workers/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def load(cls, databag: _RawDatabag):
return cls.model_validate_json(json.dumps(data)) # type: ignore
except pydantic.ValidationError as e:
msg = f"failed to validate databag: {databag}"
log.debug(msg, exc_info=True)
if databag:
log.debug(msg, exc_info=True)
raise DataValidationError(msg) from e

def dump(self, databag: Optional[_RawDatabag] = None, clear: bool = True) -> _RawDatabag:
Expand Down
9 changes: 8 additions & 1 deletion src/cosl/loki_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,18 @@ def build_labels(self, record: logging.LogRecord) -> Dict[str, str]:
labels[self.level_label] = record.levelname.lower()
labels[self.logger_label] = record.name

extra_labels = getattr(record, "labels", {})
# if the user implemented a logrecord subclass with a .labels attributes, attempt to
# respect it and add those labels on top of those registered on the LokiEmitter class.
extra_labels: Any = getattr(record, "labels", {})
if not isinstance(extra_labels, dict):
return labels

label_name: Any
label_value: Any
for label_name, label_value in extra_labels.items():
if not isinstance(label_name, str) or not isinstance(label_value, str):
return labels

cleared_name = self.format_label(label_name)
if cleared_name:
labels[cleared_name] = label_value
Expand Down
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,11 @@ setenv =
commands =
python -m doctest {[vars]src_path}/cosl/mandatory_relation_pairs.py
/usr/bin/env sh -c 'stat cos-tool-amd64 > /dev/null 2>&1 || curl -L -O https://github.com/canonical/cos-tool/releases/latest/download/cos-tool-amd64'
pytest --cov-report=html:.cover --cov {[vars]src_path} -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tst_path}
pytest {tty:--color=yes} --cov={[vars]src_path} --cov-config={tox_root}/pyproject.toml \
; for us
--cov-report=html:{tox_root}/results/html-cov/ \
; for tiobe
--cov-report=xml:{tox_root}/results/coverage-{env_name}.xml \
; for sparta
--cov-report=json:{tox_root}/results/tox-{env_name}.json \
--junit-xml={tox_root}/results/test-results-{env_name}.xml {posargs}
Loading