Skip to content

Commit

Permalink
Merge branch 'canary' into example/update-storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jun 14, 2023
2 parents 49cd139 + cc46d97 commit 58adc11
Show file tree
Hide file tree
Showing 708 changed files with 29,454 additions and 13,467 deletions.
2 changes: 1 addition & 1 deletion .config/nextest.toml
Expand Up @@ -5,5 +5,5 @@ filter = "package(next-dev-tests)"
leak-timeout = "500ms"
retries = 2
slow-timeout = "60s"
threads-required = 2
threads-required = 4
failure-output = "immediate-final"
31 changes: 4 additions & 27 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -1,34 +1,11 @@
# Learn how to add code owners here:
# https://help.github.com/en/articles/about-code-owners

* @timneutkens @ijjk @shuding @huozhi @feedthejim
/.git* @vercel/next-js
/docs/ @vercel/next-js @leerob
/errors/ @vercel/next-js @leerob
/examples/ @vercel/next-js @leerob @steven-tey
/scripts/ @vercel/next-js
/.alex* @vercel/next-js @leerob
/.eslint* @vercel/next-js @leerob
/.prettier* @vercel/next-js @leerob
/*.md @vercel/next-js @leerob
/packages/create-next-app/ @vercel/next-js
/pnpm-lock.yaml @vercel/next-js @vercel/web-tooling
# Codeowners now use Vercel Spaces
# Search .vercel.approvers for all files

# Image Component (@styfle)

/**/*image* @timneutkens @ijjk @shuding @styfle @huozhi
/**/*image*/** @timneutkens @ijjk @shuding @styfle @huozhi
/packages/next/client/use-intersection.tsx @timneutkens @ijjk @shuding @styfle
/packages/next/server/lib/squoosh/ @timneutkens @ijjk @shuding @styfle
/packages/next/server/serve-static.ts @timneutkens @ijjk @shuding @styfle @huozhi
/packages/next/server/config.ts @timneutkens @ijjk @shuding @styfle @huozhi
/**/*image* @timneutkens @ijjk @shuding @styfle @huozhi @vercel/devex
/**/*image*/** @timneutkens @ijjk @shuding @styfle @huozhi @vercel/devex

# Tooling & Telemetry

/packages/next/src/build/ @timneutkens @ijjk @shuding @vercel/web-tooling @huozhi
/packages/next/src/telemetry/ @timneutkens @ijjk @shuding @padmaia
/packages/next-swc/ @timneutkens @ijjk @shuding @vercel/web-tooling
Cargo.toml @timneutkens @ijjk @shuding @vercel/web-tooling
Cargo.lock @timneutkens @ijjk @shuding @vercel/web-tooling
/.cargo/config.toml @timneutkens @ijjk @shuding @vercel/web-tooling
/.config/nextest.toml @timneutkens @ijjk @shuding @vercel/web-tooling
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/4.docs_request.yml
Expand Up @@ -4,6 +4,12 @@ title: 'Docs: '
labels:
- 'template: documentation'
body:
- type: markdown
attributes:
value: Before opening this issue to request a docs improvement, is this something you can help us with? Your contributions are welcomed and appreciated. See our [Docs Contribution Guide](https://nextjs.org/docs/community/contribution-guide) to learn how to edit the Next.js docs.
- type: markdown
attributes:
value: Thank you for helping us improve the docs!
- type: textarea
attributes:
label: What is the improvement or update you wish to see?
Expand Down
11 changes: 9 additions & 2 deletions .github/actions/next-stats-action/Dockerfile
@@ -1,13 +1,20 @@
FROM node:16-bullseye
FROM ubuntu:22.04

LABEL com.github.actions.name="Next.js PR Stats"
LABEL com.github.actions.description="Compares stats of a PR with the main branch"
LABEL repository="https://github.com/vercel/next-stats-action"

COPY . /next-stats

RUN apt update && apt upgrade -y
RUN apt install unzip wget curl nano htop screen build-essential pkg-config libssl-dev git build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libreadline-dev libffi-dev python3 moreutils jq iproute2 openssh-server sudo whois dnsutils -y

RUN ln $(which python3) /usr/bin/python

RUN curl -sfLS https://install-node.vercel.app/v18 | bash -s -- -f

# Install node_modules
RUN npm i -g pnpm@7.24.3
RUN npm i -g pnpm@7.24.3 yarn@1.22.19
RUN cd /next-stats && pnpm install --production

RUN git config --global user.email 'stats@localhost'
Expand Down
4 changes: 0 additions & 4 deletions .github/actions/next-stats-action/src/constants.js
Expand Up @@ -8,9 +8,6 @@ const mainRepoDir = path.join(workDir, 'main-repo')
const diffRepoDir = path.join(workDir, 'diff-repo')
const statsAppDir = path.join(workDir, 'stats-app')
const diffingDir = path.join(workDir, 'diff')
const yarnEnvValues = {
YARN_CACHE_FOLDER: path.join(workDir, 'yarn-cache'),
}
const allowedConfigLocations = [
'./',
'.stats-app',
Expand All @@ -25,6 +22,5 @@ module.exports = {
mainRepoDir,
diffRepoDir,
statsAppDir,
yarnEnvValues,
allowedConfigLocations,
}
22 changes: 13 additions & 9 deletions .github/actions/next-stats-action/src/index.js
Expand Up @@ -64,22 +64,20 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
statsConfig.mainRepo = actionInfo.prRepo
}

// clone main repository/ref
if (!actionInfo.skipClone) {
await cloneRepo(statsConfig.mainRepo, mainRepoDir, statsConfig.mainBranch)
}
/* eslint-disable-next-line */
actionInfo.commitId = await getCommitId(diffRepoDir)
let mainNextSwcVersion

