Skip to content

updated command behavior #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 72 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
aa5f1db
updated command behavior
jeffreyaven Apr 25, 2024
2393a35
updated tests
jeffreyaven Apr 25, 2024
fb1d57a
updated tests
jeffreyaven Apr 25, 2024
292cf85
updated tests
jeffreyaven Apr 25, 2024
b48afb5
updated tests
jeffreyaven Apr 25, 2024
1de61c0
updated tests
jeffreyaven Apr 25, 2024
7c0cfcd
updated tests
jeffreyaven Apr 25, 2024
b74d8e1
updated tests
jeffreyaven Apr 25, 2024
23f195b
updated tests
jeffreyaven Apr 25, 2024
c901ccd
updated tests
jeffreyaven Apr 25, 2024
5b3c2d0
updated tests
jeffreyaven Apr 25, 2024
d6fc5aa
updated tests
jeffreyaven Apr 25, 2024
48706d8
windows runner fix
jeffreyaven Apr 25, 2024
08d0b7e
windows runner fix
jeffreyaven Apr 25, 2024
f67f901
windows runner fix
jeffreyaven Apr 25, 2024
a2f4bd8
windows runner fix
jeffreyaven Apr 25, 2024
7c405f1
windows runner fix
jeffreyaven Apr 25, 2024
0e23338
test fix
jeffreyaven Apr 25, 2024
1a307c1
test fix
jeffreyaven Apr 25, 2024
dbfaffd
windows runner fix
jeffreyaven Apr 25, 2024
5e8e87a
windows runner fix
jeffreyaven Apr 25, 2024
ff8f228
windows runner fix
jeffreyaven Apr 25, 2024
ba0c3bf
windows runner fix
jeffreyaven Apr 25, 2024
1156d8e
windows runner fix
jeffreyaven Apr 25, 2024
8294b41
windows runner fix
jeffreyaven Apr 25, 2024
8f814f0
windows runner fix
jeffreyaven Apr 26, 2024
a53c0fa
windows runner fix
jeffreyaven Apr 26, 2024
80326d3
windows runner fix
jeffreyaven Apr 26, 2024
8ad8efb
windows runner fix
jeffreyaven Apr 26, 2024
8ba1c44
windows runner fix
jeffreyaven Apr 26, 2024
e97521f
windows runner fix
jeffreyaven Apr 26, 2024
a91d1bd
windows runner fix
jeffreyaven Apr 26, 2024
67f8576
windows runner fix
jeffreyaven Apr 26, 2024
bf0bb0b
windows runner fix
jeffreyaven Apr 26, 2024
e433137
windows runner fix
jeffreyaven Apr 26, 2024
cbfadbd
windows runner fix
jeffreyaven Apr 26, 2024
bd39b48
windows runner fix
jeffreyaven Apr 26, 2024
99c0940
windows runner fix
jeffreyaven Apr 26, 2024
997df45
windows runner fix
jeffreyaven Apr 26, 2024
eb87424
windows runner fix
jeffreyaven Apr 26, 2024
932bd3b
windows runner fix
jeffreyaven Apr 26, 2024
60d1963
windows runner fix
jeffreyaven Apr 26, 2024
4f35e2c
windows runner fix
jeffreyaven Apr 26, 2024
f5ccebe
windows runner fix
jeffreyaven Apr 26, 2024
092db87
windows runner fix
jeffreyaven Apr 26, 2024
e045850
windows runner fix
jeffreyaven Apr 26, 2024
a856288
windows runner fix
jeffreyaven Apr 26, 2024
e40b929
windows runner fix
jeffreyaven Apr 26, 2024
0fd51f9
windows runner fix
jeffreyaven Apr 26, 2024
d8a5a33
windows runner fix
jeffreyaven Apr 26, 2024
5fca455
windows runner fix
jeffreyaven Apr 26, 2024
c60ae1b
windows runner fix
jeffreyaven Apr 26, 2024
356196a
windows runner fix
jeffreyaven Apr 26, 2024
bae82c5
windows runner fix
jeffreyaven Apr 26, 2024
96d3354
windows runner fix
jeffreyaven Apr 26, 2024
f184252
windows runner fix
jeffreyaven Apr 26, 2024
ff1ec2b
windows runner fix
jeffreyaven Apr 26, 2024
3d4688e
windows runner fix
jeffreyaven Apr 26, 2024
ede3cdb
windows runner fix
jeffreyaven Apr 26, 2024
f57eccb
windows runner fix
jeffreyaven Apr 26, 2024
7678043
windows runner fix
jeffreyaven Apr 26, 2024
cfdd0bb
windows runner fix
jeffreyaven Apr 26, 2024
ea2fbc0
windows runner fix
jeffreyaven Apr 26, 2024
0c31ca3
windows runner fix
jeffreyaven Apr 26, 2024
5052670
windows runner fix
jeffreyaven Apr 26, 2024
c9c40e2
windows runner fix
jeffreyaven Apr 26, 2024
e20d93b
windows runner fix
jeffreyaven Apr 26, 2024
ff01239
windows runner fix
jeffreyaven Apr 26, 2024
68cbe84
windows runner fix
jeffreyaven Apr 26, 2024
38a118f
windows runner fix
jeffreyaven Apr 26, 2024
e0ab1e8
windows runner fix
jeffreyaven Apr 26, 2024
63d7bf9
updated setup-stackql
jeffreyaven Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml → .github/workflows/npm-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Build and Test'
name: 'npm test'
on:
pull_request:

Expand All @@ -7,11 +7,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.3
- name: Use Node.js 16
uses: actions/setup-node@v3
uses: actions/setup-node@v4.0.2
with:
node-version: 16.x
- run: npm ci
- run: npm test

