Skip to content

Commit

Permalink
Update to leverage pnpm for monorepo (vercel#37259)
Browse files Browse the repository at this point in the history
* Update to leverage pnpm for monorepo

* update compiled

* update stats action

* update ci install step

* update ci

* add test dep

* update invoking scripts

* update caching

* skip cache for now

* update dep

* update packages and fix babel

* update compiled

* update lint

* update test

* update ci

* update pnpm store caching

* update path for windows

* update restore-key config

* update caching

* remove extra build azure stage

* re-add checkout

* update setting pnpm store

* bump

* remove azure caching as pnpm is faster to download

* update contributing

* apply suggestions

* remove install-peers

* prepublish -> prepublishOnly

* prepublish -> prepublishOnly more

* more yarn -> pnpm references

* more yarn -> pnpm references take 2

* use workspace protocol for root package.json

Co-authored-by: Steven <[email protected]>
  • Loading branch information
ijjk and styfle authored May 29, 2022
1 parent 748ce12 commit f7b8131
Show file tree
Hide file tree
Showing 139 changed files with 137,198 additions and 136,887 deletions.
3 changes: 2 additions & 1 deletion .github/actions/next-stats-action/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ LABEL repository="https://github.com/vercel/next-stats-action"
COPY . /next-stats

# Install node_modules
RUN cd /next-stats && yarn install --production
RUN npm i -g [email protected]
RUN cd /next-stats && pnpm install --production

RUN git config --global user.email 'stats@localhost'
RUN git config --global user.name 'next stats'
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/next-stats-action/src/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path')
const os = require('os')

const benchTitle = 'Page Load Tests'
const workDir = path.join(__dirname, '../.work')
const workDir = path.join(os.tmpdir(), 'next-stats')
const mainRepoName = 'main-repo'
const diffRepoName = 'diff-repo'
const mainRepoDir = path.join(workDir, mainRepoName)
Expand Down
21 changes: 11 additions & 10 deletions .github/actions/next-stats-action/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
for (const dir of repoDirs) {
logger(`Running initial build for ${dir}`)
if (!actionInfo.skipClone) {
const usePnpm = await fs.pathExists(path.join(dir, 'pnpm-lock.yaml'))
let buildCommand = `cd ${dir}${
!statsConfig.skipInitialInstall
? ' && yarn install --network-timeout 1000000'
? usePnpm
? ' && pnpm install && pnpm run build'
: ' && yarn install --network-timeout 1000000'
: ''
}`

Expand All @@ -118,15 +121,13 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
// in case of noisy environment slowing down initial repo build
await exec(buildCommand, false, { timeout: 5 * 60 * 1000 })
}
await fs.copy(
path.join(__dirname, '../native'),
path.join(dir, 'packages/next-swc/native')
)
// TODO: remove after next stable release (current v12.0.4)
await fs.copy(
path.join(__dirname, '../native'),
path.join(dir, 'packages/next/native')
)

await fs
.copy(
path.join(__dirname, '../native'),
path.join(dir, 'packages/next-swc/native')
)
.catch(console.error)

logger(`Linking packages in ${dir}`)
const pkgPaths = await linkPackages(dir)
Expand Down
6 changes: 5 additions & 1 deletion .github/actions/next-stats-action/src/run/collect-diffs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ module.exports = async function collectDiffs(
}

if (curFiles.length > 0) {
const prettierPath = path.join(
__dirname,
'../../node_modules/.bin/prettier'
)
await exec(
`cd "${process.env.LOCAL_STATS ? process.cwd() : diffingDir}" && ` +
`yarn prettier --write ${curFiles
`${prettierPath} --write ${curFiles
.map((f) => path.join(diffingDir, f))
.join(' ')}`
)
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/next-stats-action/src/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ async function linkPkgs(pkgDir = '', pkgPaths) {
await fs.writeFile(pkgJsonPath, JSON.stringify(pkgData, null, 2), 'utf8')

await fs.remove(yarnEnvValues.YARN_CACHE_FOLDER)
await exec(`cd ${pkgDir} && yarn install`, false, {
await exec(`cd ${pkgDir} && pnpm install`, false, {
env: yarnEnvValues,
})
}
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Choose the right checklist for the change that you're making:

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
60 changes: 39 additions & 21 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
NAPI_CLI_VERSION: 2.7.0
TURBO_VERSION: 1.2.9
RUST_TOOLCHAIN: nightly-2022-02-23
PNPM_VERSION: 7.1.6

jobs:
check-examples:
Expand Down Expand Up @@ -49,7 +50,22 @@ jobs:
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off

- run: yarn install --frozen-lockfile --check-files
- run: npm i -g pnpm@${PNPM_VERSION}

- id: get-store-path
run: echo ::set-output name=STORE_PATH::$(pnpm store path)

- uses: actions/cache@v3
id: cache-pnpm-store
with:
path: ${{ steps.get-store-path.outputs.STORE_PATH }}
key: pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-
pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm install
- run: pnpm run build
- run: node run-tests.js --timings --write-timings -g 1/1
- run: node ./scripts/fetch-tags.mjs ${{ github.sha }}

Expand Down Expand Up @@ -87,13 +103,15 @@ jobs:
node-version: 16
check-latest: true

- run: npm i -g pnpm@${PNPM_VERSION}

- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}
- run: ./scripts/check-manifests.js
- run: yarn lint
- run: pnpm lint

rust-check:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -740,7 +758,8 @@ jobs:
- run: node run-tests.js test/integration/production/test/index.test.js
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
# test rsc hydration on firefox due to limited support of TransformStream api
- run: xvfb-run yarn jest test/integration/react-streaming-and-server-components/test/index.test.js -t "should handle streaming server components correctly"
- run: npm i -g pnpm@${PNPM_VERSION}
- run: xvfb-run pnpm testheadless test/integration/react-streaming-and-server-components/test/index.test.js -t "should handle streaming server components correctly"
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

testSafari:
Expand Down Expand Up @@ -1054,7 +1073,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@${{ env.NAPI_CLI_VERSION }} turbo@${{ env.TURBO_VERSION }}
- run: npm i -g @napi-rs/cli@${{ env.NAPI_CLI_VERSION }} turbo@${{ env.TURBO_VERSION }} pnpm@${PNPM_VERSION}
- name: Build
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
run: turbo run build-native --cache-dir=".turbo" -- --release
Expand Down Expand Up @@ -1149,17 +1168,17 @@ jobs:
- host: macos-latest
target: 'x86_64-apple-darwin'
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native --cache-dir=".turbo" -- --release
strip -x packages/next-swc/native/next-swc.*.node
- host: windows-latest
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native --cache-dir=".turbo" -- --release
target: 'x86_64-pc-windows-msvc'
- host: windows-latest
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native --cache-dir=".turbo" -- --release --target i686-pc-windows-msvc
target: 'i686-pc-windows-msvc'
- host: ubuntu-latest
Expand All @@ -1170,7 +1189,7 @@ jobs:
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add x86_64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}" &&
turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-gnu &&
strip packages/next-swc/native/next-swc.*.node
- host: ubuntu-latest
Expand All @@ -1181,7 +1200,7 @@ jobs:
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add x86_64-unknown-linux-musl &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}" &&
turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl &&
strip packages/next-swc/native/next-swc.*.node
- host: macos-latest
Expand All @@ -1192,7 +1211,7 @@ jobs:
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-apple-darwin
strip -x packages/next-swc/native/next-swc.*.node
- host: ubuntu-latest
Expand All @@ -1203,7 +1222,7 @@ jobs:
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add aarch64-unknown-linux-gnu &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}" &&
export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc &&
turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-gnu &&
llvm-strip -x packages/next-swc/native/next-swc.*.node
Expand All @@ -1213,7 +1232,7 @@ jobs:
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native-no-plugin --cache-dir=".turbo" -- --release --target armv7-unknown-linux-gnueabihf
arm-linux-gnueabihf-strip packages/next-swc/native/next-swc.*.node
- host: ubuntu-latest
Expand All @@ -1223,7 +1242,7 @@ jobs:
export CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang"
export CXX="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++"
export PATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-linux-android
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip packages/next-swc/native/next-swc.*.node
- host: ubuntu-latest
Expand All @@ -1233,15 +1252,15 @@ jobs:
export CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang"
export CXX="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang++"
export PATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native-no-plugin --cache-dir=".turbo" -- --release --target armv7-linux-androideabi
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip packages/next-swc/native/next-swc.*.node
- host: ubuntu-latest
target: 'aarch64-unknown-linux-musl'
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: >-
set -e &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" &&
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}" &&
rustup toolchain install "${RUST_TOOLCHAIN}" &&
rustup default "${RUST_TOOLCHAIN}" &&
rustup target add aarch64-unknown-linux-musl &&
Expand All @@ -1250,7 +1269,7 @@ jobs:
- host: windows-latest
target: 'aarch64-pc-windows-msvc'
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native-no-plugin --cache-dir=".turbo" -- --release --target aarch64-pc-windows-msvc
if: ${{ needs.build.outputs.isRelease == 'true' }}
needs: build
Expand Down Expand Up @@ -1301,7 +1320,6 @@ jobs:
with:
node-version: 16
check-latest: true
cache: yarn

- name: Install
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -1397,8 +1415,8 @@ jobs:
whoami
env
freebsd-version
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}"
yarn --cwd packages/next-swc build-native --release --target x86_64-unknown-freebsd
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
pnpm --filter=@next/swc build-native --release --target x86_64-unknown-freebsd
rm -rf node_modules
rm -rf packages/next-swc/target
- name: Upload artifact
Expand Down Expand Up @@ -1436,7 +1454,7 @@ jobs:
override: true
target: wasm32-unknown-unknown

- run: npm i -g turbo@${{ env.TURBO_VERSION }}
- run: npm i -g turbo@${{ env.TURBO_VERSION }} pnpm@${PNPM_VERSION}

- name: Turbo cache
id: turbo-cache
Expand Down Expand Up @@ -1482,7 +1500,7 @@ jobs:
node-version: 16
check-latest: true

- run: npm i -g turbo@${{ env.TURBO_VERSION }}
- run: npm i -g turbo@${{ env.TURBO_VERSION }} pnpm@${PNPM_VERSION}

- name: Install Rust
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pull_request_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:

name: Generate Pull Request Stats

env:
NAPI_CLI_VERSION: 2.7.0
TURBO_VERSION: 1.2.9
RUST_TOOLCHAIN: nightly-2022-02-23
PNPM_VERSION: 7.1.6

jobs:
build-native-dev:
name: Build dev binary for tests
Expand Down Expand Up @@ -78,7 +84,7 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/[email protected]
- run: npm i -g turbo@1.2.9
- run: npm i -g turbo@${TURBO_VERSION} pnpm@${PNPM_VERSION}

- name: Build
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
Expand Down
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
save-exact = true
tag-version-prefix=""
strict-peer-dependencies = false
auto-install-peers = true
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ test-timings.json
test/**/out/**
bench/nested-deps/pages/**/*
bench/nested-deps/components/**/*
pnpm-lock.yaml
1 change: 1 addition & 0 deletions .prettierignore_staged
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ packages/next/bundles/webpack/packages/*.runtime.js
lerna.json
packages/next-codemod/transforms/__testfixtures__/**/*
packages/next-codemod/transforms/__tests__/**/*
pnpm-lock.yaml
Loading

0 comments on commit f7b8131

Please sign in to comment.