Skip to content

Commit ea89d6e

Browse files
committed
trying out the new test workflow
1 parent 4f8ad81 commit ea89d6e

File tree

5 files changed

+148
-10
lines changed

5 files changed

+148
-10
lines changed

.github/workflows/test.js.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# This workflow will do a clean install of node dependencies, build the source
2+
# code and run tests in block on the latest version of node.
3+
4+
name: test
5+
6+
on:
7+
push:
8+
branches:
9+
- new_testsuite
10+
- develop
11+
pull_request:
12+
branches:
13+
- develop
14+
15+
jobs:
16+
setup:
17+
runs-on: ubuntu-latest
18+
name: Compile SRE with locales
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- uses: pnpm/action-setup@v4
24+
name: Install pnpm
25+
with:
26+
version: 10
27+
run_install: false
28+
29+
- name: Setup Speech Rule Engine
30+
run: pnpm i; pnpm build
31+
32+
- name: Upload build
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: sre-library
36+
path: |
37+
lib
38+
js
39+
package.json
40+
41+
test:
42+
strategy:
43+
matrix:
44+
block: [base, walker, semantic, en, en-ssml, ca, de, da, fr, es, it, hi, ko, nb, nn, sv]
45+
needs: setup
46+
runs-on: ubuntu-latest
47+
name: SRE jests tests for ${{ matrix.block }}
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
52+
- uses: pnpm/action-setup@v4
53+
name: Install pnpm
54+
with:
55+
version: 10
56+
run_install: false
57+
58+
- name: Downloading the build
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: sre-library
62+
63+
- name: Set up tests
64+
run: |
65+
pnpm -r i --ignore-scripts
66+
cd testsuite; pnpm build;
67+
68+
- name: Run tests for ${{ matrix.block }}
69+
run: pnpm actionTest tests/actions/${{ matrix.block }}.test.ts
70+
71+
- name: Upload coverage artifact
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: coverage-${{ matrix.block }}
75+
path: coverage
76+
77+
combine-coverage:
78+
# needs: test
79+
runs-on: ubuntu-latest
80+
name: Combine Coverage Reports
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- uses: pnpm/action-setup@v4
85+
name: Install pnpm
86+
with:
87+
version: 10
88+
run_install: false
89+
90+
- name: Install merge tool
91+
run: pnpm add -g nyc
92+
93+
- name: Download all coverage artifacts
94+
uses: actions/download-artifact@v4
95+
with:
96+
path: coverage-artifacts
97+
98+
- name: Merge coverage reports
99+
run: |
100+
mkdir -p combine
101+
cd coverage-artifacts
102+
for i in coverage-*; do cp $i/coverage-final.json ../combine/$i.json; done
103+
cd ..
104+
nyc merge ./combine/ coverage.json
105+
ls -l combine/
106+
ls -l coverage.json
107+
# mkdir -p merged
108+
# ls -l coverage-artifacts/coverage-*/lcov.info
109+
# # find coverage-artifacts -name 'lcov.info' -print -exec cp {} merged/ \;
110+
# # ls -l merged
111+
# lcov-result-merger coverage-artifacts/coverage-*/lcov.info > lcov.info
112+
# # lcov-result-merger merged/*.info > lcov.info
113+
# ls -l lcov.info
114+
115+
- name: Upload final result
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: result
119+
path: coverage.json
120+
121+
# - name: Output coverage summary
122+
# run: |
123+
# pnpm add -g coveralls # optional if uploading
124+
# cat lcov.info
125+
126+
# Optional: Upload to Codecov or Coveralls
127+
- name: Upload to Codecov
128+
uses: codecov/codecov-action@v5
129+
with:
130+
token: ${{ secrets.CODECOV_TOKEN }}
131+
slug: speech-rule-engine/speech-rule-engine
132+
file: coverage.json
133+
name: codecov-$(date +%Y%m%d)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"format-fix": "prettier --write ts/",
1111
"lint": "eslint ts/ --ext .ts,.tsx",
1212
"lint-fix": "eslint ts/ --ext .ts,.tsx --fix",
13-
"test": "cd sre-tests; export SRE_JSON_PATH=../lib/mathmaps; npm run test",
13+
"test": "cd testsuite; export SRE_JSON_PATH=../lib/mathmaps; pnpm test:files",
1414
"docs": "pnpm typedoc --entryPointStrategy ts/",
1515
"commonjs": "pnpm tsc --module commonjs --outDir cjs --moduleResolution node",
1616
"postcommonjs": "node -e 'require(\"fs\").writeFileSync(\"cjs/package.json\", \"{\\n \\\"type\\\": \\\"commonjs\\\"\\n}\\n\");'",
@@ -20,7 +20,7 @@
2020
"pretest": "git submodule update --remote --merge; pnpm compile; cd sre-tests; ln -s .. speech-rule-engine; npm install",
2121
"compile": "pnpm module",
2222
"clean": "rimraf js lib cjs",
23-
"actionTest": "cd sre-tests; export SRE_JSON_PATH=../lib/mathmaps; pnpm jest --silent ",
23+
"actionTest": "cd testsuite; export SRE_JSON_PATH=../lib/mathmaps; pnpm test --silent --coverage",
2424
"cleanAll": "make clean; make clean_min",
2525
"prepublish": "pnpm cleanAll; pnpm buildAll; rimraf js/**/*.js.map cjs/**/*.js.map",
2626
"build": "make -j 12 all; pnpm module; pnpm webpack; pnpm require",

