-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: switch from yarn to pnpm (#2231)
* feat(pnpm): switch from yarn to pnpm * fix: lint * fix: lockfile * fix: remove invalid types * fix: global-component types * fix: package preview * fix: lockfile
- Loading branch information
1 parent
88490c9
commit 9f846b7
Showing
15 changed files
with
9,309 additions
and
9,070 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Setup PNPM with Dependencies | ||
description: Reusable composition of setup-node, cache, and pnpm install actions | ||
inputs: | ||
nodejs-version: | ||
description: 'Version of NodeJS to use (ex: 18.19.1)' | ||
default: '18.19.1' | ||
force-install: | ||
description: When 'true', pnpm install will be executed regardless of a cache hit | ||
required: false | ||
default: 'false' | ||
frozen-lockfile: | ||
description: When false, pnpm install will use the --no-frozen-lockfile flag | ||
required: false | ||
default: 'true' | ||
outputs: | ||
cache-hit: | ||
description: Whether or not there was a cache hit | ||
value: ${{ steps.dependency-cache.outputs.cache-hit }} | ||
runs: | ||
using: composite | ||
steps: | ||
|
||
- name: get Node version | ||
id: node-version | ||
shell: bash | ||
run: | | ||
voltaNodeVersion=$(cat package.json|jq -r ".volta.node") | ||
if [[ $voltaNodeVersion == null ]]; then | ||
voltaNodeVersion="${{ inputs.nodejs-version }}" | ||
fi | ||
voltaPnpmVersion=$(cat package.json|jq -r ".volta.pnpm") | ||
if [[ $voltaPnpmVersion == null ]]; then | ||
voltaPnpmVersion="9.3.0" | ||
fi | ||
echo "node-version=${voltaNodeVersion}">> $GITHUB_OUTPUT | ||
echo "pnpm-version=${voltaPnpmVersion}">> $GITHUB_OUTPUT | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ steps.node-version.outputs.node-version }} | ||
|
||
- name: Install PNPM | ||
shell: bash | ||
run: | | ||
npm i -g pnpm@${{ steps.node-version.outputs.pnpm-version }} | ||
pnpm --version | ||
- name: Dependency Cache | ||
id: dependency-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: '**/node_modules' | ||
key: pnpm-${{ steps.node-version.outputs.pnpm-version }}-${{ steps.node-version.outputs.node-version }}-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
|
||
- name: Install Dependencies | ||
if: ${{ inputs.force-install == 'true' || steps.dependency-cache.outputs.cache-hit != 'true' }} | ||
shell: bash | ||
run: pnpm i${{ inputs.frozen-lockfile == 'false' && ' --no-frozen-lockfile' || '' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ jobs: | |
- run-tests | ||
# Only run the publish action (including semantic-release) if files in the /src/ directory changed. | ||
# Should only run if files in the `src/` directory were changed | ||
if: needs.get-changed-files.outputs.component-files-changed == 'true' || needs.get-changed-files.outputs.package-json-yarn-lock-files-changed == 'true' | ||
if: needs.get-changed-files.outputs.component-files-changed == 'true' || needs.get-changed-files.outputs.package-json-pnpm-lock-files-changed == 'true' | ||
runs-on: ubuntu-latest | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLIC_PUBLISH }} | ||
|
@@ -40,7 +40,7 @@ jobs: | |
with: | ||
token: ${{ secrets.KONGPONENTS_BOT_PAT }} | ||
|
||
- name: setup git | ||
- name: Setup git | ||
run: | | ||
git config --global user.name 'kongponents-bot' | ||
git config --global user.email '[email protected]' | ||
|
@@ -49,16 +49,11 @@ jobs: | |
# Reference the env variable NPM_TOKEN here, not the secret | ||
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
- name: Setup PNPM with Dependencies | ||
uses: ./.github/actions/setup-pnpm-with-dependencies/ | ||
|
||
- name: Build | ||
run: yarn build:kongponents | ||
run: pnpm build:kongponents | ||
|
||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@v4 | ||
|
@@ -70,7 +65,7 @@ jobs: | |
name: No Component Tests needed | ||
needs: | ||
- get-changed-files | ||
if: needs.get-changed-files.outputs.component-files-changed == 'false' && needs.get-changed-files.outputs.package-json-yarn-lock-files-changed == 'false' | ||
if: needs.get-changed-files.outputs.component-files-changed == 'false' && needs.get-changed-files.outputs.package-json-pnpm-lock-files-changed == 'false' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Skip component tests | ||
|
@@ -80,7 +75,7 @@ jobs: | |
name: No Build and Publish needed | ||
needs: | ||
- get-changed-files | ||
if: needs.get-changed-files.outputs.components-or-docs-or-cypress-files-changed == 'false' && needs.get-changed-files.outputs.package-json-yarn-lock-files-changed == 'false' | ||
if: needs.get-changed-files.outputs.components-or-docs-or-cypress-files-changed == 'false' && needs.get-changed-files.outputs.package-json-pnpm-lock-files-changed == 'false' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Skip new release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,26 +47,26 @@ jobs: | |
with: | ||
fetch-depth: 0 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
- name: Setup PNPM with Dependencies | ||
uses: ./.github/actions/setup-pnpm-with-dependencies/ | ||
with: | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
force-install: true | ||
|
||
- name: Stylelint | ||
run: yarn stylelint | ||
run: pnpm stylelint | ||
|
||
- name: Lint | ||
run: yarn lint | ||
run: pnpm lint | ||
|
||
- name: Build components and docs | ||
run: yarn build:ci | ||
run: pnpm build:ci | ||
|
||
- name: Publish Package Preview | ||
id: package-preview | ||
# Do not run for `alpha` or `beta` branches | ||
if: github.event_name == 'pull_request' && (github.actor != 'renovate[bot]' || contains(github.event.pull_request.labels.*.name, 'create preview package')) | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLIC_PUBLISH }} | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "Kong UI Bot" | ||
|
@@ -75,11 +75,10 @@ jobs: | |
tag="pr-${{ github.event.pull_request.number }}" | ||
echo "preid=${preid}" | ||
git checkout ${{ github.head_ref }} | ||
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_PUBLIC_PUBLISH }}" > .npmrc | ||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc | ||
yarn version --prerelease --preid ${preid} --allow-branch ${{ github.head_ref }} --no-git-tag-version --yes --amend | ||
# Use pnpm to bump the version for the prerelease | ||
pnpm version prerelease --preid ${preid} --no-git-tag-version --yes --amend | ||
package_version=$(jq -r ".version" package.json) | ||
package=@kong/kongponents@"${package_version}" | ||
|
@@ -92,7 +91,7 @@ jobs: | |
npm_instructions="" | ||
pkg=$(npm publish --no-git-checks --access public --report-summary --tag "${tag}" | grep "+ "| sed 's/+ //') | ||
pkg=$(pnpm publish --no-git-checks --access public --report-summary --tag "${tag}" | grep "+ "| sed 's/+ //') | ||
if [[ -z "${pkg}" ]]; then | ||
echo "Error publishing package" | ||
|
@@ -122,7 +121,7 @@ jobs: | |
uses: cypress-io/github-action@v6 | ||
with: | ||
install: false | ||
command: yarn test | ||
command: pnpm test | ||
|
||
- name: Upload Cypress screenshots (on failure) | ||
uses: actions/upload-artifact@v4 | ||
|
@@ -137,15 +136,3 @@ jobs: | |
with: | ||
name: cypress-videos | ||
path: cypress/videos | ||
|
||
# This step will be skipped if being ran from the publish action with PREVENT_PERCY_TESTS: 'true' | ||
# - name: Trigger Percy visual regression test for docs | ||
# timeout-minutes: 5 | ||
# env: | ||
# PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} | ||
# PREVENT_PERCY_TESTS: ${{ secrets.PREVENT_PERCY_TESTS }} | ||
# # TODO: Change branch as branch name changes | ||
# PERCY_TARGET_BRANCH: alpha | ||
# if: "${{ env.PREVENT_PERCY_TESTS != 'true' }}" | ||
# run: | | ||
# npx @percy/cli snapshot docs/.vitepress/dist/ --exclude "**/404.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.