From 7594b13a8099e74f0552454f1b7285f141a2b365 Mon Sep 17 00:00:00 2001 From: Jan Horstmann Date: Thu, 7 Nov 2024 10:24:45 +0100 Subject: [PATCH] Add tests for whether mixin output is checked-in With the proposed workflow mixin output is generated offline and checked into version control for direct usage. A test is added to check whether the generated rules and dashboards match the checked-in version. Additionally checks for the shellscript generating the mixins and for the mixin test playbook from above are added. Signed-off-by: Jan Horstmann --- .../mixin-ouput-ensure-git-checkin.yml | 38 +++++++++++++++++++ .zuul.yaml | 4 ++ 2 files changed, 42 insertions(+) create mode 100644 .src/playbooks/mixin-ouput-ensure-git-checkin.yml diff --git a/.src/playbooks/mixin-ouput-ensure-git-checkin.yml b/.src/playbooks/mixin-ouput-ensure-git-checkin.yml new file mode 100644 index 0000000..55eaad1 --- /dev/null +++ b/.src/playbooks/mixin-ouput-ensure-git-checkin.yml @@ -0,0 +1,38 @@ +--- +- name: Run check-shell-syntax + connection: local + hosts: localhost + #hosts: all + vars: + zuul: + project: + src_dir: ../.. + tasks: + - name: Build monitoring-mixin container + containers.podman.podman_image: + name: mixin-builder + path: "./{{ zuul.project.src_dir }}/.src" + build: + file: "./{{ zuul.project.src_dir }}/.src/Containerfile" + - name: Install monitoring-mixin dependencies + containers.podman.podman_container: + command: jb install + <<: &mixin_container_options + name: mixin-builder + image: localhost/mixin-builder + detach: false + volume: + - "./{{ zuul.project.src_dir }}:/srv" + rm: true + - name: Render monitoring-mixin rules / dashboards + containers.podman.podman_container: + <<: *mixin_container_options + - name: Check difference between git and generated rules / dashboards + ansible.builtin.command: + argv: + - /usr/bin/git + - diff + - --exit-code + register: git_diff + changed_when: false + failed_when: git_diff.rc != 0 diff --git a/.zuul.yaml b/.zuul.yaml index 11b9930..712d164 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,4 +1,8 @@ --- +- job: + name: mixin-ouput-ensure-git-checkin + description: Check for differences between monitoring-mixin output and checked in rules/dashboards + run: .src/playbooks/mixin-ouput-ensure-git-checkin.yml - project: default-branch: main merge-mode: squash-merge