testsuite/jest.config.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ const config = {
2222
rootDir: '..',
2323
preset: tsjest,
2424
clearMocks: true,
25-
collectCoverage: true,
2625
coverageDirectory: 'coverage',
2726
coverageProvider: "v8",
2827
coveragePathIgnorePatterns: ["node_modules", "testsuite"],
28+
testPathIgnorePatterns: [
29+
"tests/json/nemeth",
30+
"tests/actions/nemeth"
31+
],
2932
testEnvironment: "node",
30-
verbose: true,
3133
testMatch: [
3234
"**/tests/**/*.test.ts"
3335
],
@@ -37,7 +39,7 @@ const config = {
3739
}),
3840
setupFiles: ["./lib/require.mjs"],
3941
transform: {
40-
"^.+\\.tsx?$": [ tsjest, { useESM: true } ],
42+
"^.+\\.tsx?$": [ tsjest, { useESM: true, isolatedModules: false } ],
4143
}
4244
};
4345

testsuite/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
},
88
"type": "module",
99
"scripts": {
10+
"=============================================================================== tests": "",
11+
"test:all": "pnpm test:files; pnpm test:output; pnpm test:analytics",
12+
"test:files": "pnpm test --silent --testPathPattern tests/json",
13+
"test:actions": "pnpm test --silent --testPathPattern tests/actions",
14+
"test:output": "pnpm test --silent --testPathPattern tests/output",
15+
"test:analytics": "pnpm rimraf analysis; pnpm test --silent --testPathPattern tests/analyse; pnpm test:allrules",
16+
"test:allrules": "echo \"import('./js/module_loader.js').then((m) => m.loadPromise('at')).then(m => m.default.outputAllRules())\" | node ",
17+
"analyse:tries": "echo \"import('./js/module_loader.js').then((m) => m.loadPromise('atrie')).then(m => m.default.output())\" | node ",
1018
"compile": "pnpm tsc",
1119
"prepare": "node tests.config.js",
1220
"build": "pnpm clean; pnpm prepare && pnpm compile",

ts/speech_generator/speech_generator_util.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ export function nextStyle(node: SemanticNode, options: OptionsList) {
492492
return style;
493493
}
494494

495-
console.log(`${locale} ${domain} ${style}`);
496495
if (domain === 'mathspeak') {
497496
const styles = ['default', 'brief', 'sbrief'];
498497
const index = styles.indexOf(style);
@@ -514,15 +513,11 @@ export function nextStyle(node: SemanticNode, options: OptionsList) {
514513
return x.split('_')[1];
515514
});
516515
const index = options.indexOf(current);
517-
console.log(current);
518516
if (index === -1) {
519-
console.log(31);
520517
return style;
521518
}
522519
const next = index >= options.length - 1 ? options[0] : options[index + 1];
523520
const result = addPreference(style, smart, next);
524-
console.log(32);
525-
console.log(result);
526521
return result;
527522
}
528523
return style;

0 commit comments

Comments
 (0)