if (!actionInfo.skipClone) {
let mainRef = statsConfig.mainBranch

if (actionInfo.isRelease) {
logger('Release detected, resetting mainRepo to last stable tag')
const lastStableTag = await getLastStable(mainRepoDir, actionInfo.prRef)
logger('Release detected, using last stable tag')
const lastStableTag = await getLastStable(diffRepoDir, actionInfo.prRef)
mainRef = lastStableTag
mainNextSwcVersion = lastStableTag
if (!lastStableTag) throw new Error('failed to get last stable tag')
console.log('using latestStable', lastStableTag)
await checkoutRef(lastStableTag, mainRepoDir)

/* eslint-disable-next-line */
actionInfo.lastStableTag = lastStableTag
Expand All @@ -90,12 +88,15 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
/* eslint-disable-next-line */
actionInfo.commentEndpoint = `https://api.github.com/repos/${statsConfig.mainRepo}/commits/${actionInfo.commitId}/comments`
}
} else if (statsConfig.autoMergeMain) {
}

await cloneRepo(statsConfig.mainRepo, mainRepoDir, mainRef)

if (!actionInfo.isRelease && statsConfig.autoMergeMain) {
logger('Attempting auto merge of main branch')
await mergeBranch(statsConfig.mainBranch, mainRepoDir, diffRepoDir)
}
}

let mainRepoPkgPaths
let diffRepoPkgPaths

Expand Down Expand Up @@ -132,6 +133,9 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
)
.catch(console.error)

console.log(await exec(`ls ${path.join(__dirname, '../native')}`))
console.log(await exec(`cd ${dir} && ls ${dir}/packages/next-swc/native`))

