Skip to content

Commit 6ccd1ac

Browse files
committed
CI: Update and cleanup next-stats-action, force using pnpm 10.33.0
1 parent 5636400 commit 6ccd1ac

2 files changed

Lines changed: 32 additions & 20 deletions

File tree

.github/actions/next-stats-action/Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# syntax=docker.io/docker/dockerfile:1
22

3-
FROM ubuntu:22.04
3+
FROM ubuntu:24.04
44

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

9-
RUN apt update && apt upgrade -y
10-
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 apache2-utils -y
9+
# use apt-get instead of apt, because apt does not have a stable CLI interface
10+
RUN apt-get update && apt-get upgrade -y
11+
RUN apt-get 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 apache2-utils -y
1112

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

1415
RUN curl -sfLS https://install-node.vercel.app/v20.9.0 | bash -s -- -f
15-
RUN npm i -g corepack@0.31
16+
RUN npm i -g corepack@0.34.6
1617
RUN corepack enable
1718

1819
WORKDIR /next-stats
@@ -21,8 +22,8 @@ WORKDIR /next-stats
2122
COPY package.json ./
2223
RUN pnpm install --production
2324

24-
# caching optimization
25-
COPY . .
25+
# Do this copy after the pnpm install to optimize docker caching
26+
COPY --exclude=node_modules . .
2627

2728
RUN git config --global user.email 'stats@localhost' && \
2829
git config --global user.name 'next stats'

.github/actions/next-stats-action/src/index.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,36 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
110110
logger(`Running initial build for ${dir}`)
111111
if (!actionInfo.skipClone) {
112112
const usePnpm = existsSync(path.join(dir, 'pnpm-lock.yaml'))
113+
if (usePnpm) {
114+
// TODO: we can remove this explicit `corepack use` once Next.js
115+
// 16.3 is released, but we must override it for now because 16.2 uses
116+
// pnpm 9.6.0, which supports different arguments. `diffRepoDir`
117+
// points to the most recent stable tag.
118+
await exec.spawnPromise('corepack use pnpm@10.33.0', {
119+
cwd: dir,
120+
})
121+
}
113122

114123
if (!statsConfig.skipInitialInstall) {
115-
await exec.spawnPromise(
116-
`cd ${dir}${
117-
usePnpm
118-
? // --no-frozen-lockfile is used here to tolerate lockfile
119-
// changes from merging latest changes
120-
// --package-import-method=copy avoids hardlink issues on
121-
// self-hosted runners, and the store is colocated with the
122-
// workdir to avoid EXDEV copy failures on overlayfs runners.
123-
` && pnpm install --no-frozen-lockfile --package-import-method=copy --store-dir=${pnpmStoreDir}`
124-
: ' && yarn install --network-timeout 1000000'
125-
}`,
126-
{ env: { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' } }
127-
)
124+
const command = usePnpm
125+
? 'pnpm install ' +
126+
// tolerate lockfile changes from merging latest changes
127+
'--no-frozen-lockfile ' +
128+
// avoid hardlink issues on self-hosted runners,
129+
'--package-import-method=clone-or-copy ' +
130+
// the store is colocated with the workdir to avoid EXDEV copy
131+
// failures on overlayfs runners.
132+
`--store-dir=${pnpmStoreDir}`
133+
: 'yarn install --network-timeout=1000000'
134+
await exec.spawnPromise(command, {
135+
env: { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' },
136+
cwd: dir,
137+
})
128138

129139
await exec.spawnPromise(
130140
statsConfig.initialBuildCommand ||
131-
`cd ${dir} && ${usePnpm ? 'pnpm build' : 'echo built'}`
141+
(usePnpm ? 'pnpm build' : 'echo built'),
142+
{ cwd: dir }
132143
)
133144
}
134145
}

0 commit comments

Comments
 (0)