Skip to content

Commit f4f68cd

Browse files
recovered the install wrapper code, added condition step of prep google creds in windows
1 parent 7faf95e commit f4f68cd

4 files changed

Lines changed: 141 additions & 10 deletions

File tree

.github/workflows/setup-stackql.yml

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defaults:
1212
shell: bash
1313

1414
jobs:
15-
stackql-test-matrix:
15+
stackql-test-matrix-no-wrapper:
1616
name: Stackql Local Run ${{ matrix.os }}
1717
runs-on: ${{ matrix.os }}
1818
strategy:
@@ -37,19 +37,70 @@ jobs:
3737
STACKQL_GITHUB_CREDS: ${{ secrets.STACKQL_GITHUB_CREDS }}
3838

3939
- name: Prep Google Creds (Windows)
40+
if: ${{ matrix.os }} == 'windows-latest'
4041
run: | ## use the secret to create json file
4142
$GoogleCreds = [System.Environment]::GetEnvironmentVariable("GOOGLE_CREDS_ENV")
4243
$GoogleCredsDecoded = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($GoogleCreds))
4344
Write-Output $GoogleCredsDecoded | Set-Content sa-key.json
4445
shell: pwsh
4546
env:
4647
GOOGLE_CREDS_ENV: ${{ secrets.GOOGLE_CREDS }}
48+
49+
- name: Prep Google Creds (bash)
50+
if: ${{ matrix.os }} != 'windows-latest'
51+
run: | ## use the secret to create json file
52+
sudo echo ${{ secrets.GOOGLE_CREDS }} | base64 -d > sa-key.json
4753
4854
- name: Use Google Provider
4955
run: |
5056
stackql exec -i ./examples/google-example.iql --auth='{ "google": { "type": "service_account", "credentialsfilepath": "sa-key.json" }}'
5157
52-
##### uncomment the step to see error handling
53-
# - name: Handle error
54-
# run: | ## use the secret to create json file
55-
# stackql exec -i ./examples/github-example.iql --auth="${INVALID_AUTH}"
58+
stackql-test-matrix-with-wrapper:
59+
name: Stackql Local Run ${{ matrix.os }}
60+
runs-on: ${{ matrix.os }}
61+
strategy:
62+
matrix:
63+
os: [ubuntu-latest, windows-latest, macos-latest]
64+
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v3
68+
69+
- name: Setup Stackql
70+
uses: ./
71+
with:
72+
use_wrapper: 'true'
73+
74+
- name: Validate Stackql Version
75+
run: |
76+
stackql --version
77+
78+
- name: Use GitHub Provider
79+
run: |
80+
stackql exec -i ./examples/github-example.iql --auth='{ "github": { "type": "basic", "credentialsenvvar": "STACKQL_GITHUB_CREDS" } }'
81+
env:
82+
STACKQL_GITHUB_CREDS: ${{ secrets.STACKQL_GITHUB_CREDS }}
83+
84+
- name: Prep Google Creds (Windows)
85+
if: ${{ matrix.os }} == 'windows-latest'
86+
run: | ## use the secret to create json file
87+
$GoogleCreds = [System.Environment]::GetEnvironmentVariable("GOOGLE_CREDS_ENV")
88+
$GoogleCredsDecoded = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($GoogleCreds))
89+
Write-Output $GoogleCredsDecoded | Set-Content sa-key.json
90+
shell: pwsh
91+
env:
92+
GOOGLE_CREDS_ENV: ${{ secrets.GOOGLE_CREDS }}
93+
94+
- name: Prep Google Creds (bash)
95+
if: ${{ matrix.os }} != 'windows-latest'
96+
run: | ## use the secret to create json file
97+
sudo echo ${{ secrets.GOOGLE_CREDS }} | base64 -d > sa-key.json
98+
99+
- name: Use Google Provider
100+
run: |
101+
stackql exec -i ./examples/google-example.iql --auth='{ "google": { "type": "service_account", "credentialsfilepath": "sa-key.json" }}'
102+
103+
#### uncomment the step to see error handling
104+
- name: Handle error
105+
run: | ## use the secret to create json file
106+
stackql exec -i ./examples/github-example.iql --auth="${INVALID_AUTH}"

action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: 'StackQL Studio - Setup StackQL'
22
description: 'Sets up the StackQL CLI in your GitHub Actions workflow.'
33
author: 'Yuncheng Yang, StackQL Studios'
4-
inputs: {}
5-
# use_wrapper:
6-
# description: 'Whether or not to install a wrapper to wrap subsequent calls of the `stackql` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.'
7-
# default: 'true'
8-
# required: false
4+
inputs:
5+
use_wrapper:
6+
description: 'Whether or not to install a wrapper to wrap subsequent calls of the `stackql` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.'
7+
default: 'true'
8+
required: false
99

