Skip to content

Commit

Permalink
CI: replace yaml lib
Browse files Browse the repository at this point in the history
yaml was removed from core in some version between 3.8 and 3.10.
  • Loading branch information
wreis committed Nov 9, 2023
1 parent bedd054 commit 023789a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade black pytest sh
python -m pip install --upgrade black
- name: Check Python formatting
run: |
set -eux
Expand All @@ -36,13 +36,13 @@ jobs:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pytest sh
sudo python -m pip install --upgrade pip
sudo pip install --upgrade pytest sh ruamel.yaml
- name: Running addons tests
run: |
set -x
sudo snap install microk8s --classic --channel=latest/edge
sudo microk8s status --wait-ready --timeout 600
sudo microk8s addons repo add testing .
pytest -s ./tests/test-addons.py
sudo pytest -s ./tests/test-addons.py
sudo snap remove microk8s --purge
8 changes: 6 additions & 2 deletions tests/test-addons.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import sh
import yaml

from ruamel.yaml import YAML

from utils import microk8s_enable, wait_for_pod_state, microk8s_disable


yaml = YAML(typ="safe")


class TestAddons(object):
def test_python_demo_nginx(self):
microk8s_enable("python-hello-k8s")
wait_for_pod_state("", "default", "running", label="app=python-demo-nginx")
status = yaml.safe_load(sh.microk8s.status(format="yaml").stdout)
status = yaml.load(sh.microk8s.status(format="yaml").stdout)
expected = {"python-hello-k8s": "enabled"}
microk8s_disable("python-hello-k8s")
8 changes: 6 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import datetime
import time
import yaml

from subprocess import check_output, CalledProcessError
from ruamel.yaml import YAML


yaml = YAML(typ="safe")


def run_until_success(cmd, timeout_insec=60, err_out=None):
Expand Down Expand Up @@ -58,7 +62,7 @@ def kubectl_get(target, timeout_insec=300):
"""
cmd = "get -o yaml " + target
output = kubectl(cmd, timeout_insec)
return yaml.safe_load(output)
return yaml.load(output)


def wait_for_pod_state(
Expand Down

0 comments on commit 023789a

Please sign in to comment.