Repository navigation
190 lines (172 loc) · 6.22 KB
/
Copy pathstackql-assert-test.yml
File metadata and controls
190 lines (172 loc) · 6.22 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: 'stackql-assert'
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
smoke-tests:
name: Assert smoke (${{ matrix.target.os }}, ${{ matrix.install }})
runs-on: ${{ matrix.target.os }}
strategy:
fail-fast: false
matrix:
target:
- { os: ubuntu-24.04, arch: X64 }
- { os: ubuntu-24.04-arm, arch: ARM64 }
- { os: windows-2025, arch: X64 }
- { os: windows-11-arm, arch: ARM64 }
- { os: macos-15-intel, arch: X64 }
- { os: macos-15, arch: ARM64 }
install: [automatic, wrapped, plain]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Verify runner architecture
env:
EXPECTED_ARCH: ${{ matrix.target.arch }}
run: test "$RUNNER_ARCH" = "$EXPECTED_ARCH"
- name: Preinstall StackQL
if: matrix.install != 'automatic'
uses: stackql/setup-stackql@v2
with:
use_wrapper: ${{ matrix.install == 'wrapped' }}
- name: Assert inline query
uses: ./
with:
test_query: SELECT 1 AS result
expected_rows: 1
- name: Verify native Windows binary architecture
if: runner.os == 'Windows'
shell: pwsh
run: |
$binary = if ($env:STACKQL_CLI_PATH) {
Join-Path $env:STACKQL_CLI_PATH 'stackql-bin.exe'
} else {
(Get-Command stackql.exe).Source
}
$bytes = [IO.File]::ReadAllBytes($binary)
$pe = [BitConverter]::ToInt32($bytes, 0x3c)
$machine = [BitConverter]::ToUInt16($bytes, $pe + 4)
$expected = if ($env:RUNNER_ARCH -eq 'ARM64') { 0xaa64 } else { 0x8664 }
if ($machine -ne $expected) { throw 'Installed binary does not match runner architecture' }
- name: Verify native Linux or macOS binary architecture
if: runner.os != 'Windows'
run: |
binary="$(command -v stackql)"
if [[ -n "${STACKQL_CLI_PATH:-}" ]]; then
binary="$STACKQL_CLI_PATH/stackql-bin"
fi
if [[ "$RUNNER_OS" == 'macOS' ]]; then
arch=x86_64
if [[ "$RUNNER_ARCH" == 'ARM64' ]]; then arch=arm64; fi
lipo "$binary" -verify_arch "$arch"
else
arch='x86-64'
if [[ "$RUNNER_ARCH" == 'ARM64' ]]; then arch='ARM aarch64'; fi
file "$binary" | grep -E "ELF 64-bit.*$arch"
fi
- name: Create query and expected results files
run: |
mkdir -p 'smoke fixtures'
printf '%s\n' 'SELECT 1 AS result;' > 'smoke fixtures/query.iql'
printf '%s\n' 'SELECT 1 AS result WHERE 1 = 0;' > 'smoke fixtures/empty.iql'
printf '%s\n' '[]' > 'smoke fixtures/expected.json'
- name: Assert query file with spaces in its path
uses: ./
with:
test_query_file_path: smoke fixtures/query.iql
expected_rows: 1
- name: Assert empty results string
uses: ./
with:
test_query: SELECT 1 AS result WHERE 1 = 0
expected_results_str: '[]'
expected_rows: 0
- name: Assert expected results file with spaces in its path
uses: ./
with:
test_query_file_path: smoke fixtures/empty.iql
expected_results_file_path: smoke fixtures/expected.json
- name: Reject a mismatching row count
id: mismatch
continue-on-error: true
uses: ./
with:
test_query: SELECT 1 AS result
expected_rows: 2
- name: Verify assertion failed
if: always()
env:
ASSERT_OUTCOME: ${{ steps.mismatch.outcome }}
run: test "$ASSERT_OUTCOME" = 'failure'
stackql-exec-google-example:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm, windows-2025, windows-11-arm, macos-15-intel, macos-15]
runs-on: ${{matrix.os}}
name: 'Assert test '
steps:
- name: Checkout
uses: actions/checkout@v6
#
# Pull required providers
#
- name: pull required providers
uses: stackql/stackql-exec@v2
with:
is_command: true
query: "REGISTRY PULL google; REGISTRY PULL github"
#
# Example `test_query` with `expected_rows`
#
- name: Use test query string and expected rows
uses: ./
with:
test_query: |
SELECT projectId, displayName, state
FROM google.cloudresourcemanager.projects
WHERE projectsId = 'stackql';
expected_rows: 1
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
#
# Example `test_query_file_path` with `expected_results_str`
#
- name: Use test query file and expected result string
uses: ./
with:
test_query_file_path: './.github/workflows/workflow_scripts/google-example.iql'
expected_results_str: '[{"displayName":"stackql","projectId":"stackql","state":"ACTIVE"}]'
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
#
# Example `test_query_file_path` with `expected_results_file_path` supplying `vars` using an inline `jsonnet` config block
#
- name: Use test query file and expected results file path using inline jsonnet config block and external vars
uses: ./
with:
test_query_file_path: './.github/workflows/workflow_scripts/google-example-inline-jsonnet.iql'
expected_results_file_path: './.github/workflows/workflow_scripts/google-example-inline-jsonnet-results.json'
vars: GOOGLE_PROJECT=stackql
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
#
# Example `test_query_file_path` with `expected_rows` supplying `vars` using `jsonnet` config provided using `data_file_path`
#
- name: Use test query file with a jsonnet data file sourcing external vars and an expected row count
uses: ./
with:
test_query_file_path: './.github/workflows/workflow_scripts/github-example.iql'
data_file_path: './.github/workflows/workflow_scripts/github-example-data.jsonnet'
vars: TEST_ORG=${{ env.TEST_ORG }},TEST_REPO=${{ env.TEST_REPO }}
expected_rows: 1
env:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}
TEST_ORG: ${{ vars.TEST_ORG }}
TEST_REPO: ${{ vars.TEST_REPO }}