Skip to content

Commit 6ccc69c

Browse files
cli-api-calls
Summary: - Leverage provider and service docs to make authenticated `any-cli` API calls. - Primitive automated testing derived from and dependent upon approach in core repository.
1 parent b1e0aa7 commit 6ccc69c

File tree

4 files changed

+69
-3
lines changed

4 files changed

+69
-3
lines changed

.github/workflows/build.yml

+51-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ env:
1919
GH_ACCESS_TOKEN: ${{ secrets.ACTIONS_PRIVATE_PACKAGE_SECRET }}
2020
PLANCACHEENABLED: "true"
2121
GOLANG_VERSION: 1.22
22+
STACKQL_CORE_REPOSITORY: ${{ vars.STACKQL_CORE_REPOSITORY != '' && vars.STACKQL_CORE_REPOSITORY || 'stackql/stackql' }}
23+
STACKQL_CORE_REF: ${{ vars.STACKQL_CORE_REF != '' && vars.STACKQL_CORE_REF || 'main' }}
2224

2325
jobs:
2426

@@ -92,6 +94,12 @@ jobs:
9294

9395
- name: Check out code into the Go module directory
9496
uses: actions/checkout@v2
97+
98+
- name: Setup Python
99+
uses: actions/[email protected]
100+
with:
101+
cache: pip
102+
python-version: '3.11'
95103

96104
- name: Get dependencies
97105
run: |
@@ -124,17 +132,57 @@ jobs:
124132
if: success()
125133
run: go test -timeout 240s -v ./...
126134

127-
- name: CLI Test
135+
- name: Trivial CLI Test
128136
if: success()
129137
run: |
130138
sudo apt-get update
131139
sudo apt-get install -y jq
132140
result="$(build/anysdk const | jq -r '.ExtensionKeyAlwaysRequired')"
133141
if [ "$result" != "x-alwaysRequired" ]; then
134-
echo "CLI Test Failed with unexpected result: $result"
142+
echo "Trivial CLI Test Failed with unexpected result: $result"
143+
exit 1
144+
else
145+
echo "Trivial CLI Test passed with expected result: $result"
146+
fi
147+
148+
- name: Download core
149+
uses: actions/checkout@v2
150+
with:
151+
repository: ${{ env.STACKQL_CORE_REPOSITORY }}
152+
ref: ${{ env.STACKQL_CORE_REF }}
153+
path: stackql-core
154+
155+
- name: Create materials for core tests
156+
working-directory: stackql-core
157+
run: |
158+
pip3 install -r cicd/requirements.txt
159+
openssl req -x509 -keyout test/server/mtls/credentials/pg_server_key.pem -out test/server/mtls/credentials/pg_server_cert.pem -config test/server/mtls/openssl.cnf -days 365
160+
openssl req -x509 -keyout test/server/mtls/credentials/pg_client_key.pem -out test/server/mtls/credentials/pg_client_cert.pem -config test/server/mtls/openssl.cnf -days 365
161+
openssl req -x509 -keyout test/server/mtls/credentials/pg_rubbish_key.pem -out test/server/mtls/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
162+
python3 test/python/registry-rewrite.py
163+
164+
- name: Start Core Test Mocks
165+
working-directory: stackql-core
166+
run: |
167+
pgrep -f flask | xargs kill -9
168+
flask --app=./test/python/flask/gcp/app run --cert=./test/server/mtls/credentials/pg_server_cert.pem --key=./test/server/mtls/credentials/pg_server_key.pem --port 1080 &
169+
170+
- name: Run core mocked testing
171+
working-directory: stackql-core
172+
run: |
173+
bucketsListIDs="$(./build/anysdk query \
174+
--svc-file-path="test/registry-mocked/src/googleapis.com/v0.1.2/services/storage-v1.yaml" \
175+
--prov-file-path="test/registry-mocked/src/googleapis.com/v0.1.2/provider.yaml" \
176+
--resource buckets \
177+
--method list \
178+
--parameters '{ "project": "stackql-demo" }' \
179+
| jq -r '.items[].id')"
180+
matchingBuckets="$(echo "${bucketsListIDs}" | grep "stackql-demo" )"
181+
if [ "${matchingBuckets}" = "" ]; then
182+
echo "Core Test Failed with no matchinh buckets"
135183
exit 1
136184
else
137-
echo "CLI Test passed with expected result: $result"
185+
echo "Core Test passed with matching buckets: $matchingBuckets"
138186
fi
139187
140188
macosbuild:

cicd/staging/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!README.md
3+
!.gitignore

cicd/staging/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
## Staging directory
3+
4+
A working directory for download of software for use in CICD.
5+
6+
All items execpt this file should remain `.gitignore`d.
7+

docs/cli.md

+8
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,12 @@ export GOOGLE_CREDENTIALS="$(cat cicd/keys/google-ro-credentials.json)"
4343
| jq -r '.items["zones/us-east7-b"]'
4444

4545

46+
./build/anysdk query \
47+
--svc-file-path="test/tmp/googleapis.com/v24.11.00274/services/storage.yaml" \
48+
--prov-file-path="test/tmp/googleapis.com/v24.11.00274/provider.yaml" \
49+
--resource buckets \
50+
--method list \
51+
--parameters '{ "project": "stackql-demo" }' \
52+
| jq -r '.items[].id'
53+
4654
```

0 commit comments

Comments
 (0)