-
Notifications
You must be signed in to change notification settings - Fork 6
72 lines (64 loc) · 2.75 KB
/
Copy pathcheck-alerts.yaml
File metadata and controls
72 lines (64 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Check Alerts using Promtool
on:
pull_request:
paths:
- 'helm/bundles/*/templates/alerts.yaml'
- 'helm/bundles/*/values.yaml'
- 'helm/bundles/*/Chart.yaml'
- 'helm/library/**'
- '.github/workflows/check-alerts.yaml'
jobs:
lint:
# Pinned to ubuntu-24.04 so the pre-installed helm and yq versions are
# stable. helm and yq come from the base runner image (no install step
# needed); promtool is installed by the peimanja action below.
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- name: Get changed bundles
id: changed_bundles
uses: tj-actions/changed-files@v47
with:
dir_names: "true"
dir_names_max_depth: "3"
files: |
helm/bundles/**
- name: Get changed library files
id: changed_library
uses: tj-actions/changed-files@v47
with:
files: helm/library/**
- name: Render bundles to rule files
env:
CHANGED_BUNDLES: ${{ steps.changed_bundles.outputs.all_changed_files }}
LIBRARY_CHANGED: ${{ steps.changed_library.outputs.any_changed }}
run: |
set -euo pipefail
mkdir -p rendered
# When library charts change (or nothing bundle-specific was detected,
# e.g. only the workflow file changed) all bundles are affected.
if [[ "$LIBRARY_CHANGED" == "true" || -z "$CHANGED_BUNDLES" ]]; then
bundles=$(find helm/bundles -maxdepth 1 -mindepth 1 -type d | sort)
else
bundles="$CHANGED_BUNDLES"
fi
for bundle in $bundles; do
name=$(basename "$bundle")
helm/replace-oci-refs.sh "$bundle" > "$bundle/Chart.yaml.tmp" && mv "$bundle/Chart.yaml.tmp" "$bundle/Chart.yaml"
helm dep update "$bundle"
if [[ "$name" == "cortex-nova" ]]; then
# nova has KVM-gated rules; render both flavours.
helm template "$name" "$bundle" | yq 'select(.kind == "PrometheusRule") | .spec' > "rendered/${name}-default.yaml"
helm template "$name" "$bundle" --set kvm.enabled=true | yq 'select(.kind == "PrometheusRule") | .spec' > "rendered/${name}-kvm.yaml"
else
helm template "$name" "$bundle" | yq 'select(.kind == "PrometheusRule") | .spec' > "rendered/${name}.yaml"
fi
done
ls -la rendered/
- name: Check rules with promtool
uses: peimanja/promtool-github-actions@741be6fd6b8ee6a1d777ea020076b70c6233b3a1 # v0.0.2
with:
promtool_actions_subcommand: 'rules'
promtool_actions_files: 'rendered/*.yaml'
promtool_actions_version: 'latest'
promtool_actions_comment: 'false'