From 7754a8b50b853f06b44c4a2e80b8b4d377f6d216 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 14:59:29 -0800 Subject: [PATCH 01/45] internal(deps): add deps for ts-node and filesize computation --- package.json | 25 ++++++++++++++------ yarn.lock | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index ad610b062..739b48660 100644 --- a/package.json +++ b/package.json @@ -30,23 +30,29 @@ ], "private": true, "scripts": { - "build": "yarn run babel && yarn run type:dts", - "build-one": "nimbus babel --clean", "babel": "yarn run babel:cjs && yarn run babel:esm", "babel:cjs": "nimbus babel --clean --workspaces=\"@visx/!(demo)\"", "babel:esm": "nimbus babel --clean --workspaces=\"@visx/!(demo)\" --esm", + "build": "yarn run babel && yarn run type", + "build-one": "echo 'build-one has been replaced with build:workspace' & exit 1", + "build:sizes": "yarn run ts ./scripts/computeBuildSizes.ts", + "build:workspace": "nimbus babel --clean", + "check:sizes": "yarn run ts ./scripts/compareBuildSizes.ts", "clean": "rm -rf ./packages/**/{lib,esm}", "format": "yarn run prettier --write", "jest": "NODE_ENV=test nimbus jest --coverage --verbose", "lint": "nimbus eslint", "lint:fix": "yarn run lint --fix", + "prepare-release": "git checkout master && git pull --rebase origin master && lerna updated", "prettier": "nimbus prettier", + "release": "yarn run prepare-release && lerna publish --exact", "setup": "yarn run build", "test": "yarn run jest", - "type:dts": "nimbus typescript --build --reference-workspaces", - "type-one": "nimbus typescript --build", - "prepare-release": "git checkout master && git pull --rebase origin master && lerna updated", - "release": "yarn run prepare-release && lerna publish --exact" + "ts": "ts-node --project ./tsconfig.node.json", + "type": "nimbus typescript --build --reference-workspaces", + "type-one": "echo 'type-one has been replaced with type:workspace' & exit 1", + "type:dts": "echo 'type:dts has been replaced with type' & exit 1", + "type:workspace": "nimbus typescript --build" }, "devDependencies": { "@airbnb/config-babel": "^2.1.3", @@ -60,21 +66,26 @@ "@types/jsdom": "^12.2.4", "@types/react-test-renderer": "^16.9.0", "@types/webpack": "^4.41.17", + "chalk": "4.1.0", "coveralls": "^3.0.6", "enzyme": "^3.10.0", "enzyme-adapter-react-16": "^1.14.0", "enzyme-to-json": "^3.4.0", + "fast-glob": "3.2.5", + "filesize": "6.1.0", "fs-jetpack": "^1.3.0", "husky": "^3.0.0", "jest-mock-console": "^1.0.1", "lerna": "^3.15.0", "marked": "^0.7.0", + "node-fetch": "2.6.1", "raf": "^3.4.0", "react": "^15.0.0-0 || ^16.0.0-0", "react-dom": "^15.0.0-0 || ^16.0.0-0", "react-test-renderer": "^16.8.6", "regenerator-runtime": "^0.10.5", - "timezone-mock": "^1.1.0" + "timezone-mock": "^1.1.0", + "ts-node": "9.1.1" }, "workspaces": [ "./packages/*" diff --git a/yarn.lock b/yarn.lock index a722d2361..f1e3e14c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4404,6 +4404,11 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -5293,6 +5298,14 @@ chalk@4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +chalk@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" + integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" @@ -5944,6 +5957,11 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + cross-fetch@3.0.5: version "3.0.5" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.0.5.tgz#2739d2981892e7ab488a7ad03b92df2816e03f4c" @@ -6534,6 +6552,11 @@ diff-sequences@^25.2.6: resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-25.2.6.tgz#5f467c00edd35352b7bca46d7927d60e687a76dd" integrity sha512-Hq8o7+6GaZeoFjtpgvRBUknSXNeJiCx7V9Fr94ZMljNiCr9n9L8H8aJqgWOQiDDGdyn29fRNcDdRVJ5fdyihfg== +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + diffie-hellman@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" @@ -7536,6 +7559,18 @@ fast-diff@^1.1.2: resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== +fast-glob@3.2.5: + version "3.2.5" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.5.tgz#7939af2a656de79a4f1901903ee8adcaa7cb9661" + integrity sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.0" + merge2 "^1.3.0" + micromatch "^4.0.2" + picomatch "^2.2.1" + fast-glob@^2.2.6: version "2.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" @@ -7633,6 +7668,11 @@ file-uri-to-path@1.0.0: resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== +filesize@6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/filesize/-/filesize-6.1.0.tgz#e81bdaa780e2451d714d71c0d7a4f3238d37ad00" + integrity sha512-LpCHtPQ3sFx67z+uh2HnSyWSLLu5Jxo21795uRDuar/EOuYWXib5EmPaGIBuSnRqH2IODiKA2k5re/K9OnN/Yg== + fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -10214,7 +10254,7 @@ make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0: dependencies: semver "^6.0.0" -make-error@1.x: +make-error@1.x, make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== @@ -10844,6 +10884,11 @@ node-fetch@2.6.0, node-fetch@^2.3.0, node-fetch@^2.5.0: resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== +node-fetch@2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== + node-fetch@^1.0.1: version "1.7.3" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" @@ -13295,7 +13340,7 @@ source-map-resolve@^0.5.0, source-map-resolve@^0.5.2: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.5.6, source-map-support@^0.5.9, source-map-support@~0.5.12: +source-map-support@^0.5.17, source-map-support@^0.5.6, source-map-support@^0.5.9, source-map-support@~0.5.12: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== @@ -14168,6 +14213,18 @@ ts-jest@^24.1.0: semver "^5.5" yargs-parser "10.x" +ts-node@9.1.1: + version "9.1.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.1.1.tgz#51a9a450a3e959401bda5f004a72d54b936d376d" + integrity sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg== + dependencies: + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + source-map-support "^0.5.17" + yn "3.1.1" + ts-pnp@^1.1.6: version "1.2.0" resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92" @@ -14991,6 +15048,11 @@ yargs@^15.3.1: y18n "^4.0.0" yargs-parser "^18.1.1" +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + zip-stream@^4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-4.0.4.tgz#3a8f100b73afaa7d1ae9338d910b321dec77ff3a" From f385cdfd021e6cc36ffd53e1290f33cfe03a909f Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 14:59:50 -0800 Subject: [PATCH 02/45] internal(node): add tsconfig for node --- tsconfig.node.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tsconfig.node.json diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 000000000..e91a0fed0 --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "composite": true, + "declaration": true, + "declarationMap": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "isolatedModules": false, + "jsx": "react", + "lib": ["dom", "esnext"], + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noErrorTruncation": false, + "noImplicitReturns": true, + "noUnusedLocals": true, + "pretty": true, + "removeComments": false, + "strict": true, + "target": "es2015", + "typeRoots": ["./node_modules/@types", "./types"], + "useDefineForClassFields": false + } +} From 6b6700790489d217ce8b5b601eecb64bdf6594e2 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 15:00:41 -0800 Subject: [PATCH 03/45] build: add computeBuildSizes script --- scripts/computeBuildSizes.ts | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 scripts/computeBuildSizes.ts diff --git a/scripts/computeBuildSizes.ts b/scripts/computeBuildSizes.ts new file mode 100644 index 000000000..e48e21a32 --- /dev/null +++ b/scripts/computeBuildSizes.ts @@ -0,0 +1,64 @@ +import fs from 'fs'; +import path from 'path'; +import chalk from 'chalk'; +import glob from 'fast-glob'; + +export const PACKAGE_SIZES_FILENAME = './packageSizes.json'; + +async function getTotalSize(fileGlob: string, cwd: string): Promise { + const files = await glob(fileGlob, { absolute: true, cwd, onlyFiles: true }); + const sizes = await Promise.all( + files.map( + file => + new Promise((resolve, reject) => { + fs.stat(file, (error, stats) => { + if (error) { + reject(error); + } else { + resolve(stats.size); + } + }); + }), + ), + ); + + return sizes.reduce((sum, size) => sum + size, 0); +} + +async function computeBuildSizes() { + const packages = await glob('./packages/*', { absolute: true, onlyDirectories: true }); + const stats: { name: string; sizes: object }[] = []; + + await Promise.all( + packages.map(async packagePath => { + const packageName = path.basename(packagePath); + + stats.push({ + name: packageName, + sizes: { + esm: await getTotalSize('./esm/**/*.js', packagePath), + lib: await getTotalSize('./lib/**/*.js', packagePath), + }, + }); + }), + ); + + // Sort so its deterministic + stats.sort((a, b) => a.name.localeCompare(b.name)); + + // Convert to an object + const sizes = stats.reduce( + (obj, stat) => ({ + ...obj, + [stat.name]: stat.sizes, + }), + {}, + ); + + fs.writeFileSync(PACKAGE_SIZES_FILENAME, JSON.stringify(sizes), 'utf8'); +} + +computeBuildSizes().catch(error => { + console.error(chalk.red(error.message)); + process.exitCode = 1; +}); From 96b1e96e307f3bc337ee3f50b0f983873323a1a6 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 15:01:07 -0800 Subject: [PATCH 04/45] build: add compareBuildSizes, upsertPullRequestComment scripts --- scripts/compareBuildSizes.ts | 122 ++++++++++++++++++++++++++++ scripts/upsertPullRequestComment.ts | 52 ++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 scripts/compareBuildSizes.ts create mode 100644 scripts/upsertPullRequestComment.ts diff --git a/scripts/compareBuildSizes.ts b/scripts/compareBuildSizes.ts new file mode 100644 index 000000000..ef0e2b75b --- /dev/null +++ b/scripts/compareBuildSizes.ts @@ -0,0 +1,122 @@ +import fs from 'fs'; +import size from 'filesize'; +import chalk from 'chalk'; +import fetch from 'node-fetch'; +import upsertPullRequestComment from './upsertPullRequestComment'; +import { PACKAGE_SIZES_FILENAME } from './computeBuildSizes'; + +type StatMap = { + [pkg: string]: { + [dir: string]: number; + }; +}; + +function calculateDiff(prev: number, next: number): number { + return (next - prev) / prev; +} + +function formatDiff(diff: number): string { + const sum = diff * 100; + const percent = sum.toFixed(1); + + // Smaller + if (percent.startsWith('-')) { + return `${sum < -10 ? ':small_red_triangle_down: ' : ''}${percent}%`; + } + + // Larger + return `${sum > 10 ? ':small_red_triangle: ' : ''}+${percent}%`; +} + +async function compareBuildSizes() { + const nextSizes: StatMap = JSON.parse(fs.readFileSync(PACKAGE_SIZES_FILENAME, 'utf8')); + let prevSizes: StatMap = {}; + let sameBuild = false; + + try { + const masterFileSizesRequest = await fetch( + `https://raw.githubusercontent.com/airbnb/visx/master/${PACKAGE_SIZES_FILENAME}`, + ); + + prevSizes = await masterFileSizesRequest.json(); + } catch (error) { + console.log(error.message); + + prevSizes = nextSizes; + sameBuild = true; + } + + function getPrevSize(name: string, type: string) { + return (prevSizes[name] && prevSizes[name][type]) || 0; + } + + const output: string[] = [ + '### Size Changes', + '| Package | Diff | ESM | Prev ESM | CJS | Prev CJS |', + '| --- | ---: | ---: | ---: | ---: | ---: |', + ]; + const rows: string[] = []; + + Object.entries(nextSizes).forEach(([pkgName, stats]) => { + const prevEsm = getPrevSize(pkgName, 'esm'); + const prevLib = getPrevSize(pkgName, 'lib'); + const diff = calculateDiff(prevEsm, stats.esm); + + if (!isFinite(diff) || diff === 0 || diff === 0.0) { + return; + } + + const row = [ + pkgName, + formatDiff(diff), + size(stats.esm), + prevEsm === 0 ? 'N/A' : size(prevEsm), + size(stats.lib), + prevLib === 0 ? 'N/A' : size(prevLib), + ]; + + rows.push(`| ${row.join(' | ')} |`); + }); + + // Don't post anything if no changes + if (rows.length === 0) { + return; + } + + // Sort rows before joining to output + rows.sort(); + + output.push(...rows); + output.push('> Compared to master. File sizes are unminified and ungzipped.'); + + // Show dumps for easier debugging + if (!sameBuild) { + output.push(`
+View raw build stats + +#### Previous (master) +\`\`\`json +${JSON.stringify(prevSizes, null, 2)} +\`\`\` + +#### Current +\`\`\`json +${JSON.stringify(nextSizes, null, 2)} +\`\`\` +
`); + } + + // Leave a comment on the PR + const breakdown = output.join('\n'); + + try { + await upsertPullRequestComment('### Size Changes', breakdown); + } catch { + console.log(breakdown); + } +} + +compareBuildSizes().catch(error => { + console.error(chalk.red(error.message)); + process.exitCode = 1; +}); diff --git a/scripts/upsertPullRequestComment.ts b/scripts/upsertPullRequestComment.ts new file mode 100644 index 000000000..33734d870 --- /dev/null +++ b/scripts/upsertPullRequestComment.ts @@ -0,0 +1,52 @@ +import createGitHubClient from '@airbnb/nimbus/lib/helpers/createGitHubClient'; + +export default async function upsertPullRequestComment(query: string, body: string) { + const { GITHUB_USER, TRAVIS_PULL_REQUEST = 'false', TRAVIS_PULL_REQUEST_SLUG = '' } = process.env; + + if (!TRAVIS_PULL_REQUEST || TRAVIS_PULL_REQUEST === 'false') { + console.log(`No pull request detected (${TRAVIS_PULL_REQUEST}). Avoiding comment.`); + + return; + } + + const [owner, repo] = TRAVIS_PULL_REQUEST_SLUG.split('/'); + const prNumber = Number(TRAVIS_PULL_REQUEST); + const client = createGitHubClient(); + + // Load all comments + const { data: comments } = await client.issues.listComments({ + issue_number: prNumber, + owner, + repo, + }); + + // Find a previously created comment by our bot + const previousComments = comments.filter( + comment => comment.body.includes(query) && comment.user.login === GITHUB_USER, + ); + + // Update existing comment + if (previousComments.length > 0) { + const { id } = previousComments[0]; + + console.log(`Updating comment #${id}`); + + await client.issues.updateComment({ + comment_id: id, + owner, + repo, + body, + }); + + // Insert a new comment + } else { + console.log('Adding a new comment'); + + await client.issues.createComment({ + issue_number: prNumber, + owner, + repo, + body, + }); + } +} From b778c4fb245872839acd458ab74e975ec2e7919e Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 16:29:24 -0800 Subject: [PATCH 05/45] build: update computeBuildSizes output file --- scripts/computeBuildSizes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/computeBuildSizes.ts b/scripts/computeBuildSizes.ts index e48e21a32..4707437bd 100644 --- a/scripts/computeBuildSizes.ts +++ b/scripts/computeBuildSizes.ts @@ -3,7 +3,7 @@ import path from 'path'; import chalk from 'chalk'; import glob from 'fast-glob'; -export const PACKAGE_SIZES_FILENAME = './packageSizes.json'; +export const PACKAGE_SIZES_FILENAME = './packages/sizes.json'; async function getTotalSize(fileGlob: string, cwd: string): Promise { const files = await glob(fileGlob, { absolute: true, cwd, onlyFiles: true }); From 65d7f0bf8032f86df258a123588c4edd9cf27a95 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 16:30:02 -0800 Subject: [PATCH 06/45] build: add deploy-demo script --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 739b48660..d0d172a28 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "babel:esm": "nimbus babel --clean --workspaces=\"@visx/!(demo)\" --esm", "build": "yarn run babel && yarn run type", "build-one": "echo 'build-one has been replaced with build:workspace' & exit 1", + "build:deploy-demo": "cd ./packages/visx-demo/ && yarn deploy", "build:sizes": "yarn run ts ./scripts/computeBuildSizes.ts", "build:workspace": "nimbus babel --clean", "check:sizes": "yarn run ts ./scripts/compareBuildSizes.ts", From 894c50670edb034f7ad3f863c22cff4b70ad879e Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 16:30:39 -0800 Subject: [PATCH 07/45] github(workflows/ci): add Package sizes + Deploy gallery steps --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99af853c6..35aed9121 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,3 +53,12 @@ jobs: HAPPO_API_KEY: ${{ secrets.HAPPO_API_KEY }} HAPPO_API_SECRET: ${{ secrets.HAPPO_API_SECRET }} HAPPO_COMMAND: '../../node_modules/happo.io/build/cli.js' + + - name: Package sizes + run: yarn build:sizes && yarn check:sizes + + - name: Deploy gallery + if: + github.event_name == 'pull_request' && github.event.action == 'closed' && + github.event.pull_request.merged == true + run: yarn build:deploy-demo From cb085cc1ae953959a21ce931185b0abb519a118a Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 17:05:09 -0800 Subject: [PATCH 08/45] github(workflows/ci): add pull_request checks to happo, package sizes --- .github/workflows/ci.yml | 7 +++++-- package.json | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35aed9121..7f5700b5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,7 @@ jobs: run: yarn lint - name: Run happo + if: github.event_name == 'pull_request' run: yarn run happo-ci-github-actions working-directory: './packages/visx-demo/' env: @@ -54,11 +55,13 @@ jobs: HAPPO_API_SECRET: ${{ secrets.HAPPO_API_SECRET }} HAPPO_COMMAND: '../../node_modules/happo.io/build/cli.js' - - name: Package sizes + - name: Report package sizes + if: github.event_name == 'pull_request' run: yarn build:sizes && yarn check:sizes - name: Deploy gallery if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true - run: yarn build:deploy-demo + working-directory: './packages/visx-demo/' + run: yarn deploy diff --git a/package.json b/package.json index d0d172a28..739b48660 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "babel:esm": "nimbus babel --clean --workspaces=\"@visx/!(demo)\" --esm", "build": "yarn run babel && yarn run type", "build-one": "echo 'build-one has been replaced with build:workspace' & exit 1", - "build:deploy-demo": "cd ./packages/visx-demo/ && yarn deploy", "build:sizes": "yarn run ts ./scripts/computeBuildSizes.ts", "build:workspace": "nimbus babel --clean", "check:sizes": "yarn run ts ./scripts/compareBuildSizes.ts", From 06f90a2ff527da2cd3ae1c1c780d7b162d7cfdd7 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 17:31:44 -0800 Subject: [PATCH 09/45] deps(dev): add @types/node-fetch --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 739b48660..222b9d989 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "@types/enzyme": "^3.10.3", "@types/jest": "^24.0.18", "@types/jsdom": "^12.2.4", + "@types/node-fetch": "1.6.9", "@types/react-test-renderer": "^16.9.0", "@types/webpack": "^4.41.17", "chalk": "4.1.0", From 85d18be045efe599a5eb3e8e2c01c88161e79a08 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 17:33:54 -0800 Subject: [PATCH 10/45] deps: update yarn.lock --- yarn.lock | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/yarn.lock b/yarn.lock index f1e3e14c8..22c26a610 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3690,6 +3690,13 @@ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6" integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= +"@types/node-fetch@1.6.9": + version "1.6.9" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-1.6.9.tgz#a750fb0f4cf2960bf72b462e4c86908022dd69c5" + integrity sha512-n2r6WLoY7+uuPT7pnEtKJCmPUGyJ+cbyBR8Avnu4+m1nzz7DwBVuyIvvlBzCZ/nrpC7rIgb3D6pNavL7rFEa9g== + dependencies: + "@types/node" "*" + "@types/node@*", "@types/node@>= 8": version "14.0.9" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.9.tgz#43896ab87fc82bda1dfd600cdf44a0c8a64e11d2" From c05539354d49502c723228d16b6ab764c33f91b2 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 17:57:50 -0800 Subject: [PATCH 11/45] type(scripts/upsertPullRequestComment): fix comment type --- scripts/upsertPullRequestComment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upsertPullRequestComment.ts b/scripts/upsertPullRequestComment.ts index 33734d870..528384446 100644 --- a/scripts/upsertPullRequestComment.ts +++ b/scripts/upsertPullRequestComment.ts @@ -22,7 +22,7 @@ export default async function upsertPullRequestComment(query: string, body: stri // Find a previously created comment by our bot const previousComments = comments.filter( - comment => comment.body.includes(query) && comment.user.login === GITHUB_USER, + (comment: any) => comment.body.includes(query) && comment.user.login === GITHUB_USER, ); // Update existing comment From 6703ca84f989ec986dd74ef22f0b559a9ddd9ff8 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 18:21:03 -0800 Subject: [PATCH 12/45] github(workflows): separate CI into push + pull_request --- .../workflows/{ci.yml => pull_request.yml} | 13 +---- .github/workflows/push.yml | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 12 deletions(-) rename .github/workflows/{ci.yml => pull_request.yml} (79%) create mode 100644 .github/workflows/push.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/pull_request.yml similarity index 79% rename from .github/workflows/ci.yml rename to .github/workflows/pull_request.yml index 7f5700b5a..1aa3b9664 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/pull_request.yml @@ -1,8 +1,6 @@ -name: CI +name: Pull request on: - push: - branches: [master] pull_request: branches: [master] @@ -47,7 +45,6 @@ jobs: run: yarn lint - name: Run happo - if: github.event_name == 'pull_request' run: yarn run happo-ci-github-actions working-directory: './packages/visx-demo/' env: @@ -56,12 +53,4 @@ jobs: HAPPO_COMMAND: '../../node_modules/happo.io/build/cli.js' - name: Report package sizes - if: github.event_name == 'pull_request' run: yarn build:sizes && yarn check:sizes - - - name: Deploy gallery - if: - github.event_name == 'pull_request' && github.event.action == 'closed' && - github.event.pull_request.merged == true - working-directory: './packages/visx-demo/' - run: yarn deploy diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 000000000..4211763e2 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,48 @@ +name: Push + +on: + push: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '12' + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v1 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: yarn install --frozen-lockfile --ignore-engines + + - name: Build packages + run: yarn build + + - name: Commit package sizes + run: | + yarn build:sizes + git config user.name github-actions + git config user.email github-actions@github.com + echo "GITHUB_SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV + yarn add . + git commit -m "build(${GITHUB_SHORT_SHA}): auto-commit package sizes" + git push + + - name: Deploy gallery + working-directory: './packages/visx-demo/' + run: | + git config user.name github-actions + git config user.email github-actions@github.com + yarn deploy From fdcc60282898c82bd74686a381071fd200b286c4 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 18:56:25 -0800 Subject: [PATCH 13/45] deps(dev): add @octokit/rest --- package.json | 1 + yarn.lock | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 222b9d989..315a62391 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "@airbnb/config-prettier": "^2.0.4", "@airbnb/config-typescript": "^2.1.2", "@airbnb/nimbus": "^2.1.3", + "@octokit/rest": "18.1.0", "@types/enzyme": "^3.10.3", "@types/jest": "^24.0.18", "@types/jsdom": "^12.2.4", diff --git a/yarn.lock b/yarn.lock index 22c26a610..b9b949969 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3313,6 +3313,25 @@ dependencies: "@octokit/types" "^4.0.1" +"@octokit/auth-token@^2.4.4": + version "2.4.5" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.5.tgz#568ccfb8cb46f36441fac094ce34f7a875b197f3" + integrity sha512-BpGYsPgJt05M7/L/5FoE1PiAbdxXFZkX/3kDYcsvd1v6UhlnE5e96dTDr0ezX/EFwciQxf3cNV0loipsURU+WA== + dependencies: + "@octokit/types" "^6.0.3" + +"@octokit/core@^3.2.3": + version "3.2.5" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.2.5.tgz#57becbd5fd789b0592b915840855f3a5f233d554" + integrity sha512-+DCtPykGnvXKWWQI0E1XD+CCeWSBhB6kwItXqfFmNBlIlhczuDPbg+P6BtLnVBaRJDAjv+1mrUJuRsFSjktopg== + dependencies: + "@octokit/auth-token" "^2.4.4" + "@octokit/graphql" "^4.5.8" + "@octokit/request" "^5.4.12" + "@octokit/types" "^6.0.3" + before-after-hook "^2.1.0" + universal-user-agent "^6.0.0" + "@octokit/endpoint@^6.0.1": version "6.0.2" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.2.tgz#e876aafe68d7f9b6c6d80bf29458403f9afe7b2b" @@ -3322,6 +3341,20 @@ is-plain-object "^3.0.0" universal-user-agent "^5.0.0" +"@octokit/graphql@^4.5.8": + version "4.6.0" + resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.6.0.tgz#f9abca55f82183964a33439d5264674c701c3327" + integrity sha512-CJ6n7izLFXLvPZaWzCQDjU/RP+vHiZmWdOunaCS87v+2jxMsW9FB5ktfIxybRBxZjxuJGRnxk7xJecWTVxFUYQ== + dependencies: + "@octokit/request" "^5.3.0" + "@octokit/types" "^6.0.3" + universal-user-agent "^6.0.0" + +"@octokit/openapi-types@^4.0.0": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-4.0.1.tgz#bafd3d173974827ba0b733fcca7f1860cb71a9aa" + integrity sha512-k2hRcfcLRyPJjtYfJLzg404n7HZ6sUpAWAR/uNI8tf96NgatWOpw1ocdF+WFfx/trO1ivBh7ckynO1rn+xAw/Q== + "@octokit/plugin-enterprise-rest@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/@octokit/plugin-enterprise-rest/-/plugin-enterprise-rest-6.0.1.tgz#e07896739618dab8da7d4077c658003775f95437" @@ -3334,11 +3367,23 @@ dependencies: "@octokit/types" "^2.0.1" +"@octokit/plugin-paginate-rest@^2.6.2": + version "2.9.1" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.9.1.tgz#e9bb34a89b7ed5b801f1c976feeb9b0078ecd201" + integrity sha512-8wnuWGjwDIEobbBet2xAjZwgiMVTgIer5wBsnGXzV3lJ4yqphLU2FEMpkhSrDx7y+WkZDfZ+V+1cFMZ1mAaFag== + dependencies: + "@octokit/types" "^6.8.0" + "@octokit/plugin-request-log@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e" integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw== +"@octokit/plugin-request-log@^1.0.2": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.3.tgz#70a62be213e1edc04bb8897ee48c311482f9700d" + integrity sha512-4RFU4li238jMJAzLgAwkBAw+4Loile5haQMQr+uhFq27BmyJXcXSKvoQKqh0agsZEiUlW6iSv3FAgvmGkur7OQ== + "@octokit/plugin-rest-endpoint-methods@2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-2.4.0.tgz#3288ecf5481f68c494dd0602fc15407a59faf61e" @@ -3347,6 +3392,14 @@ "@octokit/types" "^2.0.1" deprecation "^2.3.1" +"@octokit/plugin-rest-endpoint-methods@4.10.1": + version "4.10.1" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.10.1.tgz#b7a9181d1f52fef70a13945c5b49cffa51862da1" + integrity sha512-YGMiEidTORzgUmYZu0eH4q2k8kgQSHQMuBOBYiKxUYs/nXea4q/Ze6tDzjcRAPmHNJYXrENs1bEMlcdGKT+8ug== + dependencies: + "@octokit/types" "^6.8.2" + deprecation "^2.3.1" + "@octokit/request-error@^1.0.2": version "1.2.1" resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.2.1.tgz#ede0714c773f32347576c25649dc013ae6b31801" @@ -3379,6 +3432,30 @@ once "^1.4.0" universal-user-agent "^5.0.0" +"@octokit/request@^5.3.0", "@octokit/request@^5.4.12": + version "5.4.14" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.14.tgz#ec5f96f78333bb2af390afa5ff66f114b063bc96" + integrity sha512-VkmtacOIQp9daSnBmDI92xNIeLuSRDOIuplp/CJomkvzt7M18NXgG044Cx/LFKLgjKt9T2tZR6AtJayba9GTSA== + dependencies: + "@octokit/endpoint" "^6.0.1" + "@octokit/request-error" "^2.0.0" + "@octokit/types" "^6.7.1" + deprecation "^2.0.0" + is-plain-object "^5.0.0" + node-fetch "^2.6.1" + once "^1.4.0" + universal-user-agent "^6.0.0" + +"@octokit/rest@18.1.0": + version "18.1.0" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.1.0.tgz#9bf72604911a3433165bcc924263c9a706d32804" + integrity sha512-YQfpTzWV3jdzDPyXQVO54f5I2t1zxk/S53Vbe+Aa5vQj6MdTx6sNEWzmUzUO8lSVowbGOnjcQHzW1A8ATr+/7g== + dependencies: + "@octokit/core" "^3.2.3" + "@octokit/plugin-paginate-rest" "^2.6.2" + "@octokit/plugin-request-log" "^1.0.2" + "@octokit/plugin-rest-endpoint-methods" "4.10.1" + "@octokit/rest@^16.28.4": version "16.43.1" resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.43.1.tgz#3b11e7d1b1ac2bbeeb23b08a17df0b20947eda6b" @@ -3415,6 +3492,14 @@ dependencies: "@types/node" ">= 8" +"@octokit/types@^6.0.3", "@octokit/types@^6.7.1", "@octokit/types@^6.8.0", "@octokit/types@^6.8.2": + version "6.8.2" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.8.2.tgz#ce4872e038d6df38b2d3c21bc12329af0b10facb" + integrity sha512-RpG0NJd7OKSkWptiFhy1xCLkThs5YoDIKM21lEtDmUvSpbaIEfrxzckWLUGDFfF8RydSyngo44gDv8m2hHruUg== + dependencies: + "@octokit/openapi-types" "^4.0.0" + "@types/node" ">= 8" + "@sinonjs/commons@^1.7.0": version "1.8.0" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.0.tgz#c8d68821a854c555bba172f3b06959a0039b236d" @@ -4856,6 +4941,11 @@ before-after-hook@^2.0.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A== +before-after-hook@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.1.tgz#99ae36992b5cfab4a83f6bee74ab27835f28f405" + integrity sha512-5ekuQOvO04MDj7kYZJaMab2S8SPjGJbotVNyv7QYFCOAwrGZs/YnoDNlh1U+m5hl7H2D/+n0taaAV/tfyd3KMA== + big.js@^5.2.2: version "5.2.2" resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" @@ -8986,6 +9076,11 @@ is-plain-object@^3.0.0: dependencies: isobject "^4.0.0" +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== + is-potential-custom-element-name@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz#0c52e54bcca391bb2c494b21e8626d7336c6e397" @@ -10891,7 +10986,7 @@ node-fetch@2.6.0, node-fetch@^2.3.0, node-fetch@^2.5.0: resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== -node-fetch@2.6.1: +node-fetch@2.6.1, node-fetch@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== @@ -14479,6 +14574,11 @@ universal-user-agent@^5.0.0: dependencies: os-name "^3.1.0" +universal-user-agent@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" + integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== + universalify@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" From 1efd7c8ed7d27da60888b91f7bc9a7c1d07165e8 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 18:56:59 -0800 Subject: [PATCH 14/45] fix(workflows/pull_request): add needed variables for upsertPullRequestComment --- .github/workflows/pull_request.yml | 6 ++++++ scripts/upsertPullRequestComment.ts | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1aa3b9664..503f7ca23 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -54,3 +54,9 @@ jobs: - name: Report package sizes run: yarn build:sizes && yarn check:sizes + # this action posts comments on the PR so we need some variables + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ context.issue.number }} + OWNER: ${{ context.repo.owner }} + REPO: ${{ context.repo.repo }} diff --git a/scripts/upsertPullRequestComment.ts b/scripts/upsertPullRequestComment.ts index 528384446..53578bca1 100644 --- a/scripts/upsertPullRequestComment.ts +++ b/scripts/upsertPullRequestComment.ts @@ -1,17 +1,17 @@ -import createGitHubClient from '@airbnb/nimbus/lib/helpers/createGitHubClient'; +import { Octokit } from '@octokit/rest'; -export default async function upsertPullRequestComment(query: string, body: string) { - const { GITHUB_USER, TRAVIS_PULL_REQUEST = 'false', TRAVIS_PULL_REQUEST_SLUG = '' } = process.env; - - if (!TRAVIS_PULL_REQUEST || TRAVIS_PULL_REQUEST === 'false') { - console.log(`No pull request detected (${TRAVIS_PULL_REQUEST}). Avoiding comment.`); +function createGitHubClient(authToken: string) { + return new Octokit({ + auth: `token ${authToken}`, + userAgent: 'visx', + }); +} - return; - } +export default async function upsertPullRequestComment(query: string, body: string) { + const { GITHUB_TOKEN, PR_NUMBER, OWNER: owner, REPO: repo } = process.env; - const [owner, repo] = TRAVIS_PULL_REQUEST_SLUG.split('/'); - const prNumber = Number(TRAVIS_PULL_REQUEST); - const client = createGitHubClient(); + const client = createGitHubClient(GITHUB_TOKEN); + const prNumber = Number(PR_NUMBER); // Load all comments const { data: comments } = await client.issues.listComments({ From 91f4e6ed9b69574b316643ef0c873b336d7d9cee Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 18:59:03 -0800 Subject: [PATCH 15/45] commit to kick workflow --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 503f7ca23..a9fdfce2d 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -54,7 +54,7 @@ jobs: - name: Report package sizes run: yarn build:sizes && yarn check:sizes - # this action posts comments on the PR so we need some variables + # add needed variables for posting on the PR via octokit env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ context.issue.number }} From a861a3923f8aa3d50c892721aff4747d8f1f355a Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 19:09:16 -0800 Subject: [PATCH 16/45] github(workflows): fix package size report job --- .github/workflows/pull_request.yml | 6 +++--- scripts/upsertPullRequestComment.ts | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a9fdfce2d..d8440eada 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -57,6 +57,6 @@ jobs: # add needed variables for posting on the PR via octokit env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ context.issue.number }} - OWNER: ${{ context.repo.owner }} - REPO: ${{ context.repo.repo }} + PR_NUMBER: ${{ github.event.issue.number }} + GITHUB_REPOSITORY: ${{ GITHUB_REPOSITORY }} + GITHUB_ACTOR: ${{ GITHUB_ACTOR }} diff --git a/scripts/upsertPullRequestComment.ts b/scripts/upsertPullRequestComment.ts index 53578bca1..00edd082b 100644 --- a/scripts/upsertPullRequestComment.ts +++ b/scripts/upsertPullRequestComment.ts @@ -8,9 +8,10 @@ function createGitHubClient(authToken: string) { } export default async function upsertPullRequestComment(query: string, body: string) { - const { GITHUB_TOKEN, PR_NUMBER, OWNER: owner, REPO: repo } = process.env; + const { GITHUB_TOKEN, PR_NUMBER, GITHUB_REPOSITORY } = process.env; const client = createGitHubClient(GITHUB_TOKEN); + const [owner, repo] = GITHUB_REPOSITORY.split('/'); const prNumber = Number(PR_NUMBER); // Load all comments From f50dff2e2cab52bad24b10dde2f9fb8b9cf2f8bf Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 19:11:21 -0800 Subject: [PATCH 17/45] github(workflow): fix GITHUB_REPOSITORY/ACTOR variable syntax --- .github/workflows/pull_request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d8440eada..9ccf83846 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -58,5 +58,5 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.issue.number }} - GITHUB_REPOSITORY: ${{ GITHUB_REPOSITORY }} - GITHUB_ACTOR: ${{ GITHUB_ACTOR }} + GITHUB_REPOSITORY: $GITHUB_REPOSITORY + GITHUB_ACTOR: $GITHUB_ACTOR From f01184d39a393928f1fa2945297d62ae0410dbf8 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 19:52:49 -0800 Subject: [PATCH 18/45] fix(scripts/upsertPullRequestComment): better types --- scripts/upsertPullRequestComment.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upsertPullRequestComment.ts b/scripts/upsertPullRequestComment.ts index 00edd082b..939b6a9fa 100644 --- a/scripts/upsertPullRequestComment.ts +++ b/scripts/upsertPullRequestComment.ts @@ -1,6 +1,6 @@ import { Octokit } from '@octokit/rest'; -function createGitHubClient(authToken: string) { +function createGitHubClient(authToken?: string) { return new Octokit({ auth: `token ${authToken}`, userAgent: 'visx', @@ -8,7 +8,7 @@ function createGitHubClient(authToken: string) { } export default async function upsertPullRequestComment(query: string, body: string) { - const { GITHUB_TOKEN, PR_NUMBER, GITHUB_REPOSITORY } = process.env; + const { GITHUB_TOKEN, PR_NUMBER, GITHUB_REPOSITORY = '/', GITHUB_ACTOR } = process.env; const client = createGitHubClient(GITHUB_TOKEN); const [owner, repo] = GITHUB_REPOSITORY.split('/'); @@ -23,7 +23,7 @@ export default async function upsertPullRequestComment(query: string, body: stri // Find a previously created comment by our bot const previousComments = comments.filter( - (comment: any) => comment.body.includes(query) && comment.user.login === GITHUB_USER, + (comment: any) => comment.body.includes(query) && comment.user.login === GITHUB_ACTOR, ); // Update existing comment From 8dd07201b3bd6b5812f015db104d81ba45b80dfa Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 20:15:43 -0800 Subject: [PATCH 19/45] fix(scripts/compareBuildSizes): log errors --- scripts/compareBuildSizes.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/compareBuildSizes.ts b/scripts/compareBuildSizes.ts index ef0e2b75b..479c055fe 100644 --- a/scripts/compareBuildSizes.ts +++ b/scripts/compareBuildSizes.ts @@ -111,8 +111,9 @@ ${JSON.stringify(nextSizes, null, 2)} try { await upsertPullRequestComment('### Size Changes', breakdown); - } catch { - console.log(breakdown); + } catch (error) { + console.log('Could not post size stats', breakdown); + console.error(error); } } From e21bc089ceb1eda6e9e26acf483f73316e61547e Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 21:38:57 -0800 Subject: [PATCH 20/45] debug(scripts//upsertPullRequestComment): add more debug logs --- .github/workflows/pull_request.yml | 4 +++- scripts/upsertPullRequestComment.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 9ccf83846..519f1f454 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -53,7 +53,9 @@ jobs: HAPPO_COMMAND: '../../node_modules/happo.io/build/cli.js' - name: Report package sizes - run: yarn build:sizes && yarn check:sizes + run: | + echo "Report package sizes on PR #${{ github.event.issue.number }}" + yarn build:sizes && yarn check:sizes # add needed variables for posting on the PR via octokit env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/upsertPullRequestComment.ts b/scripts/upsertPullRequestComment.ts index 939b6a9fa..b4c1f28f2 100644 --- a/scripts/upsertPullRequestComment.ts +++ b/scripts/upsertPullRequestComment.ts @@ -14,6 +14,8 @@ export default async function upsertPullRequestComment(query: string, body: stri const [owner, repo] = GITHUB_REPOSITORY.split('/'); const prNumber = Number(PR_NUMBER); + console.log(`Loading comments for repo ${GITHUB_REPOSITORY} issue #${prNumber}`); + // Load all comments const { data: comments } = await client.issues.listComments({ issue_number: prNumber, From 2169ed7ac6c70d3d73dedfd13db37407a39e1bb4 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 4 Feb 2021 21:58:33 -0800 Subject: [PATCH 21/45] debug(scripts/upsertPullRequestComment): add more debug logs --- .github/workflows/pull_request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 519f1f454..7bcb291b9 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -54,11 +54,11 @@ jobs: - name: Report package sizes run: | - echo "Report package sizes on PR #${{ github.event.issue.number }}" + echo "Report package sizes for event ${{ github.event }}" yarn build:sizes && yarn check:sizes # add needed variables for posting on the PR via octokit env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.issue.number }} + PR_NUMBER: ${{ github.event.pull_request.number }} GITHUB_REPOSITORY: $GITHUB_REPOSITORY GITHUB_ACTOR: $GITHUB_ACTOR From 42509e48e26af69a1aa5ee2ccb092f2ad40ee74b Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 11:46:40 -0800 Subject: [PATCH 22/45] fix(/workflows/pull_request): remove debug logging --- .github/workflows/pull_request.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7bcb291b9..7fd08dde6 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -53,9 +53,7 @@ jobs: HAPPO_COMMAND: '../../node_modules/happo.io/build/cli.js' - name: Report package sizes - run: | - echo "Report package sizes for event ${{ github.event }}" - yarn build:sizes && yarn check:sizes + run: yarn build:sizes && yarn check:sizes # add needed variables for posting on the PR via octokit env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 734973e954915b87ebbc5355a2effa7b2e4bb76f Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 11:50:22 -0800 Subject: [PATCH 23/45] github(workflows): update branches for testing --- .github/workflows/pull_request.yml | 2 +- .github/workflows/push.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7fd08dde6..2ceb61b42 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -2,7 +2,7 @@ name: Pull request on: pull_request: - branches: [master] + branches: [] jobs: build: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4211763e2..fb5b2abb1 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -2,7 +2,7 @@ name: Push on: push: - branches: [master] + branches: [chris--moar-ci] jobs: build: From 32deedaa34c085f87b151c36cfe1ae33e0739982 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 12:00:03 -0800 Subject: [PATCH 24/45] fix(workflows/push) --- .github/workflows/pull_request.yml | 2 +- .github/workflows/push.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 2ceb61b42..51165d9ea 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -2,7 +2,7 @@ name: Pull request on: pull_request: - branches: [] + branches: [no-branch] jobs: build: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index fb5b2abb1..b0157d325 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -36,7 +36,7 @@ jobs: git config user.name github-actions git config user.email github-actions@github.com echo "GITHUB_SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV - yarn add . + git add . git commit -m "build(${GITHUB_SHORT_SHA}): auto-commit package sizes" git push From e8a955c70147c4fd0e329b02569c4732680a6ef3 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 12:10:04 -0800 Subject: [PATCH 25/45] fix(scripts/upsertPullRequestComment): fix bot user login check --- scripts/compareBuildSizes.ts | 1 + scripts/upsertPullRequestComment.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/compareBuildSizes.ts b/scripts/compareBuildSizes.ts index 479c055fe..7c269ff6e 100644 --- a/scripts/compareBuildSizes.ts +++ b/scripts/compareBuildSizes.ts @@ -40,6 +40,7 @@ async function compareBuildSizes() { prevSizes = await masterFileSizesRequest.json(); } catch (error) { + console.log(`Could not fetch file ${PACKAGE_SIZES_FILENAME} from master. Aborting.`); console.log(error.message); prevSizes = nextSizes; diff --git a/scripts/upsertPullRequestComment.ts b/scripts/upsertPullRequestComment.ts index b4c1f28f2..e9e4b10a9 100644 --- a/scripts/upsertPullRequestComment.ts +++ b/scripts/upsertPullRequestComment.ts @@ -25,7 +25,11 @@ export default async function upsertPullRequestComment(query: string, body: stri // Find a previously created comment by our bot const previousComments = comments.filter( - (comment: any) => comment.body.includes(query) && comment.user.login === GITHUB_ACTOR, + comment => + comment.body.includes(query) && + comment.user.type === 'Bot' && + // bots have [bot] appended to GITHUB_ACTOR + comment.user.login.includes(GITHUB_ACTOR), ); // Update existing comment From 9609b2fa40c77d2946f5458dabd2c8521b322255 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 12:45:31 -0800 Subject: [PATCH 26/45] deps(demo, annotation, tooltip): react-measure@2.0.3 --- packages/visx-annotation/package.json | 2 +- packages/visx-demo/package.json | 2 +- packages/visx-tooltip/package.json | 2 +- yarn.lock | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/visx-annotation/package.json b/packages/visx-annotation/package.json index b22461782..8c7a90e3b 100644 --- a/packages/visx-annotation/package.json +++ b/packages/visx-annotation/package.json @@ -40,7 +40,7 @@ "@visx/text": "1.3.0", "classnames": "^2.2.5", "prop-types": "^15.5.10", - "react-use-measure": "2.0.1" + "react-use-measure": "^2.0.3" }, "devDependencies": { "resize-observer-polyfill": "^1.5.1" diff --git a/packages/visx-demo/package.json b/packages/visx-demo/package.json index 0f3bb420e..65bf2acc3 100644 --- a/packages/visx-demo/package.json +++ b/packages/visx-demo/package.json @@ -68,7 +68,7 @@ "@visx/xychart": "1.4.0", "@visx/zoom": "1.3.0", "@zeit/next-css": "^1.0.1", - "babel-loader": "8.2.2", + "babel-loader": "^8.2.2", "classnames": "^2.2.5", "d3-array": "^1.1.1", "d3-collection": "^1.0.4", diff --git a/packages/visx-tooltip/package.json b/packages/visx-tooltip/package.json index 9f3c5f706..d44fee80a 100644 --- a/packages/visx-tooltip/package.json +++ b/packages/visx-tooltip/package.json @@ -33,7 +33,7 @@ "@visx/bounds": "1.0.0", "classnames": "^2.2.5", "prop-types": "^15.5.10", - "react-use-measure": "2.0.1" + "react-use-measure": "^2.0.3" }, "peerDependencies": { "react": "^16.8.0-0", diff --git a/yarn.lock b/yarn.lock index b9b949969..d1609f395 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4789,7 +4789,7 @@ babel-literal-to-ast@^2.1.0: "@babel/traverse" "^7.1.6" "@babel/types" "^7.1.6" -babel-loader@8.2.2: +babel-loader@^8.2.2: version "8.2.2" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.2.tgz#9363ce84c10c9a40e6c753748e1441b60c8a0b81" integrity sha512-JvTd0/D889PQBtUXJ2PXaKU/pjZDMtHA9V2ecm+eNRmmBCMR09a+fmpGTNwnJtFmFl5Ei7Vy47LjBb+L0wQ99g== @@ -12437,10 +12437,10 @@ react-tilt@^0.1.4: resolved "https://registry.yarnpkg.com/react-tilt/-/react-tilt-0.1.4.tgz#0ac1f33674a3fff6c617cf411002d7ecdd2ebcb1" integrity sha512-bVeRumg+RIn6QN8S92UmubGqX/BG6/QeQISBeAcrS/70dpo/jVj+sjikIawDl5wTuPdubFH8zH0EMulWIctsnw== -react-use-measure@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/react-use-measure/-/react-use-measure-2.0.1.tgz#4f23f94c832cd4512da55acb300d1915dcbf3ae8" - integrity sha512-lFfHiqcXbJ2/6aUkZwt8g5YYM7EGqNVxJhMqMPqv1BVXRKp8D7jYLlmma0SvhRY4WYxxkZpCdbJvhDylb5gcEA== +react-use-measure@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/react-use-measure/-/react-use-measure-2.0.3.tgz#7b56ae3ca19ccf62326933678625a8ff6b3f90a3" + integrity sha512-57O8Os9MbgFEHuOHOXNdPmBHhXjCBIwtB3YxyrM/MgaX44a1o97Mu9YqiOA6cAF8kXIw4fO3XK0r2Taa4SqaqQ== dependencies: debounce "^1.2.0" From e6d31c5c2f8b0074bf5f5616cf53fef3c6d9f277 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 12:45:50 -0800 Subject: [PATCH 27/45] fix(demo/axis,pattern,xychart): fix window check for ssr --- packages/visx-demo/src/sandboxes/visx-axis/Example.tsx | 3 ++- packages/visx-demo/src/sandboxes/visx-pattern/Example.tsx | 3 ++- .../src/sandboxes/visx-xychart/userPrefersReducedMotion.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/visx-demo/src/sandboxes/visx-axis/Example.tsx b/packages/visx-demo/src/sandboxes/visx-axis/Example.tsx index da3c3d804..54b0e9292 100644 --- a/packages/visx-demo/src/sandboxes/visx-axis/Example.tsx +++ b/packages/visx-demo/src/sandboxes/visx-axis/Example.tsx @@ -67,7 +67,8 @@ export default function Example({ showControls = true, }: AxisProps) { // use non-animated components if prefers-reduced-motion is set - const prefersReducedMotionQuery = window?.matchMedia('(prefers-reduced-motion: reduce)'); + const prefersReducedMotionQuery = + typeof window === 'undefined' ? false : window.matchMedia('(prefers-reduced-motion: reduce)'); const prefersReducedMotion = !prefersReducedMotionQuery || !!prefersReducedMotionQuery.matches; const [useAnimatedComponents, setUseAnimatedComponents] = useState(!prefersReducedMotion); diff --git a/packages/visx-demo/src/sandboxes/visx-pattern/Example.tsx b/packages/visx-demo/src/sandboxes/visx-pattern/Example.tsx index ace500aaa..4a75993f8 100644 --- a/packages/visx-demo/src/sandboxes/visx-pattern/Example.tsx +++ b/packages/visx-demo/src/sandboxes/visx-pattern/Example.tsx @@ -120,7 +120,8 @@ const Patterns: React.FC<{ id: string; prefersReducedMotion?: boolean }>[] = [ export default function Example({ width, height, margin = defaultMargin }: PatternProps) { // use non-animated components if prefers-reduced-motion is set - const prefersReducedMotionQuery = window?.matchMedia('(prefers-reduced-motion: reduce)'); + const prefersReducedMotionQuery = + typeof window === 'undefined' ? false : window.matchMedia('(prefers-reduced-motion: reduce)'); const prefersReducedMotion = !prefersReducedMotionQuery || !!prefersReducedMotionQuery.matches; const numColumns = 3; diff --git a/packages/visx-demo/src/sandboxes/visx-xychart/userPrefersReducedMotion.ts b/packages/visx-demo/src/sandboxes/visx-xychart/userPrefersReducedMotion.ts index 6f9ac04b3..cc1823670 100644 --- a/packages/visx-demo/src/sandboxes/visx-xychart/userPrefersReducedMotion.ts +++ b/packages/visx-demo/src/sandboxes/visx-xychart/userPrefersReducedMotion.ts @@ -1,4 +1,5 @@ export default function userPrefersReducedMotion() { - const prefersReducedMotionQuery = window?.matchMedia('(prefers-reduced-motion: reduce)'); + const prefersReducedMotionQuery = + typeof window === 'undefined' ? false : window.matchMedia('(prefers-reduced-motion: reduce)'); return !prefersReducedMotionQuery || !!prefersReducedMotionQuery.matches; } From 0009880b26d9211b85494ede245f65e88ad782aa Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 13:07:49 -0800 Subject: [PATCH 28/45] fix(/workflows/push): rewrite gallery deploy job to fix credentials --- .github/workflows/push.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b0157d325..91492aeb1 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -42,7 +42,19 @@ jobs: - name: Deploy gallery working-directory: './packages/visx-demo/' + # this builds the next.js static site into an out/ dir, creates a git + # repo with its contents and pushes it to the gh-pages branch. + # we can't use the visx-demo script because we need git credentials run: | + rm -rf out + yarn build + cd out + touch .nojekyll git config user.name github-actions git config user.email github-actions@github.com + git init + git add . + git commit -m "gallery: deploy commit" + git remote add origin git@github.com:airbnb/visx.git + git push -f origin master:gh-pages yarn deploy From ff77c3ed523091d4f078e949a846a8130883e2eb Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 13:36:58 -0800 Subject: [PATCH 29/45] fix(workflows/push/gallery): try to fix credentials --- .github/workflows/push.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 91492aeb1..efb05fc45 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -35,9 +35,8 @@ jobs: yarn build:sizes git config user.name github-actions git config user.email github-actions@github.com - echo "GITHUB_SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV git add . - git commit -m "build(${GITHUB_SHORT_SHA}): auto-commit package sizes" + git commit -m "build(${GITHUB_SHA}): auto-commit package sizes" git push - name: Deploy gallery @@ -49,12 +48,12 @@ jobs: rm -rf out yarn build cd out - touch .nojekyll + touch .nojekyll + git init git config user.name github-actions git config user.email github-actions@github.com - git init git add . - git commit -m "gallery: deploy commit" + git commit -m "gallery(${GITHUB_SHA}): auto-deploy commit" git remote add origin git@github.com:airbnb/visx.git git push -f origin master:gh-pages yarn deploy From 6cb73a33ee64cdef1a41ca2def8700473ded8add Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 13:54:48 -0800 Subject: [PATCH 30/45] fix(github/workflows/push): try https for gallery push --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index efb05fc45..ef786f8b0 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -54,6 +54,6 @@ jobs: git config user.email github-actions@github.com git add . git commit -m "gallery(${GITHUB_SHA}): auto-deploy commit" - git remote add origin git@github.com:airbnb/visx.git + git remote add origin https://github.com/airbnb/visx.git git push -f origin master:gh-pages yarn deploy From 2fdee13c48ecc2a73f31a0c2b3174c7b370dbfd0 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 14:25:07 -0800 Subject: [PATCH 31/45] fix(workflows/push): tweak https syntax --- .github/workflows/push.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ef786f8b0..a24c689fe 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -54,6 +54,5 @@ jobs: git config user.email github-actions@github.com git add . git commit -m "gallery(${GITHUB_SHA}): auto-deploy commit" - git remote add origin https://github.com/airbnb/visx.git - git push -f origin master:gh-pages + git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" gh-pages yarn deploy From 521b296fce1fdbd09b426cc4df9ee8581142d15b Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 14:54:39 -0800 Subject: [PATCH 32/45] fix(workflows/push): try github-pages-deploy-action --- .github/workflows/push.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index a24c689fe..b88ba2bcd 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -9,6 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + persist-credentials: false # needed for gh-pages deployment - uses: actions/setup-node@v1 with: node-version: '12' @@ -39,20 +41,17 @@ jobs: git commit -m "build(${GITHUB_SHA}): auto-commit package sizes" git push - - name: Deploy gallery + - name: Build gallery working-directory: './packages/visx-demo/' - # this builds the next.js static site into an out/ dir, creates a git - # repo with its contents and pushes it to the gh-pages branch. - # we can't use the visx-demo script because we need git credentials run: | rm -rf out yarn build - cd out - touch .nojekyll - git init - git config user.name github-actions - git config user.email github-actions@github.com - git add . - git commit -m "gallery(${GITHUB_SHA}): auto-deploy commit" - git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" gh-pages - yarn deploy + + - name: Deploy gallery + working-directory: './packages/visx-demo/' + uses: JamesIves/github-pages-deploy-action@3.7.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages # branch to deploy to + FOLDER: out # folder the action should deploy + SINGLE_COMMIT: true # use single commit on gh-pages instead of the full history From 72b182c34ab63dafac78264b0322645bb06ae31c Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 15:06:06 -0800 Subject: [PATCH 33/45] fix(workflows/push): don't use working-directory with uses --- .github/workflows/push.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b88ba2bcd..79dde1410 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -29,10 +29,10 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile --ignore-engines - - name: Build packages + - name: ๐Ÿ›  Build packages run: yarn build - - name: Commit package sizes + - name: ๐Ÿ“ Commit package sizes run: | yarn build:sizes git config user.name github-actions @@ -41,17 +41,16 @@ jobs: git commit -m "build(${GITHUB_SHA}): auto-commit package sizes" git push - - name: Build gallery + - name: ๐Ÿ›  Build gallery working-directory: './packages/visx-demo/' run: | rm -rf out yarn build - - name: Deploy gallery - working-directory: './packages/visx-demo/' + - name: ๐Ÿš€ Deploy gallery uses: JamesIves/github-pages-deploy-action@3.7.1 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH: gh-pages # branch to deploy to - FOLDER: out # folder the action should deploy + FOLDER: ./packages/visx-demo/out # folder the action should deploy SINGLE_COMMIT: true # use single commit on gh-pages instead of the full history From 82bfeab5516cdb0ce29e1aeb3735eff753a7f98f Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 15:21:23 -0800 Subject: [PATCH 34/45] fix(workflows/push): try changing persist-credentials mid-workflow --- .github/workflows/push.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 79dde1410..38f712d3f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -9,8 +9,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - with: - persist-credentials: false # needed for gh-pages deployment - uses: actions/setup-node@v1 with: node-version: '12' @@ -47,6 +45,10 @@ jobs: rm -rf out yarn build + - uses: actions/checkout@v2 + with: + persist-credentials: false # needed for gh-pages deployment + - name: ๐Ÿš€ Deploy gallery uses: JamesIves/github-pages-deploy-action@3.7.1 with: From ff3a7b7de55c695f5d2704023f6ee3fdd973766f Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 15:34:15 -0800 Subject: [PATCH 35/45] fix(workflows/push): more changes --- .github/workflows/push.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 38f712d3f..9ec7eb39e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -9,6 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + persist-credentials: false # needed for gh-pages deployment - uses: actions/setup-node@v1 with: node-version: '12' @@ -30,25 +32,12 @@ jobs: - name: ๐Ÿ›  Build packages run: yarn build - - name: ๐Ÿ“ Commit package sizes - run: | - yarn build:sizes - git config user.name github-actions - git config user.email github-actions@github.com - git add . - git commit -m "build(${GITHUB_SHA}): auto-commit package sizes" - git push - - name: ๐Ÿ›  Build gallery working-directory: './packages/visx-demo/' run: | rm -rf out yarn build - - uses: actions/checkout@v2 - with: - persist-credentials: false # needed for gh-pages deployment - - name: ๐Ÿš€ Deploy gallery uses: JamesIves/github-pages-deploy-action@3.7.1 with: From 6e71972b6cb4863fc9915d231d76bdf6d899724b Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 17:16:32 -0800 Subject: [PATCH 36/45] fix(workflows/push): try worktree approach --- .github/workflows/pull_request.yml | 2 +- .github/workflows/push.yml | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 51165d9ea..2705280ce 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -8,7 +8,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 # checkout visx + this commit - uses: actions/setup-node@v1 with: node-version: '12' diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9ec7eb39e..ab5c9b9f1 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -8,9 +8,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - persist-credentials: false # needed for gh-pages deployment + - uses: actions/checkout@v2 # checkout visx + this commit - uses: actions/setup-node@v1 with: node-version: '12' @@ -34,14 +32,20 @@ jobs: - name: ๐Ÿ›  Build gallery working-directory: './packages/visx-demo/' + # below we + # checkout gh-pages as an orphan branch so we don't build history + # build the next.js site and commit it + # switch to master and add out/ as a new worktree mapped to the gh-pages branch + # cd into out/ which updates to the gh-pages branch run: | - rm -rf out + git checkout --orphan gh-pages + git reset --hard + touch .nojekyll yarn build - - - name: ๐Ÿš€ Deploy gallery - uses: JamesIves/github-pages-deploy-action@3.7.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages # branch to deploy to - FOLDER: ./packages/visx-demo/out # folder the action should deploy - SINGLE_COMMIT: true # use single commit on gh-pages instead of the full history + git add . + git commit -m "bot(${GITHUB_SHA}): auto-commit gallery" + git checkout master + rm -rf out + git worktree add out gh-pages + cd out + git push -f https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git gh-pages From ed6c6bf631f902b6561e3bdb6175e1b28b7a96a2 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 17:26:11 -0800 Subject: [PATCH 37/45] fix(workflows/push): build gallery on master --- .github/workflows/push.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ab5c9b9f1..bcc7c47fc 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -41,11 +41,12 @@ jobs: git checkout --orphan gh-pages git reset --hard touch .nojekyll - yarn build git add . - git commit -m "bot(${GITHUB_SHA}): auto-commit gallery" + git commit -m "bot(${GITHUB_SHA}): initialize gh-pages branch" git checkout master rm -rf out + yarn build git worktree add out gh-pages cd out + git commit -m "bot(${GITHUB_SHA}): auto-commit gallery" git push -f https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git gh-pages From b6734d358a2e832d173dbb515347814ecd5d2d48 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 17:29:56 -0800 Subject: [PATCH 38/45] fix(workflows/push): add out/ contents pre-commit --- .github/workflows/push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index bcc7c47fc..844c079f4 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -48,5 +48,6 @@ jobs: yarn build git worktree add out gh-pages cd out + git add . git commit -m "bot(${GITHUB_SHA}): auto-commit gallery" git push -f https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git gh-pages From 16eac020caae0fa89a6ec0b51c49273620796d22 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 17:58:16 -0800 Subject: [PATCH 39/45] fix(workflows/push): fix credentials --- .github/workflows/push.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 844c079f4..1eef10125 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -33,11 +33,14 @@ jobs: - name: ๐Ÿ›  Build gallery working-directory: './packages/visx-demo/' # below we + # setup git credentials provided via actions/checkout@v2 # checkout gh-pages as an orphan branch so we don't build history # build the next.js site and commit it # switch to master and add out/ as a new worktree mapped to the gh-pages branch # cd into out/ which updates to the gh-pages branch run: | + git config user.name github-actions + git config user.email github-actions@github.com git checkout --orphan gh-pages git reset --hard touch .nojekyll From 3bed467217c17c2e8eb93009a211acde26c4bc45 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 5 Feb 2021 18:24:19 -0800 Subject: [PATCH 40/45] fix(workflows/push): try not master --- .github/workflows/push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1eef10125..5d0b92d0c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -46,11 +46,11 @@ jobs: touch .nojekyll git add . git commit -m "bot(${GITHUB_SHA}): initialize gh-pages branch" - git checkout master + git checkout "$GITHUB_SHA" rm -rf out yarn build git worktree add out gh-pages cd out git add . git commit -m "bot(${GITHUB_SHA}): auto-commit gallery" - git push -f https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git gh-pages + git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" gh-pages From ddd77a9d0a4707ecf786ba50820ab41653a322ba Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Sat, 6 Feb 2021 14:03:03 -0800 Subject: [PATCH 41/45] fix(workflows/push): try not master take 2 --- .github/workflows/push.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 5d0b92d0c..baedb609e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -47,9 +47,8 @@ jobs: git add . git commit -m "bot(${GITHUB_SHA}): initialize gh-pages branch" git checkout "$GITHUB_SHA" - rm -rf out - yarn build git worktree add out gh-pages + yarn build cd out git add . git commit -m "bot(${GITHUB_SHA}): auto-commit gallery" From da1b37423e610cd7bde344e3d6acefa9d53e72d3 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Mon, 8 Feb 2021 19:31:03 -0800 Subject: [PATCH 42/45] fix(workflows/push): we have a winner --- .github/workflows/push.yml | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index baedb609e..bef85f5bc 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -31,25 +31,31 @@ jobs: run: yarn build - name: ๐Ÿ›  Build gallery - working-directory: './packages/visx-demo/' # below we - # setup git credentials provided via actions/checkout@v2 - # checkout gh-pages as an orphan branch so we don't build history - # build the next.js site and commit it - # switch to master and add out/ as a new worktree mapped to the gh-pages branch - # cd into out/ which updates to the gh-pages branch + # - setup git credentials provided via actions/checkout@v2 + # - initialize gh-pages-branch as an orphan branch so we don't build history + # - checkout the current commit and create gh-pages-root-dir/ as a new worktree + # - outside that directory HEAD is detached at $GITHUB_SHA + # - within that directory we are on the gh-pages-branch we just initialized + # *worktree initialization should be in a root dir, otherwise the worktree inherits nested directories + # - build the static next.js site and copy the output into gh-pages-root-dir/ + # - we can't output directly into gh-pages-root-dir/ because next wipes the folder including .git + # - commit the demo site within gh-pages-root-dir/ onto the gh-pages-branch + # - push gh-pages-branch to visx as gh-pages. we overwrite history every time so it must be forced run: | git config user.name github-actions git config user.email github-actions@github.com - git checkout --orphan gh-pages + git checkout --orphan gh-pages-branch git reset --hard touch .nojekyll - git add . + git add .nojekyll git commit -m "bot(${GITHUB_SHA}): initialize gh-pages branch" git checkout "$GITHUB_SHA" - git worktree add out gh-pages + git worktree add gh-pages-root-dir gh-pages-branch + cd ./packages/visx-demo/ yarn build - cd out + mv -v out/* ../../gh-pages-root-dir/ + cd ../../gh-pages-root-dir/ git add . - git commit -m "bot(${GITHUB_SHA}): auto-commit gallery" - git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" gh-pages + git commit -m "bot(${GITHUB_SHA}): build gh-pages" + git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:gh-test From 1bc79d115a13fddfbdf3fffe915661350b2eea24 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Mon, 8 Feb 2021 19:56:48 -0800 Subject: [PATCH 43/45] fix(workflows/push,pull_request): final final --- .github/workflows/pull_request.yml | 16 ++++++++-------- .github/workflows/push.yml | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 2705280ce..46b281682 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -2,7 +2,7 @@ name: Pull request on: pull_request: - branches: [no-branch] + branches: [master] jobs: build: @@ -24,27 +24,27 @@ jobs: restore-keys: | ${{ runner.os }}-yarn- - - name: Install dependencies + - name: ๐Ÿ“ก Install dependencies run: yarn install --frozen-lockfile --ignore-engines - - name: Build packages + - name: ๐Ÿ›  Build packages run: yarn build - - name: Run jest + - name: ๐Ÿงช Run jest run: yarn jest -w 4 env: CI: true COVERAGE: true - - name: Report code coverage + - name: ๐Ÿ“ˆ Report code coverage uses: coverallsapp/github-action@v1.1.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Run lint + - name: โœจ Run lint run: yarn lint - - name: Run happo + - name: ๐Ÿฆ› Run happo run: yarn run happo-ci-github-actions working-directory: './packages/visx-demo/' env: @@ -52,7 +52,7 @@ jobs: HAPPO_API_SECRET: ${{ secrets.HAPPO_API_SECRET }} HAPPO_COMMAND: '../../node_modules/happo.io/build/cli.js' - - name: Report package sizes + - name: ๐Ÿ“ Report package sizes run: yarn build:sizes && yarn check:sizes # add needed variables for posting on the PR via octokit env: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index bef85f5bc..02f40c6b7 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -2,7 +2,7 @@ name: Push on: push: - branches: [chris--moar-ci] + branches: [master] jobs: build: @@ -24,13 +24,22 @@ jobs: restore-keys: | ${{ runner.os }}-yarn- - - name: Install dependencies + - name: ๐Ÿ‘‡ Install dependencies run: yarn install --frozen-lockfile --ignore-engines - name: ๐Ÿ›  Build packages run: yarn build - - name: ๐Ÿ›  Build gallery + - name: ๐Ÿ“ Commit package sizes + run: | + yarn build:sizes + git config user.name github-actions + git config user.email github-actions@github.com + git add . + git commit -m "build(${GITHUB_SHA}): auto-commit package sizes" + git push + + - name: ๐Ÿš€ Build and deploy gallery # below we # - setup git credentials provided via actions/checkout@v2 # - initialize gh-pages-branch as an orphan branch so we don't build history @@ -58,4 +67,4 @@ jobs: cd ../../gh-pages-root-dir/ git add . git commit -m "bot(${GITHUB_SHA}): build gh-pages" - git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:gh-test + git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:gh-pages From d503be51d3663bc04047f559aa1bfedbd6c0bc2f Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Mon, 8 Feb 2021 20:00:48 -0800 Subject: [PATCH 44/45] =?UTF-8?q?fix(workflows/push):=20match=20?= =?UTF-8?q?=F0=9F=93=A1=20emoji=20across=20workflows=20=F0=9F=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 02f40c6b7..3d99b2278 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -24,7 +24,7 @@ jobs: restore-keys: | ${{ runner.os }}-yarn- - - name: ๐Ÿ‘‡ Install dependencies + - name: ๐Ÿ“ก Install dependencies run: yarn install --frozen-lockfile --ignore-engines - name: ๐Ÿ›  Build packages From 160db5cac2eb538f9d9f9433c14891832fc65243 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Mon, 8 Feb 2021 20:21:23 -0800 Subject: [PATCH 45/45] type(scripts/upsertPullRequestComment): fix types --- scripts/upsertPullRequestComment.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upsertPullRequestComment.ts b/scripts/upsertPullRequestComment.ts index e9e4b10a9..ec5fd117a 100644 --- a/scripts/upsertPullRequestComment.ts +++ b/scripts/upsertPullRequestComment.ts @@ -8,7 +8,7 @@ function createGitHubClient(authToken?: string) { } export default async function upsertPullRequestComment(query: string, body: string) { - const { GITHUB_TOKEN, PR_NUMBER, GITHUB_REPOSITORY = '/', GITHUB_ACTOR } = process.env; + const { GITHUB_TOKEN, PR_NUMBER, GITHUB_REPOSITORY = '/', GITHUB_ACTOR = '' } = process.env; const client = createGitHubClient(GITHUB_TOKEN); const [owner, repo] = GITHUB_REPOSITORY.split('/'); @@ -26,8 +26,8 @@ export default async function upsertPullRequestComment(query: string, body: stri // Find a previously created comment by our bot const previousComments = comments.filter( comment => - comment.body.includes(query) && - comment.user.type === 'Bot' && + comment.body?.includes(query) && + comment.user?.type === 'Bot' && // bots have [bot] appended to GITHUB_ACTOR comment.user.login.includes(GITHUB_ACTOR), );