-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
92 lines (81 loc) · 2.61 KB
/
Copy pathaction.yml
File metadata and controls
92 lines (81 loc) · 2.61 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: 'StackQL Studios - StackQL Assert'
description: 'run StackQL query to test and audit your infrastructure.'
author: 'Yuncheng Yang, StackQL Studios'
inputs:
auth_obj_path:
description: file path to json object of stackql auth
required: false
auth_str:
description: json string of stackql auth
required: false
test_query:
description: stackql query to be executed
required: false
test_query_file_path:
description: stackql query file to be executed
required: false
expected_rows:
description: expected number of rows from executing test query
required: false
expected_results_str:
description: expected result from executing test query, support json string, overrides expected_results_file_path
required: false
expected_results_file_path:
description: file that stores expected result, json is support
required: false
runs:
using: "composite"
steps:
- name: Check StackQL is installed and set output
id: check-stackql
shell: bash
run: |
if command -v stackql &> /dev/null; then
echo "stackql_installed=true" >> $GITHUB_OUTPUT
else
echo "stackql_installed=false" >> $GITHUB_OUTPUT
fi
- name: Setup StackQL
uses: stackql/setup-stackql@v1.1.0
if: ${{steps.check-stackql.outputs.stackql_installed == 'false'}}
with:
use_wrapper: true
- name: Setup auth
id: setup-auth
uses: actions/github-script@v6
with:
script: |
const {setupAuth} = require('./lib/utils.js')
setupAuth(core)
env:
AUTH_FILE_PATH: ${{ inputs.auth_obj_path }}
AUTH_STR: ${{inputs.auth_str}}
- name: get stackql command
uses: actions/github-script@v6
with:
script: |
const {getStackqlCommand} = require('./lib/utils.js')
getStackqlCommand(core)
env:
QUERY_FILE_PATH: ${{ inputs.test_query_file_path }}
QUERY: ${{inputs.test_query}}
OUTPUT: 'json'
- name: execute stackql command
id: exec-query
shell: bash
run: |
${{ env.STACKQL_COMMAND }}
- name: Check results
uses: actions/github-script@v6
with:
script: |
const {assertResult} = require('./stackql-assert.js')
assertResult(core)
env:
RESULT: ${{steps.exec-query.outputs.stdout}}
EXPECTED_RESULTS_STR: ${{ inputs.expected_results_str }}
EXPECTED_RESULTS_FILE_PATH: ${{inputs.expected_results_file_path}}
EXPECTED_ROWS: ${{inputs.expected_rows}}
branding:
icon: 'terminal'
color: 'green'