From 101b2761ff2182d16cf412c5e849c95bfab207ec Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Mar 2026 23:16:33 +0000 Subject: [PATCH 1/3] Replace Google Compute instance tests with stable GCS bucket resource Switch all Google test references from google.compute.instances (stackql-integration-tests project, australia-southeast1-a zone) to google.storage.buckets (stackql project, stackql-public-releases bucket). Bucket properties (name, location, locationType) are stable and not subject to instance lifecycle costs. Remove GOOGLE_ZONE variable dependency throughout. https://claude.ai/code/session_019CH6RrcMGtdUafvyVCKCHE --- .github/workflows/stackql-assert-test.yml | 18 ++++++++--------- ...google-example-inline-jsonnet-results.json | 2 +- .../google-example-inline-jsonnet.iql | 9 ++++----- .../workflow_scripts/google-example.iql | 7 ++++--- lib/tests/assert.test.js | 20 +++++++++---------- lib/tests/failed-result.json | 2 +- lib/tests/success-result.json | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/stackql-assert-test.yml b/.github/workflows/stackql-assert-test.yml index e986037..a890773 100644 --- a/.github/workflows/stackql-assert-test.yml +++ b/.github/workflows/stackql-assert-test.yml @@ -33,11 +33,12 @@ jobs: uses: ./ with: test_query: | - SELECT name - FROM google.compute.instances - WHERE project = 'stackql-integration-tests' AND zone = 'australia-southeast1-a' and name = 'stackql-test-001'; + SELECT name, location, locationType + FROM google.storage.buckets + WHERE project = 'stackql' + AND name = 'stackql-public-releases'; expected_rows: 1 - env: + env: GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} # @@ -47,8 +48,8 @@ jobs: uses: ./ with: test_query_file_path: './.github/workflows/workflow_scripts/google-example.iql' - expected_results_str: '[{"name":"stackql-test-001"}]' - env: + expected_results_str: '[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]' + env: GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} # @@ -59,11 +60,10 @@ jobs: 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=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }} - env: + vars: GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }} + env: GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} GOOGLE_PROJECT: ${{ vars.GOOGLE_PROJECT }} - GOOGLE_ZONE: ${{ vars.GOOGLE_ZONE }} # # Example `test_query_file_path` with `expected_rows` supplying `vars` using `jsonnet` config provided using `data_file_path` diff --git a/.github/workflows/workflow_scripts/google-example-inline-jsonnet-results.json b/.github/workflows/workflow_scripts/google-example-inline-jsonnet-results.json index ed8d431..bc57467 100644 --- a/.github/workflows/workflow_scripts/google-example-inline-jsonnet-results.json +++ b/.github/workflows/workflow_scripts/google-example-inline-jsonnet-results.json @@ -1 +1 @@ -[{"name":"stackql-test-001"}] \ No newline at end of file +[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] diff --git a/.github/workflows/workflow_scripts/google-example-inline-jsonnet.iql b/.github/workflows/workflow_scripts/google-example-inline-jsonnet.iql index e42aade..b840d0b 100644 --- a/.github/workflows/workflow_scripts/google-example-inline-jsonnet.iql +++ b/.github/workflows/workflow_scripts/google-example-inline-jsonnet.iql @@ -1,11 +1,10 @@ <<>> -SELECT name -FROM google.compute.instances -WHERE project = '{{ .project }}' and zone = '{{ .zone }}' and name = 'stackql-test-001'; \ No newline at end of file +SELECT name, location, locationType +FROM google.storage.buckets +WHERE project = '{{ .project }}' +AND name = 'stackql-public-releases'; diff --git a/.github/workflows/workflow_scripts/google-example.iql b/.github/workflows/workflow_scripts/google-example.iql index acbed77..4b0b510 100644 --- a/.github/workflows/workflow_scripts/google-example.iql +++ b/.github/workflows/workflow_scripts/google-example.iql @@ -1,3 +1,4 @@ -SELECT name -FROM google.compute.instances -WHERE project = 'stackql-integration-tests' AND zone = 'australia-southeast1-a' AND name = 'stackql-test-001'; \ No newline at end of file +SELECT name, location, locationType +FROM google.storage.buckets +WHERE project = 'stackql' +AND name = 'stackql-public-releases'; diff --git a/lib/tests/assert.test.js b/lib/tests/assert.test.js index 0bd4ffb..3d78484 100644 --- a/lib/tests/assert.test.js +++ b/lib/tests/assert.test.js @@ -3,8 +3,8 @@ const {checkResult, parseResult, assertResult, getExpectedResult} = require('../ describe('parseResult', ()=>{ it('should parsedResult correctly', ()=>{ - const resultString = `[{"name":"stackql-demo-001","status":"TERMINATED"}]` - const expected = [{"name":"stackql-demo-001","status":"TERMINATED"}] + const resultString = `[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]` + const expected = [{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] const actual = parseResult(resultString); expect(actual).toEqual(expected); }) @@ -12,8 +12,8 @@ describe('parseResult', ()=>{ describe('getExpectedResult', ()=>{ it('should return expectedResult when expectedResultStr is passed', ()=>{ - const expectedResultStr = `[{"name":"stackql-demo-001","status":"TERMINATED"}]` - const expectedResult = [{"name":"stackql-demo-001","status":"TERMINATED"}] + const expectedResultStr = `[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]` + const expectedResult = [{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] const actual = getExpectedResult(expectedResultStr, undefined); @@ -22,7 +22,7 @@ describe('getExpectedResult', ()=>{ it('should return expectedResult when expectedResultFilePath is passed', ()=>{ const expectedResultFilePath = 'lib/tests/success-result.json' - const expectedResult = [{"name":"stackql-demo-001","status":"TERMINATED"}] + const expectedResult = [{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] const actual = getExpectedResult(undefined, expectedResultFilePath); @@ -42,7 +42,7 @@ describe('checkResult', () => { core.info.mockClear(); core.error.mockClear(); core.setFailed.mockClear(); - }); + }); it('should return false and log an error when the actual length does not match expected rows', () => { const expectedRows = "3"; @@ -89,8 +89,8 @@ describe('assertResult', ()=>{ let coreObj; const ACTION_ENV = { - RESULT: `[{"name":"stackql-demo-001","status":"TERMINATED"}]`, - EXPECTED_RESULTS_STR: `[{"name":"stackql-demo-001","status":"TERMINATED"}]`, + RESULT: `[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]`, + EXPECTED_RESULTS_STR: `[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]`, EXPECTED_RESULTS_FILE_PATH: 'test.json', EXPECTED_ROWS: 1 } @@ -120,7 +120,7 @@ describe('assertResult', ()=>{ }); it('it should setFailed when actual result is not equal to expected result', () => { - process.env.RESULT= "[{\"name\":\"stackql-demo-001\",\"status\":\"RUNNING\"}]" + process.env.RESULT= "[{\"name\":\"stackql-public-releases\",\"location\":\"EU\",\"locationType\":\"multi-region\"}]" assertResult(coreObj) @@ -185,6 +185,6 @@ describe('assertResult', ()=>{ expect(coreObj.info).toHaveBeenCalledWith(expect.stringContaining('StackQL Assert Successful')) }) - + }) diff --git a/lib/tests/failed-result.json b/lib/tests/failed-result.json index 82e6d31..9d474e3 100644 --- a/lib/tests/failed-result.json +++ b/lib/tests/failed-result.json @@ -1 +1 @@ -[{"name":"stackql-demo-001","status":"RUNNING"}] \ No newline at end of file +[{"name":"stackql-public-releases","location":"EU","locationType":"multi-region"}] diff --git a/lib/tests/success-result.json b/lib/tests/success-result.json index 030276f..bc57467 100644 --- a/lib/tests/success-result.json +++ b/lib/tests/success-result.json @@ -1 +1 @@ -[{"name":"stackql-demo-001","status":"TERMINATED"}] \ No newline at end of file +[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] From 6b2050a3bf3cdd701010639a34db60e07f05a840 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Mar 2026 23:38:49 +0000 Subject: [PATCH 2/3] Fix expected result key ordering to match stackql JSON output stackql serialises JSON keys alphabetically, so expected result strings must use the same order (location, locationType, name) to pass deep equality checks. https://claude.ai/code/session_019CH6RrcMGtdUafvyVCKCHE --- .github/workflows/stackql-assert-test.yml | 2 +- .../google-example-inline-jsonnet-results.json | 2 +- lib/tests/assert.test.js | 16 ++++++++-------- lib/tests/failed-result.json | 2 +- lib/tests/success-result.json | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/stackql-assert-test.yml b/.github/workflows/stackql-assert-test.yml index a890773..4cc9397 100644 --- a/.github/workflows/stackql-assert-test.yml +++ b/.github/workflows/stackql-assert-test.yml @@ -48,7 +48,7 @@ jobs: uses: ./ with: test_query_file_path: './.github/workflows/workflow_scripts/google-example.iql' - expected_results_str: '[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]' + expected_results_str: '[{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}]' env: GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} diff --git a/.github/workflows/workflow_scripts/google-example-inline-jsonnet-results.json b/.github/workflows/workflow_scripts/google-example-inline-jsonnet-results.json index bc57467..b6bd69d 100644 --- a/.github/workflows/workflow_scripts/google-example-inline-jsonnet-results.json +++ b/.github/workflows/workflow_scripts/google-example-inline-jsonnet-results.json @@ -1 +1 @@ -[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] +[{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}] diff --git a/lib/tests/assert.test.js b/lib/tests/assert.test.js index 3d78484..9d5a34d 100644 --- a/lib/tests/assert.test.js +++ b/lib/tests/assert.test.js @@ -3,8 +3,8 @@ const {checkResult, parseResult, assertResult, getExpectedResult} = require('../ describe('parseResult', ()=>{ it('should parsedResult correctly', ()=>{ - const resultString = `[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]` - const expected = [{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] + const resultString = `[{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}]` + const expected = [{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}] const actual = parseResult(resultString); expect(actual).toEqual(expected); }) @@ -12,8 +12,8 @@ describe('parseResult', ()=>{ describe('getExpectedResult', ()=>{ it('should return expectedResult when expectedResultStr is passed', ()=>{ - const expectedResultStr = `[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]` - const expectedResult = [{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] + const expectedResultStr = `[{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}]` + const expectedResult = [{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}] const actual = getExpectedResult(expectedResultStr, undefined); @@ -22,7 +22,7 @@ describe('getExpectedResult', ()=>{ it('should return expectedResult when expectedResultFilePath is passed', ()=>{ const expectedResultFilePath = 'lib/tests/success-result.json' - const expectedResult = [{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] + const expectedResult = [{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}] const actual = getExpectedResult(undefined, expectedResultFilePath); @@ -89,8 +89,8 @@ describe('assertResult', ()=>{ let coreObj; const ACTION_ENV = { - RESULT: `[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]`, - EXPECTED_RESULTS_STR: `[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}]`, + RESULT: `[{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}]`, + EXPECTED_RESULTS_STR: `[{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}]`, EXPECTED_RESULTS_FILE_PATH: 'test.json', EXPECTED_ROWS: 1 } @@ -120,7 +120,7 @@ describe('assertResult', ()=>{ }); it('it should setFailed when actual result is not equal to expected result', () => { - process.env.RESULT= "[{\"name\":\"stackql-public-releases\",\"location\":\"EU\",\"locationType\":\"multi-region\"}]" + process.env.RESULT= "[{\"location\":\"EU\",\"locationType\":\"multi-region\",\"name\":\"stackql-public-releases\"}]" assertResult(coreObj) diff --git a/lib/tests/failed-result.json b/lib/tests/failed-result.json index 9d474e3..f76fe22 100644 --- a/lib/tests/failed-result.json +++ b/lib/tests/failed-result.json @@ -1 +1 @@ -[{"name":"stackql-public-releases","location":"EU","locationType":"multi-region"}] +[{"location":"EU","locationType":"multi-region","name":"stackql-public-releases"}] diff --git a/lib/tests/success-result.json b/lib/tests/success-result.json index bc57467..b6bd69d 100644 --- a/lib/tests/success-result.json +++ b/lib/tests/success-result.json @@ -1 +1 @@ -[{"name":"stackql-public-releases","location":"US","locationType":"multi-region"}] +[{"location":"US","locationType":"multi-region","name":"stackql-public-releases"}] From 192918bcc93d6f65bed8db3dd93dc9221578af3f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Mar 2026 23:44:49 +0000 Subject: [PATCH 3/3] Fix key-order-sensitive comparison and hardcode stable project var assert.js: replace JSON.stringify deep equality with key-sorted comparison so JSON objects match regardless of key order. stackql-assert-test.yml: hardcode GOOGLE_PROJECT=stackql in the inline jsonnet test vars instead of pulling from the repo variable (which still pointed at stackql-integration-tests). https://claude.ai/code/session_019CH6RrcMGtdUafvyVCKCHE --- .github/workflows/stackql-assert-test.yml | 3 +-- lib/assert.js | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stackql-assert-test.yml b/.github/workflows/stackql-assert-test.yml index 4cc9397..d6d615b 100644 --- a/.github/workflows/stackql-assert-test.yml +++ b/.github/workflows/stackql-assert-test.yml @@ -60,10 +60,9 @@ jobs: 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=${{ env.GOOGLE_PROJECT }} + vars: GOOGLE_PROJECT=stackql env: GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} - GOOGLE_PROJECT: ${{ vars.GOOGLE_PROJECT }} # # Example `test_query_file_path` with `expected_rows` supplying `vars` using `jsonnet` config provided using `data_file_path` diff --git a/lib/assert.js b/lib/assert.js index 7c7332e..8f8b126 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -20,6 +20,13 @@ const getExpectedResult = (expectedResultStr, expectedResultFilePath) => { return null; }; +const sortedStringify = (obj) => JSON.stringify(obj, Object.keys(obj).sort()); + +const rowsMatch = (expected, actual) => { + if (expected.length !== actual.length) return false; + return expected.every((expectedRow, i) => sortedStringify(expectedRow) === sortedStringify(actual[i])); +}; + const checkResult = (core, expected, actual, expectedRows) => { const actualLength = actual.length; @@ -28,7 +35,7 @@ const checkResult = (core, expected, actual, expectedRows) => { return false; } - if (expected && JSON.stringify(expected) !== JSON.stringify(actual)) { + if (expected && !rowsMatch(expected, actual)) { core.error(`Expected results do not match actual results.\nExpected: ${JSON.stringify(expected)}\nActual: ${JSON.stringify(actual)}`); return false; }