Skip to content

Commit 1df9021

Browse files
authored
Improve CI testing (#2154)
1 parent ffbae18 commit 1df9021

File tree

12 files changed

+127
-53
lines changed

12 files changed

+127
-53
lines changed

.github/workflows/Build and test.yml

Lines changed: 89 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,33 @@ on:
99
permissions: read-all
1010

1111
jobs:
12-
Build:
12+
verify-formatting:
13+
name: Verify code formatting
14+
permissions:
15+
contents: read
16+
runs-on: blacksmith-4vcpu-ubuntu-2204
17+
steps:
18+
- name: Harden Runner
19+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
20+
with:
21+
egress-policy: audit
22+
23+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
25+
- name: Setup Node
26+
uses: useblacksmith/setup-node@65c6ca86fdeb0ab3d85e78f57e4f6a7e4780b391 # v5.0.4
27+
with:
28+
node-version: '24.x'
29+
30+
- name: Install dependencies
31+
run: yarn install --frozen-lockfile
32+
33+
- name: Verify formatting
34+
run: yarn test-format-all
35+
36+
build:
37+
name: Build from source files
38+
needs: []
1339
permissions:
1440
contents: write
1541
runs-on: blacksmith-4vcpu-ubuntu-2204
@@ -21,34 +47,39 @@ jobs:
2147

2248
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2349

24-
- name: Build from src
50+
- name: Setup Node
2551
uses: useblacksmith/setup-node@65c6ca86fdeb0ab3d85e78f57e4f6a7e4780b391 # v5.0.4
2652
with:
27-
node-version: '22.x'
53+
node-version: '24.x'
54+
55+
- name: Install dependencies
56+
run: yarn install --frozen-lockfile
2857

29-
- run: yarn install --frozen-lockfile
30-
- run: yarn build-only
58+
- name: Build project
59+
run: yarn build-only
3160

3261
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
3362
with:
3463
name: dist
3564
path: dist/
3665

37-
- run: tar -cvf node_modules.tar node_modules
66+
- name: Package node_modules
67+
run: tar --exclude='.cache' -cvf node_modules.tar node_modules
3868

3969
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
4070
with:
4171
name: node_modules
4272
path: node_modules.tar
4373

44-
test_node:
74+
test-suite-node:
75+
name: Test suite for Node
4576
permissions:
4677
contents: read
47-
needs: Build
78+
needs: [build]
4879
runs-on: blacksmith-4vcpu-ubuntu-2204
4980
strategy:
5081
matrix:
51-
node-version: [16.x, 18.x, 20.x, 22.x, 23.x, latest]
82+
node-version: [16.x, 18.x, 20.x, 22.x, 24.x] # Dropped '23.x' (EOL) and 'latest' for stability
5283
steps:
5384
- name: Harden Runner
5485
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
@@ -57,7 +88,7 @@ jobs:
5788

5889
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
5990

60-
- name: Run prod version with Node v${{ matrix.node-version }}
91+
- name: Setup Node
6192
uses: useblacksmith/setup-node@65c6ca86fdeb0ab3d85e78f57e4f6a7e4780b391 # v5.0.4
6293
with:
6394
node-version: ${{ matrix.node-version }}
@@ -72,13 +103,17 @@ jobs:
72103
name: node_modules
73104
path: ./
74105

75-
- run: tar -xvf node_modules.tar
76-
- run: yarn test-only
106+
- name: Unpack node_modules
107+
run: tar -xvf node_modules.tar
77108

78-
test_browser:
109+
- name: Run test suite
110+
run: yarn test-only
111+
112+
test-suite-browser:
113+
name: Test suite for Browser
79114
permissions:
80115
contents: read
81-
needs: Build
116+
needs: [build]
82117
runs-on: blacksmith-4vcpu-ubuntu-2204
83118
steps:
84119
- name: Harden Runner
@@ -93,5 +128,43 @@ jobs:
93128
name: dist
94129
path: dist/
95130

96-
- run: echo '::warning ::Not able to automate browser tests yet'
97-
- run: '# yarn test-browser-ci'
131+
- name: Placeholder for browser tests
132+
run: echo '::warning ::Not able to automate browser tests yet'
133+
134+
- name: Run browser tests (disabled)
135+
run: '# yarn test-browser-ci'
136+
137+
verify-parser:
138+
name: Verify grammar vs generated parser
139+
needs: []
140+
permissions:
141+
contents: read
142+
runs-on: blacksmith-4vcpu-ubuntu-2204
143+
steps:
144+
- name: Harden Runner
145+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
146+
with:
147+
egress-policy: audit
148+
149+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
150+
with:
151+
fetch-depth: 0
152+
153+
- name: Get changed files
154+
id: detect-changes
155+
uses: tj-actions/[email protected]
156+
with:
157+
files: src/alasqlparser.jison
158+
159+
- name: Build from src
160+
# This step only runs if the jison file changed
161+
if: steps.detect-changes.outputs.any_changed == 'true'
162+
run: |
163+
yarn install --frozen-lockfile
164+
yarn jison
165+
yarn test
166+
167+
- name: Check generated parser for changes
168+
if: steps.detect-changes.outputs.any_changed == 'true'
169+
run: |
170+
git diff --exit-code -- src/alasqlparser.js || (echo "Please run 'yarn jison && yarn test' and commit again." && exit 1)

.github/workflows/codeql.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
name: 'CodeQL'
1+
name: 'Code quality'
22

33
on:
44
push:
55
branches: ['develop']
6-
pull_request:
7-
branches: ['develop']
86
schedule:
97
- cron: '32 13 * * 0'
108

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Scorecard analysis workflow
1+
name: Scorecard analysis
22
on:
33
push:
44
# Only the default branch is supported.

.husky/pre-commit

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
4-
yarn test-format || (echo please format using 'yarn format' && exit 1)
1+
yarn test-format || (echo please format using 'yarn format' && exit 1)

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"typings": "types/alasql.d.ts",
1515
"scripts": {
1616
"test": "sh build.sh && yarn test-only",
17-
"test-ci": "(yarn test-format || 1) && yarn test && yarn install-g && alasql 'select 1 as Succes'",
17+
"test-ci": "(yarn test-format-all || 1) && yarn test-only && yarn install-g && alasql 'select 1 as Succes'",
1818
"test-only": "node node_modules/mocha/bin/mocha.js ./test --reporter dot",
1919
"#test-only": "(command -v bun && bun node_modules/.bin/mocha ./test --reporter dot) || npx bun node_modules/.bin/mocha ./test --reporter dot",
2020
"test-browser": "node test/browserTestRunner.js 7387",
@@ -27,7 +27,8 @@
2727
"fmt": "yarn pretty-commit --write",
2828
"format": "yarn pretty-since-dev --write",
2929
"format-all": "yarn pretty-all --write",
30-
"test-format": "yarn pretty-since-dev --list-different || echo 'Please correct file formatting using `yarn format` and try again.'",
30+
"test-format": "yarn pretty-since-dev --list-different || (echo 'Please correct file formatting using `yarn format` and try again.' && exit 1)",
31+
"test-format-all": "prettier --list-different '{.,src,test}/*.{js,ts,json}' || (echo 'Please correct file formatting using `yarn format-all` and try again.' && exit 1)",
3132
"pretty-since-dev": "{ git diff --name-only --diff-filter=d origin/develop ; git diff --name-only --diff-filter=d --staged origin/develop ; } | sort | uniq | grep -vE '^dist/|^test/coverage|^lib/|.min.js$' | grep -E '\\.(scss|css|js|ts|vue|json)$' | xargs npx prettier",
3233
"pretty-commit": "{ git diff --name-only --diff-filter=d ; git diff --name-only --diff-filter=d --staged ; } | sort | uniq | grep -vE '^dist/|^test/coverage|^lib/|.min.js$' | grep -E '\\.(scss|css|js|ts|vue|json)$' | xargs npx prettier",
3334
"pretty-all": "git ls-tree --full-tree --name-only -r HEAD | grep -vE '^dist/|^test/coverage|^lib/|.min.js$' | grep -E '\\.(scss|css|js|ts|vue|json)$' | xargs npx prettier",

src/84from.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ alasql.from.JSON = function (filename, opts, cb, idx, query) {
124124
//console.log('cb',cb);
125125
//console.log('JSON');
126126
filename = alasql.utils.autoExtFilename(filename, 'json', opts);
127-
alasql.utils.loadFile(filename, !!cb, function (data) {
127+
(alasql.utils.loadFile(filename, !!cb, function (data) {
128128
// console.log('DATA:'+data);
129129
// res = [{a:1}];
130130
res = JSON.parse(data);
@@ -134,12 +134,12 @@ alasql.from.JSON = function (filename, opts, cb, idx, query) {
134134
}),
135135
err => {
136136
const error = err instanceof Error ? err : new Error(err);
137-
if(query && query.cb) {
137+
if (query && query.cb) {
138138
query.cb(null, error);
139139
return;
140140
}
141141
throw error;
142-
};
142+
});
143143
return res;
144144
};
145145

@@ -168,7 +168,7 @@ const jsonl = ext => {
168168
},
169169
err => {
170170
const error = err instanceof Error ? err : new Error(err);
171-
if(query && query.cb) {
171+
if (query && query.cb) {
172172
query.cb(null, error);
173173
return;
174174
}
@@ -244,7 +244,7 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
244244
return EOF;
245245
}
246246
if (eol) {
247-
return (eol = false), EOL;
247+
return ((eol = false), EOL);
248248
}
249249
var j = I;
250250
if (text.charCodeAt(j) === quoteCode) {

src/alasqlparser.jison

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ Literal
348348
else $$ = $1.toLowerCase();
349349
}
350350
| BRALITERAL
351-
{ $$ = doubleq($1.substr(1,$1.length-2)); }
351+
{ $$ = doubleq($1.substr(1,$1.length-2));}
352352
| error NonReserved
353353
{ $$ = $2.toLowerCase() }
354354
;

src/alasqlparser.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test2112.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ describe('Test 2112 - load binary file', function () {
2020
});
2121

2222
it('C) Loads HTTPS binary file (async)', function (done) {
23-
alasql.utils.loadBinaryFile('https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg', true, function (data) {
24-
assert.equal(data.slice(0, 3), 'ÿØÿ');
25-
done();
26-
});
23+
alasql.utils.loadBinaryFile(
24+
'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg',
25+
true,
26+
function (data) {
27+
assert.equal(data.slice(0, 3), 'ÿØÿ');
28+
done();
29+
}
30+
);
2731
});
2832
});

test/test293.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if (typeof exports === 'object') {
3232
return e(r ^ (t | ~o), n, t, u, c, f);
3333
}
3434
function i(n, r) {
35-
(n[r >> 5] |= 128 << r % 32), (n[(((r + 64) >>> 9) << 4) + 14] = r);
35+
((n[r >> 5] |= 128 << r % 32), (n[(((r + 64) >>> 9) << 4) + 14] = r));
3636
var e,
3737
i,
3838
a,
@@ -43,7 +43,7 @@ if (typeof exports === 'object') {
4343
v = -1732584194,
4444
m = 271733878;
4545
for (e = 0; e < n.length; e += 16)
46-
(i = l),
46+
((i = l),
4747
(a = g),
4848
(h = v),
4949
(d = m),
@@ -114,7 +114,7 @@ if (typeof exports === 'object') {
114114
(l = t(l, i)),
115115
(g = t(g, a)),
116116
(v = t(v, h)),
117-
(m = t(m, d));
117+
(m = t(m, d)));
118118
return [l, g, v, m];
119119
}
120120
function a(n) {
@@ -140,16 +140,16 @@ if (typeof exports === 'object') {
140140
u = [],
141141
c = [];
142142
for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; 16 > r; r += 1)
143-
(u[r] = 909522486 ^ o[r]), (c[r] = 1549556828 ^ o[r]);
144-
return (e = i(u.concat(h(t)), 512 + 8 * t.length)), a(i(c.concat(e), 640));
143+
((u[r] = 909522486 ^ o[r]), (c[r] = 1549556828 ^ o[r]));
144+
return ((e = i(u.concat(h(t)), 512 + 8 * t.length)), a(i(c.concat(e), 640)));
145145
}
146146
function g(n) {
147147
var t,
148148
r,
149149
e = '0123456789abcdef',
150150
o = '';
151151
for (r = 0; r < n.length; r += 1)
152-
(t = n.charCodeAt(r)), (o += e.charAt((t >>> 4) & 15) + e.charAt(15 & t));
152+
((t = n.charCodeAt(r)), (o += e.charAt((t >>> 4) & 15) + e.charAt(15 & t)));
153153
return o;
154154
}
155155
function v(n) {

0 commit comments

Comments
 (0)