From c50d3889e215f7e1f050a112ccd33ff5df58f9af Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 09:59:51 -0600 Subject: [PATCH 01/18] use lcov for coverage reporting --- packages/core/.c8rc.json | 3 +-- packages/core/package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/core/.c8rc.json b/packages/core/.c8rc.json index 2d34c12a557..ddda08a8dce 100644 --- a/packages/core/.c8rc.json +++ b/packages/core/.c8rc.json @@ -1,7 +1,6 @@ { - "reporter": "html", + "reporter": "lcov", "all": true, "extension": "mjs", "exclude": ["node_modules/*", "tests"] } - diff --git a/packages/core/package.json b/packages/core/package.json index 5cc0bcd8139..738e3cea774 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -41,7 +41,7 @@ "tips": "node ../../scripts/help.mjs", "lint": "npx eslint 'src/*.mjs' 'tests/*.mjs'", "report": "c8 report", - "testci": "mocha tests/*.test.mjs", + "testci": "c8 mocha tests/*.test.mjs", "prettier": "npx prettier --write 'src/*.mjs' 'tests/*.mjs'", "jsdoc": "jsdoc -c jsdoc.json -r src", "cibuild_step0": "node build.mjs", From ef9eafb3d41bb3b07a8ab78f165a6269927e0087 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 10:18:51 -0600 Subject: [PATCH 02/18] logs for Jaeger --- designs/jaeger/tests/shared.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designs/jaeger/tests/shared.test.mjs b/designs/jaeger/tests/shared.test.mjs index 1b2f47a0dd9..21b61bb69f1 100644 --- a/designs/jaeger/tests/shared.test.mjs +++ b/designs/jaeger/tests/shared.test.mjs @@ -13,4 +13,4 @@ testPatternConfig(Jaeger) testPatternDrafting(Jaeger, false) // Test sampling - Change the second parameter to `true` to log errors -testPatternSampling(Jaeger, false) +testPatternSampling(Jaeger, true) From 29604759f2eb965cbcb3eed13521c460d99de7c1 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 10:27:39 -0600 Subject: [PATCH 03/18] --use-workspaces flag for bootstrapping --- .github/workflows/tests.all.yml | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.all.yml b/.github/workflows/tests.all.yml index 303e999988c..bed71d5f839 100644 --- a/.github/workflows/tests.all.yml +++ b/.github/workflows/tests.all.yml @@ -34,7 +34,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'yarn' - name: Install dependencies - run: npx lerna bootstrap + run: npx lerna bootstrap --use-workspaces env: CI: true - name: Build all diff --git a/package.json b/package.json index 8367b1d5451..84c428541ff 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "tips": "node scripts/help.mjs", "lab": "cd sites/lab && yarn start", "lab-debug": "cd sites/lab && yarn start-debug", - "kickstart": "npx lerna bootstrap && yarn buildall && yarn prepare && yarn tips", - "kickstart:windows": "npx lerna bootstrap && yarn wbuildall && yarn prepare && yarn tips", + "kickstart": "npx lerna bootstrap --use-workspaces && yarn buildall && yarn prepare && yarn tips", + "kickstart:windows": "npx lerna bootstrap --use-workspaces && yarn wbuildall && yarn prepare && yarn tips", "cleanall": "lerna run clean", "test": "lerna run test", "prettier": "npx prettier --write 'config/*' 'config/**/*' 'packages/**/src/*.mjs' 'packages/i18n/src/locales/**/*.*' 'packages/**/tests/*.mjs'", From 62fff1be51764c6d10f43b3a0816eb8d0abaf1a7 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 10:58:43 -0600 Subject: [PATCH 04/18] log settings on sample failure if log===true --- .github/workflows/tests.all.yml | 2 +- package.json | 4 ++-- tests/designs/sampling.mjs | 14 +++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.all.yml b/.github/workflows/tests.all.yml index bed71d5f839..303e999988c 100644 --- a/.github/workflows/tests.all.yml +++ b/.github/workflows/tests.all.yml @@ -34,7 +34,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'yarn' - name: Install dependencies - run: npx lerna bootstrap --use-workspaces + run: npx lerna bootstrap env: CI: true - name: Build all diff --git a/package.json b/package.json index 84c428541ff..8367b1d5451 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "tips": "node scripts/help.mjs", "lab": "cd sites/lab && yarn start", "lab-debug": "cd sites/lab && yarn start-debug", - "kickstart": "npx lerna bootstrap --use-workspaces && yarn buildall && yarn prepare && yarn tips", - "kickstart:windows": "npx lerna bootstrap --use-workspaces && yarn wbuildall && yarn prepare && yarn tips", + "kickstart": "npx lerna bootstrap && yarn buildall && yarn prepare && yarn tips", + "kickstart:windows": "npx lerna bootstrap && yarn wbuildall && yarn prepare && yarn tips", "cleanall": "lerna run clean", "test": "lerna run test", "prettier": "npx prettier --write 'config/*' 'config/**/*' 'packages/**/src/*.mjs' 'packages/i18n/src/locales/**/*.*' 'packages/**/tests/*.mjs'", diff --git a/tests/designs/sampling.mjs b/tests/designs/sampling.mjs index 6b103a0679b..6fec9c6a794 100644 --- a/tests/designs/sampling.mjs +++ b/tests/designs/sampling.mjs @@ -26,23 +26,27 @@ export const testPatternSampling = (Pattern, log = false) => { pattern.sample().render() if (log === 'always') { console.log(pattern.store.logs) - console.log(pattern.setStores[0].logs) + console.log(pattern.setStores[pattern.activeSet].logs) } - if (pattern.store.logs.error.length < 1 && pattern.setStores[0].logs.error.length < 1) { + if ( + pattern.store.logs.error.length < 1 && + pattern.setStores[pattern.activeSet].logs.error.length < 1 + ) { return true } if (log && log !== 'always') { + console.log(pattern.settings[pattern.activeSet]) console.log(pattern.store.logs) - console.log(pattern.setStores[0].logs) + console.log(pattern.setStores[pattern.activeSet].logs) } return false } catch (err) { if (log && log !== 'always') { - console.log(pattern.settings[0]) + console.log(pattern.settings[pattern.activeSet]) console.log(err) console.log(pattern.store.logs) - console.log(pattern.setStores[0].logs) + console.log(pattern.setStores[pattern.activeSet].logs) } return false From d303265f83bac7c698a3a55144ff951172908270 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 11:07:12 -0600 Subject: [PATCH 05/18] upload the correct file to codecov --- .github/workflows/tests.all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.all.yml b/.github/workflows/tests.all.yml index 303e999988c..9132e1e868e 100644 --- a/.github/workflows/tests.all.yml +++ b/.github/workflows/tests.all.yml @@ -44,7 +44,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 with: - files: ./packages/core/coverage/coverage-final.json + files: ./packages/core/coverage/lcov.info flags: core name: codecov-core fail_ci_if_error: true From a52d292131820f72d45a5fbd27a2573f5504006b Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 11:33:32 -0600 Subject: [PATCH 06/18] lint fixes --- designs/jaeger/tests/shared.test.mjs | 2 +- tests/designs/sampling.mjs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/designs/jaeger/tests/shared.test.mjs b/designs/jaeger/tests/shared.test.mjs index 21b61bb69f1..1b2f47a0dd9 100644 --- a/designs/jaeger/tests/shared.test.mjs +++ b/designs/jaeger/tests/shared.test.mjs @@ -13,4 +13,4 @@ testPatternConfig(Jaeger) testPatternDrafting(Jaeger, false) // Test sampling - Change the second parameter to `true` to log errors -testPatternSampling(Jaeger, true) +testPatternSampling(Jaeger, false) diff --git a/tests/designs/sampling.mjs b/tests/designs/sampling.mjs index 6fec9c6a794..c4b833d8a3e 100644 --- a/tests/designs/sampling.mjs +++ b/tests/designs/sampling.mjs @@ -1,5 +1,5 @@ import { adult, doll, giant } from '@freesewing/models' -import { getFamily, getShortName } from './config.mjs' +import { getShortName } from './config.mjs' import chai from 'chai' const expect = chai.expect @@ -15,7 +15,6 @@ const deprecated = ['theo'] * @param boolean log: Set to true to log errors */ export const testPatternSampling = (Pattern, log = false) => { - const pattern = new Pattern() const config = Pattern.patternConfig const design = getShortName(Pattern.designConfig.data.name) //const parts = pattern.getPartList() From a4a13dbc713821974543da341a52e681d3a82444 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 11:34:10 -0600 Subject: [PATCH 07/18] combine terse reporter and failure collector --- scripts/testall.js | 8 +++-- tests/reporters/terse.js | 65 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/scripts/testall.js b/scripts/testall.js index 2df61606b50..88a9f64c6e8 100644 --- a/scripts/testall.js +++ b/scripts/testall.js @@ -4,7 +4,7 @@ const spawn = require('child_process').spawn const projectRoot = path.normalize(path.join(__dirname, '..')) const outputLog = path.join(projectRoot, '.test-failures.log') -const collectorScript = path.join(projectRoot, 'scripts', 'test-failure-collector.js') +const collectorScript = path.join(projectRoot, 'tests', 'reporters', 'terser.js') // Start with a fresh output log on each run. if (fs.existsSync(outputLog)) { @@ -21,8 +21,10 @@ spawn( '--loglevel', 'error', '--', - '--file', - `${collectorScript}`, + // '--reporter', + // 'min' + // '--reporter', + // `${collectorScript}`, '--no-warnings', ], { stdio: 'inherit' } diff --git a/tests/reporters/terse.js b/tests/reporters/terse.js index 17adff765db..33b93ba7fb5 100644 --- a/tests/reporters/terse.js +++ b/tests/reporters/terse.js @@ -1,12 +1,73 @@ const Mocha = require('mocha') -const { EVENT_TEST_FAIL } = Mocha.Runner.constants +const { EVENT_TEST_FAIL, EVENT_TEST_END } = Mocha.Runner.constants + +const path = require('path') +const projectRoot = path.normalize(path.join(__dirname, '..')) +const outputLog = path.join(projectRoot, '.test-failures.log') + +const red = function (string) { + return `\x1b[31m${string}\x1b[0m` +} + +const green = function (string) { + return `\x1b[32m${string}\x1b[0m` +} + +const dim = function (string) { + return `\x1b[2m${string}\x1b[0m` +} + +// Mapping of test file name to array of failing tests. +const failuresPerFile = {} // This output very little info and is intended for CI runs class TerseReporter { constructor(runner) { runner.on(EVENT_TEST_FAIL, (test, err) => { - console.log(` FAIL: ${test.fullTitle()}`) + // output to the console + console.log(`FAIL: ${test.fullTitle()}`) console.log(err) + + failuresPerFile[this.currentTest.file] = failuresPerFile[this.currentTest.file] || [] + failuresPerFile[this.currentTest.file].push(this.currentTest) + }) + + runner.on(EVENT_TEST_END, () => { + if (Object.keys(failuresPerFile).length === 0) return + + const fs = require('fs') + const logger = fs.createWriteStream(outputLog, { flags: 'a' }) + const writeLine = (line) => logger.write(`${line}\n`) + + for (let file in failuresPerFile) { + const failures = failuresPerFile[file] + + // Remove project root from file path to keep log lines shorter. + if (file.startsWith(projectRoot)) { + file = file.substr(projectRoot.length + 1, file.length - projectRoot.length - 1) + } + + // Print each failure. + failures.forEach(function (failure, i) { + const stack = failure.err.stack.split('\n') + writeLine(`${file}: ${i + 1}\) ${failure.title}:`) + writeLine(`${file}:`) + writeLine(`${file}: ${red(stack[0].trim())}`) + writeLine(`${file}: ${green('+ expected')} ${red('- actual')}`) + writeLine(`${file}:`) + writeLine(`${file}: ${red('-' + failure.err.actual)}`) + writeLine(`${file}: ${green('+' + failure.err.expected)}`) + writeLine(`${file}:`) + stack.slice(1).forEach(function (stackLine) { + writeLine(`${file}: ${dim(stackLine.trim())}`) + }) + if (i < failures.length - 1) { + writeLine(`${file}:`) + } + }) + } + + logger.end() }) } } From afcecc50ac634daf260b8474c7314d7133a575cc Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 11:45:38 -0600 Subject: [PATCH 08/18] use correct end hook for reporter --- tests/reporters/terse.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/reporters/terse.js b/tests/reporters/terse.js index 33b93ba7fb5..2f0bf449b84 100644 --- a/tests/reporters/terse.js +++ b/tests/reporters/terse.js @@ -1,5 +1,5 @@ const Mocha = require('mocha') -const { EVENT_TEST_FAIL, EVENT_TEST_END } = Mocha.Runner.constants +const { EVENT_TEST_FAIL, EVENT_RUN_END } = Mocha.Runner.constants const path = require('path') const projectRoot = path.normalize(path.join(__dirname, '..')) @@ -32,7 +32,7 @@ class TerseReporter { failuresPerFile[this.currentTest.file].push(this.currentTest) }) - runner.on(EVENT_TEST_END, () => { + runner.on(EVENT_RUN_END, () => { if (Object.keys(failuresPerFile).length === 0) return const fs = require('fs') From 7742d5cd219b11877153aedb3a82dc027ac72b45 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 11:55:55 -0600 Subject: [PATCH 09/18] cleanup --- scripts/testall.js | 22 +++------------------- tests/reporters/terse.js | 3 ++- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/scripts/testall.js b/scripts/testall.js index 88a9f64c6e8..1f33a7f70d5 100644 --- a/scripts/testall.js +++ b/scripts/testall.js @@ -2,9 +2,7 @@ const fs = require('fs') const path = require('path') const spawn = require('child_process').spawn -const projectRoot = path.normalize(path.join(__dirname, '..')) const outputLog = path.join(projectRoot, '.test-failures.log') -const collectorScript = path.join(projectRoot, 'tests', 'reporters', 'terser.js') // Start with a fresh output log on each run. if (fs.existsSync(outputLog)) { @@ -12,23 +10,9 @@ if (fs.existsSync(outputLog)) { } // Run all tests, specifying the collector script. -spawn( - 'lerna', - [ - 'run', - '--no-bail', - 'testci', - '--loglevel', - 'error', - '--', - // '--reporter', - // 'min' - // '--reporter', - // `${collectorScript}`, - '--no-warnings', - ], - { stdio: 'inherit' } -).on('exit', function (code) { +spawn('lerna', ['run', '--no-bail', 'testci', '--loglevel', 'error', '--', '--no-warnings'], { + stdio: 'inherit', +}).on('exit', function (code) { // If a failure occurred, the log file will have been created. Print it. if (fs.existsSync(outputLog)) { console.error(fs.readFileSync(outputLog, 'utf8').trim()) diff --git a/tests/reporters/terse.js b/tests/reporters/terse.js index 2f0bf449b84..e7cf9b85dfa 100644 --- a/tests/reporters/terse.js +++ b/tests/reporters/terse.js @@ -28,6 +28,7 @@ class TerseReporter { console.log(`FAIL: ${test.fullTitle()}`) console.log(err) + // save for adding to an output file failuresPerFile[this.currentTest.file] = failuresPerFile[this.currentTest.file] || [] failuresPerFile[this.currentTest.file].push(this.currentTest) }) @@ -50,7 +51,7 @@ class TerseReporter { // Print each failure. failures.forEach(function (failure, i) { const stack = failure.err.stack.split('\n') - writeLine(`${file}: ${i + 1}\) ${failure.title}:`) + writeLine(`${file}: ${i + 1}) ${failure.title}:`) writeLine(`${file}:`) writeLine(`${file}: ${red(stack[0].trim())}`) writeLine(`${file}: ${green('+ expected')} ${red('- actual')}`) From 4fbbcebacd52f365fd24c8e2d058c50676876ed4 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 12:00:49 -0600 Subject: [PATCH 10/18] oops, overcleaned --- scripts/testall.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/testall.js b/scripts/testall.js index 1f33a7f70d5..139aa90e519 100644 --- a/scripts/testall.js +++ b/scripts/testall.js @@ -2,6 +2,7 @@ const fs = require('fs') const path = require('path') const spawn = require('child_process').spawn +const projectRoot = path.normalize(path.join(__dirname, '..')) const outputLog = path.join(projectRoot, '.test-failures.log') // Start with a fresh output log on each run. From 4355507c2ba8a9a3c6c9dd4b4aaf4bff40dbec8d Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 12:10:10 -0600 Subject: [PATCH 11/18] don't bootstrap or build for lint workflows --- .github/workflows/lint.all.yml | 6 +----- .github/workflows/lint.diff.yml | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint.all.yml b/.github/workflows/lint.all.yml index 1dba95997d3..4a2ee4f956a 100644 --- a/.github/workflows/lint.all.yml +++ b/.github/workflows/lint.all.yml @@ -25,10 +25,6 @@ jobs: with: node-version: ${{ matrix.node-version }} - name: Install dependencies - run: npx lerna bootstrap - env: - CI: true - - name: Build all - run: npm run buildall + run: npm i -g lerna eslint - name: Run eslint run: npm run lint diff --git a/.github/workflows/lint.diff.yml b/.github/workflows/lint.diff.yml index b1a1e381d85..2dcfb87aa18 100644 --- a/.github/workflows/lint.diff.yml +++ b/.github/workflows/lint.diff.yml @@ -31,11 +31,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - name: Install dependencies - run: npx lerna bootstrap - env: - CI: true - - name: Build all - run: npm run buildall + run: npm i -g lerna eslint - name: Run eslint run: | changed_files="$(git diff --name-only origin/${{ github.base_ref }})" From 6e5805a383cb6eaabb8e9824fb6696dfd99f3efb Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 12:22:45 -0600 Subject: [PATCH 12/18] fine, install dependencies but don't build --- .github/workflows/lint.all.yml | 4 +++- .github/workflows/lint.diff.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.all.yml b/.github/workflows/lint.all.yml index 4a2ee4f956a..d28dee651d1 100644 --- a/.github/workflows/lint.all.yml +++ b/.github/workflows/lint.all.yml @@ -25,6 +25,8 @@ jobs: with: node-version: ${{ matrix.node-version }} - name: Install dependencies - run: npm i -g lerna eslint + run: npx lerna bootstrap + env: + CI: true - name: Run eslint run: npm run lint diff --git a/.github/workflows/lint.diff.yml b/.github/workflows/lint.diff.yml index 2dcfb87aa18..f525ef3a1af 100644 --- a/.github/workflows/lint.diff.yml +++ b/.github/workflows/lint.diff.yml @@ -31,7 +31,9 @@ jobs: with: node-version: ${{ matrix.node-version }} - name: Install dependencies - run: npm i -g lerna eslint + run: npx lerna bootstrap + env: + CI: true - name: Run eslint run: | changed_files="$(git diff --name-only origin/${{ github.base_ref }})" From 375bd4de6e7c88e712b8dd6a714265416a4997c0 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 12:31:41 -0600 Subject: [PATCH 13/18] don't bail on linting --- .github/workflows/lint.diff.yml | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.diff.yml b/.github/workflows/lint.diff.yml index f525ef3a1af..21a7ac1ed24 100644 --- a/.github/workflows/lint.diff.yml +++ b/.github/workflows/lint.diff.yml @@ -18,10 +18,10 @@ jobs: node-version: [16.x] steps: - - name: Fetch PR base ref - uses: actions/checkout@v3 - with: - ref: ${{ github.base_ref }} + # - name: Fetch PR base ref + # uses: actions/checkout@v3 + # with: + # ref: ${{ github.base_ref }} - name: Checkout PR merge ref uses: actions/checkout@v3 with: diff --git a/package.json b/package.json index 8367b1d5451..adf28373469 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "build": "yarn buildall", "wbuild": "yarn wbuildall", "testall": "node scripts/testall.js", - "lint": "lerna run lint -- ", + "lint": "lerna run --no-bail lint -- ", "qa": "yarn qa:prettier && yarn qa:lint", "qa:prettier": "npx prettier", "qa:lint": "npx eslint", From 8e5bf9c6c646ec3875524aa58f4df59b7654f5b8 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 12:40:04 -0600 Subject: [PATCH 14/18] ok, done trying to shave time off these workflows --- .github/workflows/lint.diff.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.diff.yml b/.github/workflows/lint.diff.yml index 21a7ac1ed24..f525ef3a1af 100644 --- a/.github/workflows/lint.diff.yml +++ b/.github/workflows/lint.diff.yml @@ -18,10 +18,10 @@ jobs: node-version: [16.x] steps: - # - name: Fetch PR base ref - # uses: actions/checkout@v3 - # with: - # ref: ${{ github.base_ref }} + - name: Fetch PR base ref + uses: actions/checkout@v3 + with: + ref: ${{ github.base_ref }} - name: Checkout PR merge ref uses: actions/checkout@v3 with: From 72b75765e4ad315219f40c34d719826c89c97212 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 12:48:31 -0600 Subject: [PATCH 15/18] don't fail tests for codecov issues --- .github/workflows/tests.all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.all.yml b/.github/workflows/tests.all.yml index 9132e1e868e..e2021b976b1 100644 --- a/.github/workflows/tests.all.yml +++ b/.github/workflows/tests.all.yml @@ -47,4 +47,4 @@ jobs: files: ./packages/core/coverage/lcov.info flags: core name: codecov-core - fail_ci_if_error: true + fail_ci_if_error: false From 4505e70022135af9e01fcd3bf5587533cd56e799 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 12:53:18 -0600 Subject: [PATCH 16/18] prebuild packages for linting --- .github/workflows/lint.all.yml | 2 ++ .github/workflows/lint.diff.yml | 2 ++ sites/org/package.json | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.all.yml b/.github/workflows/lint.all.yml index d28dee651d1..9233614343f 100644 --- a/.github/workflows/lint.all.yml +++ b/.github/workflows/lint.all.yml @@ -28,5 +28,7 @@ jobs: run: npx lerna bootstrap env: CI: true + - name: Prebuild Packages + run: npx lerna prebuild - name: Run eslint run: npm run lint diff --git a/.github/workflows/lint.diff.yml b/.github/workflows/lint.diff.yml index f525ef3a1af..23752810b31 100644 --- a/.github/workflows/lint.diff.yml +++ b/.github/workflows/lint.diff.yml @@ -34,6 +34,8 @@ jobs: run: npx lerna bootstrap env: CI: true + - name: Prebuild Packages + run: npx lerna prebuild - name: Run eslint run: | changed_files="$(git diff --name-only origin/${{ github.base_ref }})" diff --git a/sites/org/package.json b/sites/org/package.json index ebafe0e8ce6..616ee789350 100644 --- a/sites/org/package.json +++ b/sites/org/package.json @@ -16,7 +16,7 @@ }, "scripts": { "dev": "SITE=org node --experimental-json-modules ./node_modules/.bin/next dev -p 8000", - "prebuild": "SITE=org node ../freesewing.shared/prebuild/index.mjs", + "prebuild": "SITE=org node ../shared/prebuild/index.mjs", "i18n": "SITE=org node ../freesewing.shared/prebuild/i18n-only.mjs", "build": "next build", "cibuild": "yarn prebuild && node --experimental-json-modules ./node_modules/.bin/next build", From 5577c5da33875954aba8ed018ac3da367f030efe Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 12:57:04 -0600 Subject: [PATCH 17/18] lerna *run* prebuild --- .github/workflows/lint.all.yml | 2 +- .github/workflows/lint.diff.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.all.yml b/.github/workflows/lint.all.yml index 9233614343f..5420405c8ef 100644 --- a/.github/workflows/lint.all.yml +++ b/.github/workflows/lint.all.yml @@ -29,6 +29,6 @@ jobs: env: CI: true - name: Prebuild Packages - run: npx lerna prebuild + run: npx lerna run prebuild - name: Run eslint run: npm run lint diff --git a/.github/workflows/lint.diff.yml b/.github/workflows/lint.diff.yml index 23752810b31..9ac4e06dcbb 100644 --- a/.github/workflows/lint.diff.yml +++ b/.github/workflows/lint.diff.yml @@ -35,7 +35,7 @@ jobs: env: CI: true - name: Prebuild Packages - run: npx lerna prebuild + run: npx lerna run prebuild - name: Run eslint run: | changed_files="$(git diff --name-only origin/${{ github.base_ref }})" From 7fa5c16e4fdb3e39ea096c2623d72abe63cb9c47 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Wed, 16 Nov 2022 15:19:59 -0600 Subject: [PATCH 18/18] final cleanup --- config/scripts.yaml | 3 +- packages/rehype-highlight-lines/package.json | 2 +- scripts/test-failure-collector.js | 69 -------------------- 3 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 scripts/test-failure-collector.js diff --git a/config/scripts.yaml b/config/scripts.yaml index b5c78fc4293..95278c0d388 100644 --- a/config/scripts.yaml +++ b/config/scripts.yaml @@ -20,7 +20,7 @@ _types: core: report: 'c8 report' test: 'c8 mocha tests/*.test.mjs' - testci: 'mocha tests/*.test.mjs' + testci: 'c8 mocha tests/*.test.mjs' prettier: "npx prettier --write 'src/*.mjs' 'tests/*.mjs'" lint: "npx eslint 'src/*.mjs' 'tests/*.mjs'" jsdoc: 'jsdoc -c jsdoc.json -r src' @@ -41,6 +41,7 @@ rehype-highlight-lines: build: '!' mbuild: '!' vbuild: '!' + lint: "npx eslint 'src/*.mjs'" rehype-jargon: lint: "npx eslint 'src/*.mjs'" snapseries: diff --git a/packages/rehype-highlight-lines/package.json b/packages/rehype-highlight-lines/package.json index f2f6ac4ce0c..09938ee63e9 100644 --- a/packages/rehype-highlight-lines/package.json +++ b/packages/rehype-highlight-lines/package.json @@ -28,7 +28,7 @@ "test": "echo \"rehype-highlight-lines: No tests configured. Perhaps you could write some?\" && exit 0", "lab": "cd ../../sites/lab && yarn start", "tips": "node ../../scripts/help.mjs", - "lint": "npx eslint 'src/**' 'tests/*.mjs'" + "lint": "npx eslint 'src/*.mjs'" }, "peerDependencies": {}, "dependencies": { diff --git a/scripts/test-failure-collector.js b/scripts/test-failure-collector.js deleted file mode 100644 index 65f778f2bcd..00000000000 --- a/scripts/test-failure-collector.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Used to collect test failures in a file. Use by specifying --file to Mocha. - * - * See https://mochajs.org/#command-line-usage - */ - -const path = require('path'); -const projectRoot = path.normalize(path.join(__dirname, '..')); -const outputLog = path.join(projectRoot, '.test-failures.log'); - -const red = function(string) { - return `\x1b[31m${string}\x1b[0m`; -}; - -const green = function(string) { - return `\x1b[32m${string}\x1b[0m`; -}; - -const dim = function(string) { - return `\x1b[2m${string}\x1b[0m`; -}; - -// Mapping of test file name to array of failing tests. -const failuresPerFile = {}; - -afterEach(function () { - if (this.currentTest.state === "failed") { - failuresPerFile[this.currentTest.file] = failuresPerFile[this.currentTest.file] || []; - failuresPerFile[this.currentTest.file].push(this.currentTest); - } -}); - -after(function () { - if (Object.keys(failuresPerFile).length === 0) return; - - const fs = require('fs') - const logger = fs.createWriteStream(outputLog, { flags: 'a' }); - const writeLine = (line) => logger.write(`${line}\n`); - - for (let file in failuresPerFile) { - const failures = failuresPerFile[file]; - - // Remove project root from file path to keep log lines shorter. - if (file.startsWith(projectRoot)) { - file = file.substr(projectRoot.length + 1, file.length - projectRoot.length - 1) - } - - // Print each failure. - failures.forEach(function (failure, i) { - const stack = failure.err.stack.split('\n'); - writeLine(`${file}: ${i + 1}\) ${failure.title}:`); - writeLine(`${file}:`); - writeLine(`${file}: ${red(stack[0].trim())}`); - writeLine(`${file}: ${green('+ expected')} ${red('- actual')}`); - writeLine(`${file}:`); - writeLine(`${file}: ${red("-" + failure.err.actual)}`); - writeLine(`${file}: ${green("+" + failure.err.expected)}`); - writeLine(`${file}:`); - stack.slice(1).forEach(function (stackLine) { - writeLine(`${file}: ${dim(stackLine.trim())}`); - }); - if (i < failures.length - 1) { - writeLine(`${file}:`); - } - }); - } - - logger.end(); -});