From 904d7fe08b49cc148cc78d550b4f49dad72e455c Mon Sep 17 00:00:00 2001 From: Riley Tomasek Date: Sat, 2 Dec 2023 17:46:23 -0500 Subject: [PATCH 1/3] Standardize package.json scripts This brings the package.json scripts inline with the standard names we use for all other Dexa repos. It also updates the GitHub workflow for the changes and to use explicit jobs for nicer reporting. --- .github/actions/install-node-pnpm/action.yml | 46 +++++++ .github/workflows/main.yml | 56 ++++----- package.json | 26 ++-- pnpm-lock.yaml | 123 +------------------ 4 files changed, 90 insertions(+), 161 deletions(-) create mode 100644 .github/actions/install-node-pnpm/action.yml diff --git a/.github/actions/install-node-pnpm/action.yml b/.github/actions/install-node-pnpm/action.yml new file mode 100644 index 0000000..b76b031 --- /dev/null +++ b/.github/actions/install-node-pnpm/action.yml @@ -0,0 +1,46 @@ +name: 'Install Node and pnpm' +description: 'Install Node and pnpm with caching for fast install' + +inputs: + node-version: + description: 'The version of Node to install' + default: '18' + required: false + pnpm-version: + description: 'The version of pnpm to install' + default: '8' + required: false + +runs: + using: "composite" + steps: + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + + - name: Install pnpm + uses: pnpm/action-setup@v2 + id: pnpm-install + with: + version: ${{ inputs.pnpm-version }} + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Setup pnpm cache + uses: actions/cache@v3 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + # Run install with optional filter if present + - name: Install pnpm dependencies + shell: bash + run: pnpm install --frozen-lockfile diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a32c2b0..f0ce11a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,8 +3,32 @@ name: CI on: [push, pull_request] jobs: + types: + name: Types + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-node-pnpm + - run: pnpm run typecheck + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-node-pnpm + - run: pnpm run lint + + format: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-node-pnpm + - run: pnpm run format + test: - name: Test Node.js ${{ matrix.node-version }} + name: Tests (Node ${{ matrix.node-version }}) runs-on: ubuntu-latest strategy: fail-fast: true @@ -13,36 +37,10 @@ jobs: - 21 - 20 - 18 - steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 + - uses: ./.github/actions/install-node-pnpm with: node-version: ${{ matrix.node-version }} - - - name: Install pnpm - uses: pnpm/action-setup@v2 - id: pnpm-install - with: - version: 8 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Run test + - name: Run unit tests run: pnpm run test diff --git a/package.json b/package.json index 47b198e..210cdd2 100644 --- a/package.json +++ b/package.json @@ -48,20 +48,20 @@ ], "scripts": { "build": "tsc --project tsconfig.dist.json", - "prebuild": "rimraf dist", "clean": "rimraf node_modules dist", "dev": "tsc --watch", - "prepare": "run-s build", - "release": "np", - "predocs": "rimraf docs/pages/docs", - "docs": "run-s docs:*", - "docs:typedoc": "typedoc", + "docs": "pnpm run docs:transform && pnpm run docs:typedoc", "docs:transform": "tsx docs/bin/transform-docs.ts", - "test": "run-p test:*", - "test:lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .", - "test:format": "prettier --check \"**/*.{js,ts,tsx}\"", - "test:unit": "dotenv -e .env.example -- vitest", - "test:typecheck": "tsc --noEmit" + "docs:typedoc": "typedoc", + "format": "prettier --check \"**/*.{js,ts,tsx}\"", + "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .", + "prebuild": "rimraf dist", + "predocs": "rimraf docs/pages/docs", + "prepare": "pnpm run build", + "prepublishOnly": "pnpm run lint && pnpm run typecheck", + "release": "np", + "test": "dotenv -e .env.example -- vitest", + "typecheck": "tsc --noEmit" }, "dependencies": { "@fastify/deepmerge": "^1.3.0", @@ -86,7 +86,6 @@ "eslint": "^8.54.0", "globby": "^14.0.0", "np": "^8.0.4", - "npm-run-all": "^4.1.5", "prettier": "^2.8.8", "rimraf": "^5.0.5", "tsx": "^4.1.4", @@ -114,5 +113,6 @@ "rules": { "no-console": "off" } - } + }, + "packageManager": "pnpm@8.6.12" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5f34187..08b197e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -69,9 +69,6 @@ importers: np: specifier: ^8.0.4 version: 8.0.4(typescript@5.3.2) - npm-run-all: - specifier: ^4.1.5 - version: 4.1.5 prettier: specifier: ^2.8.8 version: 2.8.8 @@ -2587,17 +2584,6 @@ packages: which: 1.3.1 dev: false - /cross-spawn@6.0.5: - resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} - engines: {node: '>=4.8'} - dependencies: - nice-try: 1.0.5 - path-key: 2.0.1 - semver: 5.7.2 - shebang-command: 1.2.0 - which: 1.3.1 - dev: true - /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} @@ -4533,10 +4519,6 @@ packages: resolution: {integrity: sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==} dev: false - /hosted-git-info@2.8.9: - resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} - dev: true - /hosted-git-info@4.1.0: resolution: {integrity: sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==} engines: {node: '>=10'} @@ -5223,10 +5205,6 @@ packages: /json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} - /json-parse-better-errors@1.0.2: - resolution: {integrity: sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==} - dev: true - /json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} dev: true @@ -5403,16 +5381,6 @@ packages: - zenObservable dev: true - /load-json-file@4.0.0: - resolution: {integrity: sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==} - engines: {node: '>=4'} - dependencies: - graceful-fs: 4.2.11 - parse-json: 4.0.0 - pify: 3.0.0 - strip-bom: 3.0.0 - dev: true - /local-pkg@0.4.3: resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} engines: {node: '>=14'} @@ -5802,11 +5770,6 @@ packages: '@types/mdast': 3.0.14 dev: false - /memorystream@0.3.1: - resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} - engines: {node: '>= 0.10.0'} - dev: true - /meow@12.1.1: resolution: {integrity: sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==} engines: {node: '>=16.10'} @@ -6483,10 +6446,6 @@ packages: - supports-color dev: false - /nice-try@1.0.5: - resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} - dev: true - /node-releases@2.0.13: resolution: {integrity: sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==} @@ -6494,15 +6453,6 @@ packages: resolution: {integrity: sha512-gkXMxRzUH+PB0ax9dUN0yYF0S25BqeAYqhgMaLUFmpXLEk7Fcu8f4emJuOAY0V8kjDICxROIKsTAKsV/v355xw==} dev: false - /normalize-package-data@2.5.0: - resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} - dependencies: - hosted-git-info: 2.8.9 - resolve: 1.22.8 - semver: 5.7.2 - validate-npm-package-license: 3.0.4 - dev: true - /normalize-package-data@3.0.3: resolution: {integrity: sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==} engines: {node: '>=10'} @@ -6586,22 +6536,6 @@ packages: validate-npm-package-name: 3.0.0 dev: true - /npm-run-all@4.1.5: - resolution: {integrity: sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==} - engines: {node: '>= 4'} - hasBin: true - dependencies: - ansi-styles: 3.2.1 - chalk: 2.4.2 - cross-spawn: 6.0.5 - memorystream: 0.3.1 - minimatch: 3.1.2 - pidtree: 0.3.1 - read-pkg: 3.0.0 - shell-quote: 1.8.1 - string.prototype.padend: 3.1.5 - dev: true - /npm-run-path@2.0.2: resolution: {integrity: sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==} engines: {node: '>=4'} @@ -6946,14 +6880,6 @@ packages: types-json: 1.2.2 dev: true - /parse-json@4.0.0: - resolution: {integrity: sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==} - engines: {node: '>=4'} - dependencies: - error-ex: 1.3.2 - json-parse-better-errors: 1.0.2 - dev: true - /parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} @@ -7014,6 +6940,7 @@ packages: /path-key@2.0.1: resolution: {integrity: sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==} engines: {node: '>=4'} + dev: false /path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} @@ -7037,13 +6964,6 @@ packages: minipass: 7.0.4 dev: true - /path-type@3.0.0: - resolution: {integrity: sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==} - engines: {node: '>=4'} - dependencies: - pify: 3.0.0 - dev: true - /path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -7078,17 +6998,6 @@ packages: engines: {node: '>=8.6'} dev: true - /pidtree@0.3.1: - resolution: {integrity: sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==} - engines: {node: '>=0.10'} - hasBin: true - dev: true - - /pify@3.0.0: - resolution: {integrity: sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==} - engines: {node: '>=4'} - dev: true - /pinecone-client@2.0.0: resolution: {integrity: sha512-CxpKuck4zxi/LaGaTrnWQNs9NmXiMB3UtynOhD6dVDoWRKGEXmgRbSFipMUdqGyyQEKMFXzTKvzo4qMHi2Gj8Q==} engines: {node: '>=18'} @@ -7276,15 +7185,6 @@ packages: type-fest: 2.19.0 dev: true - /read-pkg@3.0.0: - resolution: {integrity: sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==} - engines: {node: '>=4'} - dependencies: - load-json-file: 4.0.0 - normalize-package-data: 2.5.0 - path-type: 3.0.0 - dev: true - /read-pkg@7.1.0: resolution: {integrity: sha512-5iOehe+WF75IccPc30bWTbpdDQLOCc3Uu8bi3Dte3Eueij81yx1Mrufk8qBx/YAbR4uL1FdUr+7BKXDwEtisXg==} engines: {node: '>=12.20'} @@ -7688,11 +7588,6 @@ packages: semver: 7.5.4 dev: true - /semver@5.7.2: - resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} - hasBin: true - dev: true - /semver@6.3.1: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true @@ -7733,6 +7628,7 @@ packages: engines: {node: '>=0.10.0'} dependencies: shebang-regex: 1.0.0 + dev: false /shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} @@ -7744,16 +7640,13 @@ packages: /shebang-regex@1.0.0: resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==} engines: {node: '>=0.10.0'} + dev: false /shebang-regex@3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} dev: true - /shell-quote@1.8.1: - resolution: {integrity: sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==} - dev: true - /shiki@0.14.5: resolution: {integrity: sha512-1gCAYOcmCFONmErGTrS1fjzJLA7MGZmKzrBNX7apqSwhyITJg2O102uFzXUeBxNnEkDA9vHIKLyeKq0V083vIw==} dependencies: @@ -7932,15 +7825,6 @@ packages: side-channel: 1.0.4 dev: true - /string.prototype.padend@3.1.5: - resolution: {integrity: sha512-DOB27b/2UTTD+4myKUFh+/fXWcu/UDyASIXfg+7VzoCNNGOfWvoyU/x5pvVHr++ztyt/oSYI1BcWBBG/hmlNjA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.5 - define-properties: 1.2.1 - es-abstract: 1.22.3 - dev: true - /string.prototype.trim@1.2.8: resolution: {integrity: sha512-lfjY4HcixfQXOfaqCvcBuOIapyaroTXhbkfJN3gcB1OtyupngWK4sEET9Knd0cXd28kTUqu/kHoV4HKSJdnjiQ==} engines: {node: '>= 0.4'} @@ -8878,6 +8762,7 @@ packages: hasBin: true dependencies: isexe: 2.0.0 + dev: false /which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} From a17af22efb5a2799b2b52e96f848e47f032f2a8a Mon Sep 17 00:00:00 2001 From: Riley Tomasek Date: Sat, 2 Dec 2023 18:04:31 -0500 Subject: [PATCH 2/3] Fix duplicate GitHub workflow run --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f0ce11a..9cac798 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,10 @@ name: CI -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: jobs: types: From 3de7975cfe1bf5d9f27c0006060dba4f74ee4d91 Mon Sep 17 00:00:00 2001 From: Riley Tomasek Date: Sat, 2 Dec 2023 18:06:12 -0500 Subject: [PATCH 3/3] Stop running test on multiple Node versions It's noisy, unlikely to catch anything with unit tests, and we exclusively use Node v18 so others can open PRs for issues with other versions. --- .github/workflows/main.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9cac798..0094128 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,19 +32,9 @@ jobs: - run: pnpm run format test: - name: Tests (Node ${{ matrix.node-version }}) + name: Test runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - node-version: - - 21 - - 20 - - 18 steps: - uses: actions/checkout@v4 - uses: ./.github/actions/install-node-pnpm - with: - node-version: ${{ matrix.node-version }} - - name: Run unit tests - run: pnpm run test + - run: pnpm run test