Skip to content

Commit a6da884

Browse files
authored
fix(run-integration-test): Correctly parse config options using yq (#22)
1 parent 5901c3b commit a6da884

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

run-integration-test/action.yml

+39-23
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,32 @@ outputs:
2727
runs:
2828
using: composite
2929
steps:
30-
- name: Record Start Time
31-
id: start-time
32-
shell: bash
33-
run: |
34-
echo "START_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" | tee -a "$GITHUB_OUTPUT"
35-
3630
- name: Extract Test and Instance Configuration
3731
env:
3832
TEST_PARAMETER: ${{ inputs.test-parameter }}
3933
TEST_PLATFORM: ${{ inputs.test-platform }}
4034
TEST_RUN: ${{ inputs.test-run }}
35+
GITHUB_DEBUG: ${{ runner.debug }}
4136
shell: bash
4237
run: |
4338
set -euo pipefail
39+
[ -n "$GITHUB_DEBUG" ] && set -x
40+
41+
# Create and enter Python virtual env
42+
python -m venv .venv
43+
. .venv/bin/activate
44+
45+
# Install proper yq
46+
pip install yq==3.4.3
47+
yq --version
4448
4549
#####################################
4650
# Extract Kubernetes-related Values #
4751
#####################################
4852
49-
export KUBERNETES_DISTRIBUTION=$(echo "$TEST_PLATFORM" | cut -d - -f 1)
50-
export KUBERNETES_VERSION=$(echo "$TEST_PLATFORM" | cut -d - -f 2)
51-
export KUBERNETES_ARCHITECTURE=$(echo "$TEST_PLATFORM" | cut -d - -f 3)
53+
KUBERNETES_DISTRIBUTION=$(echo "$TEST_PLATFORM" | cut -d - -f 1)
54+
KUBERNETES_VERSION=$(echo "$TEST_PLATFORM" | cut -d - -f 2)
55+
KUBERNETES_ARCHITECTURE=$(echo "$TEST_PLATFORM" | cut -d - -f 3)
5256
5357
echo "KUBERNETES_DISTRIBUTION=$KUBERNETES_DISTRIBUTION" | tee -a "$GITHUB_ENV"
5458
echo "KUBERNETES_VERSION=$KUBERNETES_VERSION" | tee -a "$GITHUB_ENV"
@@ -58,13 +62,19 @@ runs:
5862
# Extract Instance Configuration #
5963
##################################
6064
61-
export INSTANCE_SIZE=$(yq '.instance-size' -e ./tests/infrastructure.yaml)
62-
INSTANCE_TYPE=$(yq '.[env(KUBERNETES_DISTRIBUTION)].[env(KUBERNETES_ARCHITECTURE)].[env(INSTANCE_SIZE)]' -e "$GITHUB_ACTION_PATH/instances.yml")
65+
INSTANCE_SIZE=$(yq -er '."instance-size"' ./tests/infrastructure.yaml)
66+
INSTANCE_TYPE=$(yq -er \
67+
--arg kubernetes_distribution "$KUBERNETES_DISTRIBUTION" \
68+
--arg kubernetes_architecture "$KUBERNETES_ARCHITECTURE" \
69+
--arg instance_size "$INSTANCE_SIZE" \
70+
'.[$kubernetes_distribution][$kubernetes_architecture][$instance_size]' \
71+
"$GITHUB_ACTION_PATH/instances.yml"
72+
)
6373
6474
# Optional config options
65-
CLUSTER_TTL=$(yq '.cluster-ttl' -e ./tests/infrastructure.yaml || echo "4h")
66-
INSTANCE_NODES=$(yq '.nodes' -e ./tests/infrastructure.yaml || echo "1")
67-
INSTANCE_DISK=$(yq '.disk' -e ./tests/infrastructure.yaml|| echo "50")
75+
CLUSTER_TTL=$(yq -er '."cluster-ttl" // "4h"' ./tests/infrastructure.yaml)
76+
INSTANCE_NODES=$(yq -er '.nodes // 1' ./tests/infrastructure.yaml)
77+
INSTANCE_DISK=$(yq -er '.disk // 50' ./tests/infrastructure.yaml)
6878
6979
echo "INSTANCE_TYPE=$INSTANCE_TYPE" | tee -a "$GITHUB_ENV"
7080
echo "CLUSTER_TTL=$CLUSTER_TTL" | tee -a "$GITHUB_ENV"
@@ -87,9 +97,9 @@ runs:
8797
fi
8898
8999
if [ "$TEST_RUN" == "test-suite" ]; then
90-
yq '.suites[] | select(.name == env(TEST_PARAMETER))' -e ./tests/test-definition.yaml
100+
yq -er --arg test_parameter "$TEST_PARAMETER" '.suites[] | select(.name == $test_parameter)' ./tests/test-definition.yaml
91101
elif [ "$TEST_RUN" == "test" ]; then
92-
yq '.tests[] | select(.name == env(TEST_PARAMETER))' -e ./tests/test-definition.yaml
102+
yq -er --arg test_parameter "$TEST_PARAMETER" '.tests[] | select(.name == $test_parameter)' ./tests/test-definition.yaml
93103
fi
94104
fi
95105
@@ -189,6 +199,12 @@ runs:
189199
sudo apt install -y \
190200
gettext-base
191201
202+
- name: Record Test Start Time
203+
id: start-time
204+
shell: bash
205+
run: |
206+
echo "START_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" | tee -a "$GITHUB_OUTPUT"
207+
192208
- name: Run Integration Test (${{ inputs.test-run }}=${{ inputs.test-parameter }})
193209
env:
194210
REF_NAME: ${{ github.ref_name }}
@@ -206,6 +222,13 @@ runs:
206222
python ./scripts/run-tests --skip-release --log-level debug "--$TEST_RUN" "$TEST_PARAMETER"
207223
fi
208224
225+
- name: Record Test End Time
226+
id: end-time
227+
if: always()
228+
shell: bash
229+
run: |
230+
echo "END_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" | tee -a "$GITHUB_OUTPUT"
231+
209232
- name: Destroy Replicated Cluster
210233
if: env.KUBERNETES_DISTRIBUTION != 'ionos' && always()
211234
# If the creation of the cluster failed, we don't want to error and abort
@@ -215,10 +238,3 @@ runs:
215238
# See: https://github.com/replicatedhq/replicated-actions/tree/main/remove-cluster#inputs
216239
api-token: ${{ inputs.replicated-api-token }}
217240
cluster-id: ${{ steps.prepare-replicated-cluster.outputs.cluster-id }}
218-
219-
- name: Record End Time
220-
id: end-time
221-
if: always()
222-
shell: bash
223-
run: |
224-
echo "END_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" | tee -a "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)