forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (97 loc) · 4.58 KB
/
setup-nextjs-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Reusable workflow to setup next.js integration test environment.
name: Setup Next.js
on:
workflow_call:
inputs:
# Allow to specify Next.js version to run integration test against.
# If not specified, will use latest release version including canary.
version:
type: string
jobs:
build_nextjs:
name: Build Next.js for the turbopack integration test
runs-on: ubuntu-latest-16-core-oss
outputs:
output1: ${{ steps.build-next-swc-turbopack-patch.outputs.success }}
steps:
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: 'Setup Rust toolchain'
uses: dtolnay/rust-toolchain@stable
- name: Display runner information
run: echo runner cpu count ${{ steps.cpu-cores.outputs.count }}
- name: Find Next.js latest release version
env:
GH_TOKEN: ${{ github.token }}
run: |
# Grab the latest release version from next.js repo, including prelease. `/releases/latest` will only return latest stable release.
echo NEXJS_LATEST_VERSION=$(gh release --repo vercel/next.js --limit 1 list | sed -n 1p | awk '{print $1}') >> $GITHUB_ENV
- name: Set Next.js release version
run: |
echo "NEXTJS_VERSION=${{ inputs.version != '' && inputs.version || env.NEXJS_LATEST_VERSION }}" >> $GITHUB_ENV
- name: Print Next.js release version to checkout
run: echo "Checking out Next.js ${{ env.NEXTJS_VERSION }}"
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- name: Checkout Next.js
uses: actions/checkout@v4
with:
repository: vercel/next.js
ref: ${{ env.NEXTJS_VERSION }}
- name: Checkout failed test lists
uses: actions/checkout@v4
with:
repository: vercel/turbo
ref: nextjs-integration-test-data
path: integration-test-data
- name: Download binary
uses: actions/download-artifact@v4
with:
path: artifacts
- uses: actions/cache/restore@v3
id: restore-build
with:
path: |
./*
key: ${{ inputs.version }}-${{ github.sha }}
- name: Install dependencies
run: |
wget https://github.com/sharkdp/hyperfine/releases/download/v1.16.1/hyperfine_1.16.1_amd64.deb
sudo dpkg -i hyperfine_1.16.1_amd64.deb
corepack enable
pnpm install --loglevel error
- name: Build next-swc
run: |
hyperfine --min-runs 1 --show-output 'pnpm run --filter=@next/swc build-native --features plugin --release'
echo "Successfully built next-swc with published turbopack"
- name: Build next.js
run: |
pnpm run build
strip packages/next-swc/native/next-swc.*.node
ls -al packages/next-swc/native
# Reduce the size of the cache bit
cd packages/next-swc && cargo clean && cd ../../
echo NEXT_SWC_FILESIZE: $(stat -c %s packages/next-swc/native/next-swc.linux-x64-gnu.node)
node -e "console.log('Host', require('os').arch(), require('os').platform())"
# If input version is published release, detect version by running next.js build.
- name: Detects Next.js build version
run: |
# This is being used in github action to collect test results. Do not change it, or should update ./.github/actions/next-integration-test to match.
docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-jammy /bin/bash -c 'curl https://install-node.vercel.app/v16 | FORCE=1 bash && cd /work && echo RUNNING NEXTJS VERSION: $(packages/next/dist/bin/next --version) && ls -al packages/next-swc/native && node -e "console.log(\"Container\", require(\"os\").arch(), require(\"os\").platform())"'
- name: Temporary test skip
run: |
rm -rf test/integration/jsconfig-paths/test/index.test.js
# Once build completes, creates a cache of the build output
# so subsequent job to actually execute tests can reuse it.
# Note that we do not use upload / download artifacts for this -
# it is too heavyweight for the purpose since we do not need to persist
# the cache across multiple runs.
- name: Store next.js build cache with next-swc
uses: actions/cache/save@v3
id: cache-build
with:
path: |
./*
key: ${{ inputs.version }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt}}-${{ github.run_number }}