Skip to content

Commit 72dea4d

Browse files
--wip-- [skip ci]
1 parent bec3845 commit 72dea4d

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

ci-manual-install.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env bash
2+
# Reproduces the install/build steps of the `electron-e2e` job in
3+
# .github/workflows/codspeed.yml (lines 94-138) on a local machine.
4+
# Skips the turbo cache restore (GHA-only, no-op locally — turbo will rebuild).
5+
6+
set -euo pipefail
7+
8+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
cd "$REPO_ROOT"
10+
11+
# Detect arch for prebuilt tarball URLs.
12+
case "$(uname -m)" in
13+
x86_64) NODE_ARCH=x64; PNPM_ARCH=x64 ;;
14+
aarch64) NODE_ARCH=arm64; PNPM_ARCH=arm64 ;;
15+
arm64) NODE_ARCH=arm64; PNPM_ARCH=arm64 ;;
16+
*) echo "Unsupported arch: $(uname -m)" >&2; exit 1 ;;
17+
esac
18+
19+
case "$(uname -s)" in
20+
Linux) NODE_OS=linux; PNPM_OS=linux ;;
21+
Darwin) NODE_OS=darwin; PNPM_OS=macos ;;
22+
*) echo "Unsupported OS: $(uname -s)" >&2; exit 1 ;;
23+
esac
24+
25+
TOOL_CACHE="$HOME/.cache/ci-manual-install"
26+
mkdir -p "$TOOL_CACHE/bin"
27+
28+
install_node() {
29+
local version="$1"
30+
local dest="$TOOL_CACHE/node/$version/$NODE_ARCH"
31+
if [ ! -x "$dest/bin/node" ]; then
32+
echo ">> Installing Node $version ($NODE_OS-$NODE_ARCH)"
33+
local tarball="/tmp/node-$version-$NODE_OS-$NODE_ARCH.tar.gz"
34+
curl -fL -o "$tarball" \
35+
"https://nodejs.org/dist/v$version/node-v$version-$NODE_OS-$NODE_ARCH.tar.gz"
36+
mkdir -p "$dest"
37+
tar -xzf "$tarball" -C "$dest" --strip-components=1
38+
rm -f "$tarball"
39+
fi
40+
export PATH="$dest/bin:$PATH"
41+
echo ">> node: $(node --version)"
42+
}
43+
44+
install_pnpm() {
45+
local version="$1"
46+
local binary="$TOOL_CACHE/bin/pnpm-$version"
47+
if [ ! -x "$binary" ]; then
48+
echo ">> Installing pnpm $version ($PNPM_OS-$PNPM_ARCH)"
49+
curl -fL -o "$binary" \
50+
"https://github.com/pnpm/pnpm/releases/download/v$version/pnpm-$PNPM_OS-$PNPM_ARCH"
51+
chmod +x "$binary"
52+
fi
53+
ln -sf "$binary" "$TOOL_CACHE/bin/pnpm"
54+
export PATH="$TOOL_CACHE/bin:$PATH"
55+
echo ">> pnpm: $(pnpm --version)"
56+
}
57+
58+
read_field() {
59+
# Extract a top-level string field from a package.json. Used instead of
60+
# depending on jq, which may not be installed on a fresh runner.
61+
node -e "console.log(require('./$1').$2)"
62+
}
63+
64+
# ---------------------------------------------------------------------------
65+
# Repo install + plugin build
66+
# ---------------------------------------------------------------------------
67+
68+
REPO_NODE_VERSION="$(cat .nvmrc)"
69+
install_node "$REPO_NODE_VERSION"
70+
71+
# `pnpm/action-setup@v4` with no version input reads `packageManager` from
72+
# the root package.json.
73+
REPO_PNPM_VERSION="$(node -e "console.log(require('./package.json').packageManager.split('@')[1])")"
74+
install_pnpm "$REPO_PNPM_VERSION"
75+
76+
echo ">> Installing repo dependencies"
77+
pnpm install --frozen-lockfile --prefer-offline
78+
79+
echo ">> Building @codspeed/playwright-plugin"
80+
pnpm turbo run build --filter=@codspeed/playwright-plugin
81+
82+
# ---------------------------------------------------------------------------
83+
# Example install + electron build (uses its own Node version)
84+
# ---------------------------------------------------------------------------
85+
86+
EXAMPLE_DIR="examples/with-electron-and-walltime"
87+
EXAMPLE_NODE_VERSION="$(node -e "console.log(require('./$EXAMPLE_DIR/package.json').engines.node)")"
88+
install_node "$EXAMPLE_NODE_VERSION"
89+
90+
EXAMPLE_PNPM_VERSION="$(node -e "console.log(require('./$EXAMPLE_DIR/package.json').packageManager.split('@')[1])")"
91+
install_pnpm "$EXAMPLE_PNPM_VERSION"
92+
93+
echo ">> Installing example dependencies"
94+
(cd "$EXAMPLE_DIR" && pnpm install --frozen-lockfile)
95+
96+
echo ">> Building electron app"
97+
(cd "$EXAMPLE_DIR" && pnpm --filter @mail-client-demo/electron build)
98+
99+
echo ">> Done."

0 commit comments

Comments
 (0)