Skip to content

Commit

Permalink
Merge pull request #612 from kadena-community/chore/migrate-away-from…
Browse files Browse the repository at this point in the history
…-rush

Migrate to pnpm + turborepo
  • Loading branch information
webpro authored Aug 28, 2023
2 parents a69e5ea + 46195c1 commit e969f3c
Show file tree
Hide file tree
Showing 105 changed files with 3,333 additions and 5,022 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Thanks for contributing to this project!
- Link to the related issue (if any)
- Add use cases, scenarios, images and screenshots
- Add documentation and tutorials
- Run `rush test` and `rush change`
- Run `pnpm install` and `pnpm test`
- In short: help us help you to get this through!
-->
14 changes: 11 additions & 3 deletions .github/workflows/chromatic-react-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@ jobs:
with:
fetch-depth: 0 # 👈 Required to retrieve git history, needed to determine diffs.

- uses: pnpm/action-setup@v2
with:
version: 8

- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build @kadena/react-ui
run: pnpm build --filter @kadena/react-ui

- name: Rush install (install-run-rush)
run: |
node common/scripts/install-run-rush.js install -t @kadena/react-ui
- name: Publish Storybook
uses: chromaui/action@v1
with:
Expand Down
95 changes: 19 additions & 76 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rush CI (changelog, build, test)
name: CI (build, test, format)
# All pull requests, and
# Workflow dispatch allows you to run this workflow manually from the Actions tab
on:
Expand All @@ -8,10 +8,6 @@ on:
branches:
- main

env:
AFFECTED_OR_ALL: |
${{ github.ref_name == 'main' && ' ' || format('--to git:origin/{0} --from git:origin/{0}', github.base_ref) }}
jobs:
build:
name: ${{ matrix.os }} - Node.js v${{ matrix.NodeVersion }}
Expand All @@ -21,6 +17,9 @@ jobs:
matrix:
os: [ubuntu-latest]
NodeVersion: [16, 18]
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

steps:
- uses: actions/checkout@v3
Expand All @@ -31,83 +30,27 @@ jobs:
if: github.ref_name != 'main'
run: git fetch origin ${{ github.base_ref }}

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.NodeVersion }}

- name: Cache Rush
uses: actions/cache@v3
with:
path: |
common/temp/install-run
~/.rush
key: cache-rush-${{ runner.os }}-${{ hashFiles('rush.json') }}

- name: Cache pnpm
uses: actions/cache@v3
- uses: pnpm/action-setup@v2
with:
path: |
common/temp/pnpm-store
key: |
cache-pnpm-${{ runner.os }}-${{hashFiles('common/config/rush/pnpm-lock.yaml')}}
restore-keys: |
cache-pnpm-${{runner.os}}-
cache-pnpm-
- name: Rush install (install-run-rush)
run: |
node common/scripts/install-run-rush.js install ${{ env.AFFECTED_OR_ALL }}
version: 8

- name: Cache builds
if: github.ref_name != 'main'
uses: actions/cache@v3
- uses: actions/setup-node@v3
with:
path: |
common/temp/build-cache
key: cache-build-${{ runner.os }}-${{ github.ref }}
restore-keys: |
cache-build-${{runner.os}}-
cache-build-
node-version: ${{ matrix.NodeVersion }}
cache: 'pnpm'

# Separate build cache when running on main
# This cache will be used when the first build is run on a PR
# Hence ${{ github.ref }} is not included in the key
- name: Cache builds
if: github.ref_name == 'main'
uses: actions/cache@v3
with:
path: |
common/temp/build-cache
key: cache-build-${{ runner.os }}
restore-keys: |
cache-build-
- name: Install dependencies
run: pnpm install

- name: Cache previous test-lint-format runs
if: github.ref_name != 'main'
uses: actions/cache@v3
with:
path: |
packages/*/*/.rush/temp/package-deps_format.json
packages/*/*/.rush/temp/package-deps_format_ci.json
packages/*/*/.rush/temp/package-deps_lint.json
packages/*/*/.rush/temp/package-deps_test.json
key: cache-build-${{ runner.os }}-${{ github.ref }}
- name: Build packages
run: pnpm build

