Skip to content

Commit 82a269e

Browse files
committed
GitHub Actions get the cluster config differently
Signed-off-by: Pete Wall <pete.wall@grafana.com>
1 parent 84a74a4 commit 82a269e

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

.github/workflows/integration-test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ jobs:
5050
- name: Check for cluster config
5151
id: check-cluster-config
5252
run: |
53-
if [ -f "charts/k8s-monitoring/tests/integration/${{ matrix.test }}/cluster.yaml" ]; then
53+
testManifest="charts/k8s-monitoring/tests/integration/${{ matrix.test }}/test-manifest.yaml"
54+
clusterConfig="$(yq -r ".cluster.config // \"\"" "${testManifest}")"
55+
if [ -f "charts/k8s-monitoring/tests/integration/${{ matrix.test }}/${clusterConfig}" ]; then
5456
echo "has-cluster-config=true" >> "${GITHUB_OUTPUT}"
57+
echo "cluster-config=charts/k8s-monitoring/tests/integration/${{ matrix.test }}/${clusterConfig}" >> "${GITHUB_OUTPUT}"
5558
else
5659
echo "has-cluster-config=false" >> "${GITHUB_OUTPUT}"
5760
fi
@@ -64,7 +67,7 @@ jobs:
6467
if: ${{ steps.check-cluster-config.outputs.has-cluster-config == 'true' }}
6568
uses: helm/kind-action@v1
6669
with:
67-
config: charts/k8s-monitoring/tests/integration/${{ matrix.test }}/cluster.yaml
70+
config: ${{ steps.check-cluster-config.outputs.cluster-config }}
6871

6972
- name: Run test
7073
env:

scripts/run-integration-test.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ usage() {
1414
echo " test-manifest.yaml - The test manifest, which defines cluster, and deployments"
1515
}
1616

17+
CREATE_CLUSTER=${CREATE_CLUSTER:-true}
1718
HEADLESS=${HEADLESS:-false}
1819
TEST_DIRECTORY=$1
1920
if [ -z "${TEST_DIRECTORY}" ]; then
@@ -30,23 +31,26 @@ if [ ! -f "${testManifest}" ]; then
3031
fi
3132

3233
set -eo pipefail # Exit immediately if a command fails.
34+
3335
#
3436
# Cluster creation
3537
#
36-
clusterType=$(yq -r ".cluster.type // \"kind\"" "${testManifest}")
37-
clusterName=$(yq -r ".cluster.name // \"$(basename "${TEST_DIRECTORY}")\"" "${testManifest}")
38-
clusterConfig=$(yq -r ".cluster.config // \"\"" "${testManifest}")
38+
if [ "${CREATE_CLUSTER}" == "true" ]; then
39+
clusterType=$(yq -r ".cluster.type // \"kind\"" "${testManifest}")
40+
clusterName=$(yq -r ".cluster.name // \"$(basename "${TEST_DIRECTORY}")\"" "${testManifest}")
41+
clusterConfig=$(yq -r ".cluster.config // \"\"" "${testManifest}")
3942

40-
if [ "${clusterType}" == "kind" ]; then
41-
if ! kind get clusters | grep -q "${clusterName}"; then
42-
if [ ! -f "${clusterConfig}" ]; then
43-
kind create cluster --name "${clusterName}"
44-
else
45-
kind create cluster --name "${clusterName}" --config "${TEST_DIRECTORY}/${clusterConfig}"
43+
if [ "${clusterType}" == "kind" ]; then
44+
if ! kind get clusters | grep -q "${clusterName}"; then
45+
if [ ! -f "${clusterConfig}" ]; then
46+
kind create cluster --name "${clusterName}"
47+
else
48+
kind create cluster --name "${clusterName}" --config "${TEST_DIRECTORY}/${clusterConfig}"
49+
fi
4650
fi
51+
else
52+
echo "Unknown cluster type: \"${clusterType}\""
4753
fi
48-
else
49-
echo "Unknown cluster type: \"${clusterType}\""
5054
fi
5155

5256
#

0 commit comments

Comments
 (0)