|
1 |
| -name: 'StackQL Exec Test' |
| 1 | +name: 'stackql query tests' |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
@@ -132,63 +132,53 @@ jobs:
|
132 | 132 | - name: validate stackql outputs
|
133 | 133 | shell: bash
|
134 | 134 | run: |
|
135 |
| - # Test `stackql-command` |
136 |
| - output="${{ steps.stackql-command.outputs.stackql-command-output }}" |
137 |
| - all_passed=true |
138 |
| - echo "$output" | while IFS= read -r line; do |
139 |
| - # Skip empty lines |
140 |
| - if [[ -z "$line" ]]; then |
141 |
| - continue |
142 |
| - fi |
143 |
| - # Validate against a simple keyword presence |
144 |
| - if ! echo "$line" | grep -qi "provider" || ! echo "$line" | grep -qi "version" || ! echo "$line" | grep -qi "successfully installed"; then |
145 |
| - echo "Failed line: $line" |
146 |
| - all_passed=false |
147 |
| - fi |
148 |
| - done |
149 |
| - if [[ "$all_passed" == "false" ]]; then |
150 |
| - echo "One or more lines in the output failed to match the expected format." |
151 |
| - exit 1 |
| 135 | + # Check stackql-command output |
| 136 | + if echo "${{ steps.stackql-command.outputs.stackql-command-output }}" | grep -qE "provider, version 'v[0-9.]+' successfully installed"; then |
| 137 | + echo "stackql-command output is valid." |
152 | 138 | else
|
153 |
| - echo "All lines in the output match the expected format." |
| 139 | + echo "stackql-command output is invalid." |
| 140 | + exit 1 |
154 | 141 | fi
|
155 | 142 |
|
156 |
| - # Test JSON output |
157 |
| - json_output="${{ steps.stackql-query.outputs.stackql-query-results }}" |
158 |
| - if ! echo "$json_output" | jq empty; then |
159 |
| - echo "JSON output is not valid." |
| 143 | + # Check JSON output from stackql-query |
| 144 | + if ! echo "${{ steps.stackql-query.outputs.stackql-query-results }}" | jq empty; then |
| 145 | + echo "JSON output from stackql-query is invalid." |
160 | 146 | exit 1
|
161 | 147 | fi
|
162 | 148 |
|
163 |
| - # Test CSV output |
164 |
| - csv_output="${{ steps.stackql-query-csv-output.outputs.stackql-query-results }}" |
165 |
| - IFS=',' read -ra ADDR <<< "$(echo "$csv_output" | head -n 1)" |
166 |
| - if [ "${ADDR[0]}" != "visibility" ] || [ "${ADDR[1]}" != "number_of_repos" ]; then |
167 |
| - echo "CSV header does not match expected format." |
| 149 | + # Check CSV output from stackql-query-csv-output |
| 150 | + csv_header="${{ steps.stackql-query-csv-output.outputs.stackql-query-results }}" |
| 151 | + if ! echo "$csv_header" | head -n 1 | grep -q "visibility,number_of_repos"; then |
| 152 | + echo "CSV header from stackql-query-csv-output is invalid." |
168 | 153 | exit 1
|
169 | 154 | fi
|
170 | 155 |
|
171 |
| - # Test Table output |
172 |
| - table_output="${{ steps.stackql-query-table-output.outputs.stackql-query-results }}" |
173 |
| - table_header=$(echo "$table_output" | sed -n 2p) |
174 |
| - if [[ "$table_header" != "| visibility | number_of_repos |" ]]; then |
175 |
| - echo "Table header does not match expected format." |
| 156 | + # Check Table output from stackql-query-table-output |
| 157 | + table_header="${{ steps.stackql-query-table-output.outputs.stackql-query-results }}" |
| 158 | + if ! echo "$table_header" | sed -n 2p | grep -q "| visibility | number_of_repos |"; then |
| 159 | + echo "Table header from stackql-query-table-output is invalid." |
176 | 160 | exit 1
|
177 | 161 | fi
|
178 | 162 |
|
179 |
| - # Test Text output (similar to CSV) |
| 163 | + # Check Text output from stackql-query-text-output |
180 | 164 | text_output="${{ steps.stackql-query-text-output.outputs.stackql-query-results }}"
|
181 |
| - IFS=',' read -ra ADDR <<< "$(echo "$text_output" | head -n 1)" |
182 |
| - if [ "${ADDR[0]}" != "visibility" ] || [ "${ADDR[1]}" != "number_of_repos" ]; then |
183 |
| - echo "Text output does not match expected CSV format." |
| 165 | + if ! echo "$text_output" | head -n 1 | grep -q "visibility,number_of_repos"; then |
| 166 | + echo "Text output from stackql-query-text-output is invalid." |
| 167 | + exit 1 |
| 168 | + fi |
| 169 | +
|
| 170 | + # Check outputs from files and variable dependent queries |
| 171 | + if ! echo "${{ steps.stackql-query-file.outputs.stackql-query-results }}" | jq empty; then |
| 172 | + echo "JSON output from stackql-query-file is invalid." |
184 | 173 | exit 1
|
185 | 174 | fi
|
186 | 175 |
|
187 |
| - # Additional tests for JSON outputs from file, with vars, and with data file |
188 |
| - for step_id in stackql-query-file stackql-query-file-with-vars stackql-query-file-with-data-file-and-vars; do |
189 |
| - json_output="${{ steps[step_id].outputs.stackql-query-results }}" |
190 |
| - if ! echo "$json_output" | jq empty; then |
191 |
| - echo "$step_id output is not valid JSON." |
192 |
| - exit 1 |
193 |
| - fi |
194 |
| - done |
| 176 | + if ! echo "${{ steps.stackql-query-file-with-vars.outputs.stackql-query-results }}" | jq empty; then |
| 177 | + echo "JSON output from stackql-query-file-with-vars is invalid." |
| 178 | + exit 1 |
| 179 | + fi |
| 180 | +
|
| 181 | + if ! echo "${{ steps.stackql-query-file-with-data-file-and-vars.outputs.stackql-query-results }}" | jq empty; then |
| 182 | + echo "JSON output from stackql-query-file-with-data-file-and-vars is invalid." |
| 183 | + exit 1 |
| 184 | + fi |
0 commit comments