- name: Rush build + test (install-run-rush)
run: |
node common/scripts/install-run-rush.js build --verbose ${{ env.AFFECTED_OR_ALL }}
node common/scripts/install-run-rush.js test --verbose ${{ env.AFFECTED_OR_ALL }}
env:
# Prevent time-based browserslist update warning
# See https://github.com/microsoft/rushstack/issues/2981
BROWSERSLIST_IGNORE_OLD_DATA: 1
- name: Lint packages
run: pnpm lint:ci

- name: Rush format (install-run-rush)
if: github.ref_name != 'main'
run: |
node common/scripts/install-run-rush.js format:ci --verbose ${{ env.AFFECTED_OR_ALL }}
- name: Test packages
run: pnpm test

- name: Rush verify Change Logs (install-run-rush)
- name: Verify source code formatting
if: github.ref_name != 'main'
run: |
node common/scripts/install-run-rush.js change --verify --target-branch origin/${{ github.base_ref }}
run: pnpm run format:ci
15 changes: 3 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ tsdoc-metadata.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*
**/rush-logs

# Runtime data
*.pid
Expand Down Expand Up @@ -63,10 +62,6 @@ jspm_packages/
# Output of 'npm pack'
*.tgz

# Optional config for 'rush publish'
.npmrc
.npmrc-publish

# Yarn Integrity file
.yarn-integrity

Expand All @@ -79,14 +74,7 @@ jspm_packages/
# OS X temporary files
.DS_Store

# Rush temporary files
common/deploy/
common/temp/
common/autoinstallers/*/.npmrc
**/.rush/temp/
**/.rush
packages/*/*/temp

# Heft
.heft

Expand All @@ -97,5 +85,8 @@ packages/*/*/temp
.idea
.idea/*

# Turborepo
.turbo

# Storybook static build
storybook-static
19 changes: 19 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const ALLOWED_ROOT_DEPENDENCIES = ['@kadena-dev/markdown', 'only-allow', 'syncpack', 'turbo'];

function readPackage(pkg, context) {
if(pkg.name === '@kadena/js-monorepo') {
const deps = Object.keys({...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {}});
deps.forEach(pkg => {
if(!ALLOWED_ROOT_DEPENDENCIES.includes(pkg)) {
throw new Error(`Root dependency not allowed: ${pkg}`)
}
});
}
return pkg;
}

module.exports = {
hooks: {
readPackage,
},
};
43 changes: 43 additions & 0 deletions .syncpackrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// @ts-check

/** @type {import("syncpack").RcFile} */
const config = {
versionGroups: [
{
label: 'Internal packages that have inconsistent version usage',
packages: ['**'],
dependencies: [
'@kadena/chainweb-node-client',
'@kadena/client',
'@kadena/fonts',
'@kadena/pactjs-cli',
'@kadena-dev/eslint-plugin',
],
isIgnored: true, // Toggle flag or or remove group to see inconsistencies
},
{
label: 'Internal dev packages are pinned to `workspace:*`',
packages: ['**'],
dependencies: ['@kadena-dev/*', '@kadena/types'],
dependencyTypes: ['dev'],
pinVersion: 'workspace:*',
},
{
label: 'Internal production packages are pinned to `workspace:*`',
packages: ['**'],
dependencies: ['kadena.js', '@kadena/*'],
dependencyTypes: ['prod'],
pinVersion: 'workspace:*',
},
{
label:
'Types and internal dev packages are banned from dependencies (only allowed in devDependencies)',
packages: ['**'],
dependencies: ['@types/*', '*/types', '@kadena-dev/*'],
dependencyTypes: ['prod'],
isBanned: true,
},
],
};

module.exports = config;
Loading

1 comment on commit e969f3c

@vercel
Copy link

@vercel vercel bot commented on e969f3c Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react-ui – ./packages/libs/react-ui

react-ui-delta.vercel.app
react-ui-kadena-js.vercel.app
react-ui-git-main-kadena-js.vercel.app
react-ui.kadena.io

Please sign in to comment.