157 changes: 157 additions & 0 deletions .github/workflows/stackql-exec-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: 'stackql query tests'

on:
push:
branches:
- main
pull_request:
jobs:
stackql-exec-google-example:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{matrix.os}}
name: 'StackQL exec Google '

steps:
- name: Checkout
uses: actions/checkout@v4.1.3

#
# run a query that does not return data (using the `is_command` input)
#
- name: pull providers
id: stackql-command
uses: ./
with:
is_command: true
query: "REGISTRY PULL github;
REGISTRY PULL google;"

#
# run a query using the `query` input
#
- name: github query example using the query input
id: stackql-query
uses: ./
with:
query: |
select visibility, count(*) as number_of_repos
from github.repos.repos
where org = 'stackql'
group by visibility
env:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}

# `csv` output
- name: github query example using the query input (csv output)
id: stackql-query-csv-output
uses: ./
with:
query_output: csv
query: |
select visibility, count(*) as number_of_repos
from github.repos.repos
where org = 'stackql'
group by visibility
env:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}

# `table` output
- name: github query example using the query input (table output)
id: stackql-query-table-output
uses: ./
with:
query_output: table
query: |
select visibility, count(*) as number_of_repos
from github.repos.repos
where org = 'stackql'
group by visibility
env:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}

# `text` output
- name: github query example using the query input (text output)
id: stackql-query-text-output
uses: ./
with:
query_output: text
query: |
select visibility, count(*) as number_of_repos
from github.repos.repos
where org = 'stackql'
group by visibility
env:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}

#
# run a query using the `query_file_path` input
#
- name: google query example with query file
id: stackql-query-file
uses: ./
with:
query_file_path: './stackql_scripts/google-instances-by-status.iql'
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}

#
# run a query using the `query_file_path` and `vars` inputs
#
- name: google query example with query file using vars
id: stackql-query-file-with-vars
uses: ./
with:
query_file_path: './stackql_scripts/google-instances-by-status-with-inline-jsonnet-block.iql'
vars: GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }}
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
GOOGLE_PROJECT: ${{ vars.GOOGLE_PROJECT }}
GOOGLE_ZONE: ${{ vars.GOOGLE_ZONE }}

#
# run a query using the `query_file_path`, `data_file_path` and `vars` inputs
#
- name: google query example with query file and data file using vars
id: stackql-query-file-with-data-file-and-vars
uses: ./
with:
query_file_path: './stackql_scripts/google-instances-by-status-with-external-data-file.iql'
data_file_path: './stackql_scripts/google-instances-by-status-with-external-data-file.jsonnet'
vars: GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }}
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
GOOGLE_PROJECT: ${{ vars.GOOGLE_PROJECT }}
GOOGLE_ZONE: ${{ vars.GOOGLE_ZONE }}

- name: validate stackql outputs
shell: bash
run: |
echo "stackql-command:"
echo "${{ steps.stackql-command.outputs.stackql-command-output }}"

echo "stackql-query:"
echo "${{ steps.stackql-query.outputs.stackql-query-results }}"

echo "stackql-query-csv-output:"
echo "${{ steps.stackql-query-csv-output.outputs.stackql-query-results }}"

echo "stackql-query-table-output:"
echo "${{ steps.stackql-query-table-output.outputs.stackql-query-results }}"

echo "stackql-query-text-output:"
echo "${{ steps.stackql-query-text-output.outputs.stackql-query-results }}"

echo "stackql-query-file:"
echo "${{ steps.stackql-query-file.outputs.stackql-query-results }}"

echo "stackql-query-file-with-vars:"
echo "${{ steps.stackql-query-file-with-vars.outputs.stackql-query-results }}"

echo "stackql-query-file-with-data-file-and-vars:"
echo "${{ steps.stackql-query-file-with-data-file-and-vars.outputs.stackql-query-results }}"
106 changes: 0 additions & 106 deletions .github/workflows/stackql-exec.yml

This file was deleted.

26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Authentication to StackQL providers is done via environment variables source fro
- `query_file_path` - stackql query file to execute **(need to supply either `query` or `query_file_path`)**
- `data_file_path` - (optional) path to data file to pass to the stackql query preprocessor (`json` or `jsonnet`)
- `vars` - (optional) comma delimited list of variables to pass to the stackql query preprocessor (supported with `jsonnet` config blocks or `jsonnet` data files only), accepts `var1=val1,var2=val2`, can be used to source environment variables into stackql queries
- `query_output` - (optional) output format of the stackql exec result, accepts `table`, `csv`, `json`, defaults to `json`
- `query_output` - (optional) output format of the stackql exec result, accepts `table`, `csv`, `json` and `text`, defaults to `json`
- `auth_obj_path` - (optional) the path of json file that stores stackql AUTH string **(only required when using non-standard environment variable names)**
- `auth_str` - (optional) stackql AUTH string **(only required when using non-standard environment variable names)**

- `is_command` - (optional defaults to 'false') set to true if the stackql execution is a command that does not return data

## Outputs
This action uses [setup-stackql](https://github.com/marketplace/actions/stackql-studio-setup-stackql), with use_wrapper set
Expand All @@ -27,15 +27,29 @@ to `true`, `stdout` and `stderr` are set to `exec-result` and `exec-error`

### Inline `stackql` query example

this is an example of a command (that does not return data):

```yaml
- name: exec github example
uses: ./
with:
is_command: 'true'
query: "REGISTRY PULL github;
SHOW PROVIDERS;
select total_private_repos
from github.orgs.orgs
where org = 'stackql';"
env:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}
```

this is an example of a query that returns data:

```yaml
- name: exec github example
uses: ./
with:
query: |
select total_private_repos
from github.orgs.orgs
where org = 'stackql'"
env:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}
Expand Down
Loading