1010
runs:
1111
using: 'node16'

dist/index.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6755,6 +6755,40 @@ async function makeExecutable(cliPath, osPlatform){
67556755
}
67566756
}
67576757

6758+
6759+
async function installWrapper (pathToCLI) {
6760+
let source, target;
6761+
6762+
// If we're on Windows, then the executable ends with .exe
6763+
const exeSuffix = os.platform().startsWith('win') ? '.exe' : '';
6764+
6765+
// Rename stackql(.exe) to stackql-bin(.exe)
6766+
try {
6767+
source = [pathToCLI, `stackql${exeSuffix}`].join(path.sep);
6768+
target = [pathToCLI, `stackql-bin${exeSuffix}`].join(path.sep);
6769+
core.debug(`Moving ${source} to ${target}.`);
6770+
await io.mv(source, target);
6771+
} catch (e) {
6772+
core.debug(`Unable to move ${source} to ${target}.`);
6773+
throw e;
6774+
}
6775+
6776+
// Install our wrapper as stackql by moving the wrapped executable to stackql
6777+
try {
6778+
source = path.resolve([__dirname, '..', 'wrapper', 'dist', 'index.js'].join(path.sep));
6779+
target = [pathToCLI, 'stackql'].join(path.sep);
6780+
core.debug(`Copying ${source} to ${target}.`);
6781+
await io.cp(source, target);
6782+
} catch (e) {
6783+
core.error(`Unable to copy ${source} to ${target}.`);
6784+
throw e;
6785+
}
6786+
6787+
// Export a new environment variable, so our wrapper can locate the binary
6788+
core.exportVariable('STACKQL_CLI_PATH', pathToCLI);
6789+
}
6790+
6791+
67586792
async function setup() {
67596793
try {
67606794

@@ -6778,6 +6812,12 @@ async function setup() {
67786812

67796813
await makeExecutable(cliPath, osPlatform)
67806814

6815+
const wrapper = core.getInput('use_wrapper') === 'true';
6816+
6817+
if(wrapper){
6818+
core.info('installing wrapper')
6819+
await installWrapper(path)
6820+
}
67816821
core.info(`successfully setup stackql at ${cliPath}`);
67826822

67836823
} catch (e) {

index.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,40 @@ async function makeExecutable(cliPath, osPlatform){
5353
}
5454
}
5555

56+
57+
async function installWrapper (pathToCLI) {
58+
let source, target;
59+
60+
// If we're on Windows, then the executable ends with .exe
61+
const exeSuffix = os.platform().startsWith('win') ? '.exe' : '';
62+
63+
// Rename stackql(.exe) to stackql-bin(.exe)
64+
try {
65+
source = [pathToCLI, `stackql${exeSuffix}`].join(path.sep);
66+
target = [pathToCLI, `stackql-bin${exeSuffix}`].join(path.sep);
67+
core.debug(`Moving ${source} to ${target}.`);
68+
await io.mv(source, target);
69+
} catch (e) {
70+
core.debug(`Unable to move ${source} to ${target}.`);
71+
throw e;
72+
}
73+
74+
// Install our wrapper as stackql by moving the wrapped executable to stackql
75+
try {
76+
source = path.resolve([__dirname, '..', 'wrapper', 'dist', 'index.js'].join(path.sep));
77+
target = [pathToCLI, 'stackql'].join(path.sep);
78+
core.debug(`Copying ${source} to ${target}.`);
79+
await io.cp(source, target);
80+
} catch (e) {
81+
core.error(`Unable to copy ${source} to ${target}.`);
82+
throw e;
83+
}
84+
85+
// Export a new environment variable, so our wrapper can locate the binary
86+
core.exportVariable('STACKQL_CLI_PATH', pathToCLI);
87+
}
88+
89+
5690
async function setup() {
5791
try {
5892

@@ -76,6 +110,12 @@ async function setup() {
76110

77111
await makeExecutable(cliPath, osPlatform)
78112

113+
const wrapper = core.getInput('use_wrapper') === 'true';
114+
115+
if(wrapper){
116+
core.info('installing wrapper')
117+
await installWrapper(path)
118+
}
79119
core.info(`successfully setup stackql at ${cliPath}`);
80120

81121
} catch (e) {

0 commit comments

Comments
 (0)