From e6ea4c5a904634a30ad25ed9dd68bc38d8a06012 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Tue, 1 Mar 2022 12:34:26 -0500 Subject: [PATCH 1/5] build: Move build related unit test into own job We shouldn't be asserting on built assets (dist/esm) in our unit tests. This helps unblock https://github.com/getsentry/sentry-javascript/pull/4616 --- .github/workflows/build.yml | 6 +++++- packages/utils/.gitignore | 1 + packages/utils/package.json | 3 ++- packages/utils/test/build.test.ts | 23 ----------------------- packages/utils/test/package/build.js | 27 +++++++++++++++++++++++++++ 5 files changed, 35 insertions(+), 25 deletions(-) delete mode 100644 packages/utils/test/build.test.ts create mode 100644 packages/utils/test/package/build.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a430c311a16e..c35da85dd473 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -411,7 +411,11 @@ jobs: with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} - - name: Run build tests + - name: Run browser build tests run: | cd packages/browser yarn test:package + - name: Run utils build tests + run: | + cd packages/utils + yarn test:package diff --git a/packages/utils/.gitignore b/packages/utils/.gitignore index 0bf02553e3a7..211203e7d009 100644 --- a/packages/utils/.gitignore +++ b/packages/utils/.gitignore @@ -1,4 +1,5 @@ *.js.map *.d.ts *.js +!test/package/build.js !.eslintrc.js diff --git a/packages/utils/package.json b/packages/utils/package.json index 5291d8f6eb2e..f18d05a1bd5a 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -45,7 +45,8 @@ "lint:prettier": "prettier --check \"{src,test}/**/*.ts\"", "pack": "npm pack", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "test:package": "node test/package/build.js" }, "volta": { "extends": "../../package.json" diff --git a/packages/utils/test/build.test.ts b/packages/utils/test/build.test.ts deleted file mode 100644 index 22cdbe5c1798..000000000000 --- a/packages/utils/test/build.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; - -const testStrings = [`/// `]; - -describe('build', () => { - test('not contains types', () => { - const paths = [path.join('./dist'), path.join('./esm')]; - paths.forEach(dir => { - if (!fs.existsSync(dir)) { - expect(dir).toBe(`${dir} doesn't exist please build first`); - } - const files = fs.readdirSync(dir); - files.forEach(file => { - if (file.includes('.d.ts')) { - testStrings.forEach(testString => { - expect(fs.readFileSync(path.join(dir, file), 'utf8')).toEqual(expect.not.stringContaining(testString)); - }); - } - }); - }); - }); -}); diff --git a/packages/utils/test/package/build.js b/packages/utils/test/package/build.js new file mode 100644 index 000000000000..62c511d12f16 --- /dev/null +++ b/packages/utils/test/package/build.js @@ -0,0 +1,27 @@ +const fs = require('fs'); +const path = require('path'); + +const testStrings = [`/// `]; + +const paths = [path.join('./dist'), path.join('./esm')]; + +paths.forEach(dir => { + if (!fs.existsSync(dir)) { + // eslint-disable-next-line no-console + console.error(`${dir} doesn't exist please build first`); + process.exit(1); + } + const files = fs.readdirSync(dir); + files.forEach(file => { + if (file.includes('.d.ts')) { + testStrings.forEach(testString => { + const filePath = path.join(dir, file) + if (fs.readFileSync(filePath, 'utf8').includes(testString)) { + // eslint-disable-next-line no-console + console.error(`${filePath} contains types`); + process.exit(1); + } + }); + } + }); +}); From cd2b70edc41d8e102a9a88f857300279bb63ff70 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 3 Mar 2022 08:25:04 -0500 Subject: [PATCH 2/5] delete test --- packages/utils/test/build.test.ts | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 packages/utils/test/build.test.ts diff --git a/packages/utils/test/build.test.ts b/packages/utils/test/build.test.ts deleted file mode 100644 index 3f5184a02063..000000000000 --- a/packages/utils/test/build.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; - -const testStrings = ['/// ']; - -describe('build', () => { - test('not contains types', () => { - const paths = [path.join('./dist'), path.join('./esm')]; - paths.forEach(dir => { - if (!fs.existsSync(dir)) { - expect(dir).toBe(`${dir} doesn't exist please build first`); - } - const files = fs.readdirSync(dir); - files.forEach(file => { - if (file.includes('.d.ts')) { - testStrings.forEach(testString => { - expect(fs.readFileSync(path.join(dir, file), 'utf8')).toEqual(expect.not.stringContaining(testString)); - }); - } - }); - }); - }); -}); From e69c047676a66afd4af8069ff063107fb2a7845d Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 3 Mar 2022 08:26:09 -0500 Subject: [PATCH 3/5] change name --- packages/utils/package.json | 2 +- packages/utils/test/package/build.js | 27 --------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 packages/utils/test/package/build.js diff --git a/packages/utils/package.json b/packages/utils/package.json index f18d05a1bd5a..7277cdc6dbd2 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -46,7 +46,7 @@ "pack": "npm pack", "test": "jest", "test:watch": "jest --watch", - "test:package": "node test/package/build.js" + "test:package": "node test/types/index.js" }, "volta": { "extends": "../../package.json" diff --git a/packages/utils/test/package/build.js b/packages/utils/test/package/build.js deleted file mode 100644 index 62c511d12f16..000000000000 --- a/packages/utils/test/package/build.js +++ /dev/null @@ -1,27 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const testStrings = [`/// `]; - -const paths = [path.join('./dist'), path.join('./esm')]; - -paths.forEach(dir => { - if (!fs.existsSync(dir)) { - // eslint-disable-next-line no-console - console.error(`${dir} doesn't exist please build first`); - process.exit(1); - } - const files = fs.readdirSync(dir); - files.forEach(file => { - if (file.includes('.d.ts')) { - testStrings.forEach(testString => { - const filePath = path.join(dir, file) - if (fs.readFileSync(filePath, 'utf8').includes(testString)) { - // eslint-disable-next-line no-console - console.error(`${filePath} contains types`); - process.exit(1); - } - }); - } - }); -}); From 832cb8aef12a64f5df55b1cb8ddfafb3dd8d375d Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 3 Mar 2022 08:26:39 -0500 Subject: [PATCH 4/5] .gitignore --- packages/utils/.gitignore | 2 +- packages/utils/test/types/index.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 packages/utils/test/types/index.js diff --git a/packages/utils/.gitignore b/packages/utils/.gitignore index 211203e7d009..5c5f1c199d85 100644 --- a/packages/utils/.gitignore +++ b/packages/utils/.gitignore @@ -1,5 +1,5 @@ *.js.map *.d.ts *.js -!test/package/build.js +!test/types/* !.eslintrc.js diff --git a/packages/utils/test/types/index.js b/packages/utils/test/types/index.js new file mode 100644 index 000000000000..62c511d12f16 --- /dev/null +++ b/packages/utils/test/types/index.js @@ -0,0 +1,27 @@ +const fs = require('fs'); +const path = require('path'); + +const testStrings = [`/// `]; + +const paths = [path.join('./dist'), path.join('./esm')]; + +paths.forEach(dir => { + if (!fs.existsSync(dir)) { + // eslint-disable-next-line no-console + console.error(`${dir} doesn't exist please build first`); + process.exit(1); + } + const files = fs.readdirSync(dir); + files.forEach(file => { + if (file.includes('.d.ts')) { + testStrings.forEach(testString => { + const filePath = path.join(dir, file) + if (fs.readFileSync(filePath, 'utf8').includes(testString)) { + // eslint-disable-next-line no-console + console.error(`${filePath} contains types`); + process.exit(1); + } + }); + } + }); +}); From 37e4d32ca4f7f8cde8db312522cfcece2a4513d2 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 3 Mar 2022 09:21:08 -0500 Subject: [PATCH 5/5] lint --- packages/utils/test/types/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/test/types/index.js b/packages/utils/test/types/index.js index 62c511d12f16..6fd6277f70bf 100644 --- a/packages/utils/test/types/index.js +++ b/packages/utils/test/types/index.js @@ -1,7 +1,7 @@ const fs = require('fs'); const path = require('path'); -const testStrings = [`/// `]; +const testStrings = ['/// ']; const paths = [path.join('./dist'), path.join('./esm')];