logger(`Linking packages in ${dir}`)
const isMainRepo = dir === mainRepoDir
const pkgPaths = await linkPackages({
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/next-stats-action/src/prepare/action-info.js
Expand Up @@ -61,6 +61,10 @@ module.exports = function actionInfo() {
(GITHUB_REF || '').includes('canary'),
}

if (info.isRelease) {
info.prRef = 'canary'
}

// get comment
if (GITHUB_EVENT_PATH) {
const event = require(GITHUB_EVENT_PATH)
Expand Down
52 changes: 18 additions & 34 deletions .github/actions/next-stats-action/src/prepare/repo-setup.js
Expand Up @@ -3,7 +3,6 @@ const fs = require('fs-extra')
const exec = require('../util/exec')
const { remove } = require('fs-extra')
const logger = require('../util/logger')
const semver = require('semver')
const execa = require('execa')

module.exports = (actionInfo) => {
Expand All @@ -14,21 +13,16 @@ module.exports = (actionInfo) => {
`git clone ${actionInfo.gitRoot}${repoPath} --single-branch --branch ${branch} --depth=${depth} ${dest}`
)
},
async getLastStable(repoDir = '', ref) {
const { stdout } = await exec(`cd ${repoDir} && git tag -l`)
const tags = stdout.trim().split('\n')
let lastStableTag
async getLastStable(repoDir = '') {
const { stdout } = await exec(`cd ${repoDir} && git describe`)
const tag = stdout.trim()

for (let i = tags.length - 1; i >= 0; i--) {
const curTag = tags[i]
// stable doesn't include `-canary` or `-beta`
if (!curTag.includes('-') && !ref.includes(curTag)) {
if (!lastStableTag || semver.gt(curTag, lastStableTag)) {
lastStableTag = curTag
}
}
if (!tag || !tag.startsWith('v')) {
throw new Error(`Failed to get tag info ${stdout}`)
}
return lastStableTag
const tagParts = tag.split('-canary')[0].split('.')
// last stable tag will always be 1 patch less than canary
return `${tagParts[0]}.${tagParts[1]}.${Number(tagParts[2]) - 1}`
},
async getCommitId(repoDir = '') {
const { stdout } = await exec(`cd ${repoDir} && git rev-parse HEAD`)
Expand Down Expand Up @@ -79,6 +73,7 @@ module.exports = (actionInfo) => {
}
const pkgData = require(pkgDataPath)
const { name } = pkgData

pkgDatas.set(name, {
pkgDataPath,
pkg,
Expand All @@ -103,7 +98,7 @@ module.exports = (actionInfo) => {
if (!pkgData.files) {
pkgData.files = []
}
pkgData.files.push('native/*')
pkgData.files.push('native')
require('console').log(
'using swc binaries: ',
await exec(`ls ${path.join(path.dirname(pkgDataPath), 'native')}`)
Expand All @@ -124,18 +119,11 @@ module.exports = (actionInfo) => {
pkgData.dependencies['@next/swc'] =
pkgDatas.get('@next/swc').packedPkgPath
} else {
pkgData.files.push('native/*')
pkgData.files.push('native')
}
}
}

if (pkgData?.scripts?.prepublishOnly) {
// There's a bug in `pnpm pack` where it will run
// the prepublishOnly script and that will fail.
// See https://github.com/pnpm/pnpm/issues/2941
delete pkgData.scripts.prepublishOnly
}

await fs.writeFile(
pkgDataPath,
JSON.stringify(pkgData, null, 2),
Expand All @@ -147,21 +135,17 @@ module.exports = (actionInfo) => {
// to the correct versions
await Promise.all(
Array.from(pkgDatas.keys()).map(async (pkgName) => {
const { pkg, pkgPath, pkgData, packedPkgPath } = pkgDatas.get(pkgName)
// Copied from pnpm source: https://github.com/pnpm/pnpm/blob/5a5512f14c47f4778b8d2b6d957fb12c7ef40127/releasing/plugin-commands-publishing/src/pack.ts#L96
const tmpTarball = path.join(
pkgPath,
`${pkgData.name.replace('@', '').replace('/', '-')}-${
pkgData.version
}.tgz`
)
await execa('pnpm', ['pack'], {
const { pkgPath, packedPkgPath } = pkgDatas.get(pkgName)

await execa('yarn', ['pack', '-f', packedPkgPath], {
cwd: pkgPath,
env: {
...process.env,
COREPACK_ENABLE_STRICT: '0',
},
})
await fs.copyFile(tmpTarball, packedPkgPath)
})
)

return pkgPaths
},
}
Expand Down
25 changes: 4 additions & 21 deletions .github/actions/next-stats-action/src/run/index.js
@@ -1,13 +1,12 @@
const path = require('path')
const fs = require('fs-extra')
const getPort = require('get-port')
const glob = require('../util/glob')
const exec = require('../util/exec')
const logger = require('../util/logger')
const getDirSize = require('./get-dir-size')
const collectStats = require('./collect-stats')
const collectDiffs = require('./collect-diffs')
const { statsAppDir, diffRepoDir, yarnEnvValues } = require('../constants')
const { statsAppDir, diffRepoDir } = require('../constants')

async function runConfigs(
configs = [],
Expand Down Expand Up @@ -59,13 +58,7 @@ async function runConfigs(

const buildStart = Date.now()
console.log(
await exec(
`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`,
false,
{
env: yarnEnvValues,
}
)
await exec(`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`, false)
)
curStats.General.buildDuration = Date.now() - buildStart

Expand Down Expand Up @@ -160,13 +153,7 @@ async function runConfigs(

const secondBuildStart = Date.now()
console.log(
await exec(
`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`,
false,
{
env: yarnEnvValues,
}
)
await exec(`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`, false)
)
curStats.General.buildDurationCached = Date.now() - secondBuildStart
}
Expand Down Expand Up @@ -203,13 +190,9 @@ 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} && pnpm install --strict-peer-dependencies=false`,
false,
{
env: yarnEnvValues,
}
false
)
}

Expand Down
65 changes: 65 additions & 0 deletions .github/actions/setup-rust/action.yml
@@ -0,0 +1,65 @@
name: 'Rust Setup'
description: 'Sets up the Rust toolchain for CI'
inputs:
targets:
description: 'Comma-separated list of target triples to install for this toolchain'
required: false
components:
description: 'Comma-separated list of components to be additionally installed'
required: false
skip-install:
description: 'Sets environment variables without installing the rust toolchain'
required: false

runs:
using: 'composite'
steps:
- name: 'Get toolchain version from file'
id: file
shell: bash
run: echo "toolchain=$(cat ./rust-toolchain)" >> $GITHUB_OUTPUT

- shell: bash
run: |
: force toolchain version
echo "RUST_TOOLCHAIN=${{ steps.file.outputs.toolchain }}" >> $GITHUB_ENV
- shell: bash
run: |
: disable incremental compilation
if [ -z "${CARGO_INCREMENTAL+set}" ]; then
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
fi
- shell: bash
run: |
: enable colors in Cargo output
if [ -z "${CARGO_TERM_COLOR+set}" ]; then
echo CARGO_TERM_COLOR=always >> $GITHUB_ENV
fi
- shell: bash
run: |
: enable rust backtrace
if [ -z "${RUST_BACKTRACE+set}" ]; then
echo RUST_BACKTRACE=short >> $GITHUB_ENV
fi
- shell: bash
run: |
: enable faster cargo sparse registry
if [ -z "${CARGO_REGISTRIES_CRATES_IO_PROTOCOL+set}" ]; then
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
fi
- name: 'Setup Rust toolchain'
uses: dtolnay/rust-toolchain@master
if: ${{ !inputs.skip-install }}
with:
toolchain: ${{ steps.file.outputs.toolchain }}
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}

- name: 'Add cargo problem matchers'
shell: bash
run: echo "::add-matcher::${{ github.action_path }}/matchers.json"

0 comments on commit 58adc11

Please sign in to comment.