Skip to content

Commit

Permalink
[build] Test example configs during build (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
robpickerill committed Oct 7, 2023
1 parent 4702de3 commit c79f62f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ jobs:
go test github.com/cloudprober/cloudprober/probes/ping -c
sudo PING_HOSTS_V4=${{ env.PING_HOSTS_V4 }} PING_HOSTS_V6=${{ env.PING_HOSTS_V6 }} ./ping.test -test.v -test.run ^TestRunProbeRealICMP$
- name: Example config tests
if: matrix.os == 'ubuntu-latest'
run: tools/test_example_configs.sh

- name: Upload test and coverage reports
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion examples/additional_label/cloudprober.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ probe {
type: HTTP

targets {
k8s_targets {
k8s {
namespace: "prod"
ingresses: ".*"
labelSelector: "role=ingress-proxy"
Expand Down
14 changes: 14 additions & 0 deletions tools/test_example_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail

# This script is used to test the example configurations found
# in the examples/ directory. If any examples fail to parse
# or are invalid, this script will fail by returning a non-zero
# exit code.
# It is used by the CI system to ensure that the examples are
# valid and up-to-date.

for example in examples/**/*.cfg; do
echo "Testing ${example}"
go run cmd/cloudprober.go -configtest -config_file "${example}"
done

0 comments on commit c79f62f

Please sign in to comment.