Skip to content

Commit

Permalink
Merge pull request #135 from rollup/sync-91352494
Browse files Browse the repository at this point in the history
docs(en): merge rollup/master into rollup-docs-cn/master @ 9135249
  • Loading branch information
waynzh authored Apr 29, 2024
2 parents ed108ee + 01ab861 commit aed5919
Show file tree
Hide file tree
Showing 231 changed files with 6,641 additions and 2,339 deletions.
138 changes: 114 additions & 24 deletions .github/workflows/build-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ jobs:
target: x86_64-apple-darwin
build: >-
set -e &&
npm run build:napi -- --release &&
strip -x *.node
npm run build:napi -- --release --target x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
build: >-
set -e &&
rustup target add aarch64-apple-darwin &&
npm run build:napi -- --release --target aarch64-apple-darwin &&
strip -x *.node
npm run build:napi -- --release --target aarch64-apple-darwin
# Linux
- host: ubuntu-latest
Expand All @@ -121,14 +119,13 @@ jobs:
build: >-
set -e &&
rustup target add x86_64-unknown-linux-gnu &&
npm run build:napi -- --release --target x86_64-unknown-linux-gnu &&
strip *.node
npm run build:napi -- --release --target x86_64-unknown-linux-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: >-
set -e &&
npm run build:napi -- --release && strip *.node
npm run build:napi -- --release
- host: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
zig: true
Expand All @@ -137,8 +134,13 @@ jobs:
sudo apt-get install gcc-arm-linux-gnueabihf -y
build: >-
set -e &&
npm run build:napi -- --release --target armv7-unknown-linux-gnueabihf &&
arm-linux-gnueabihf-strip *.node
npm run build:napi -- --release --target armv7-unknown-linux-gnueabihf
- host: ubuntu-latest
target: armv7-unknown-linux-musleabihf
zig: true
build: >-
set -e &&
npm run build:napi -- --release --target armv7-unknown-linux-musleabihf
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
Expand All @@ -147,8 +149,7 @@ jobs:
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup default nightly-2023-10-05 &&
rustup target add aarch64-unknown-linux-gnu &&
npm run build:napi -- --release --target aarch64-unknown-linux-gnu &&
aarch64-unknown-linux-gnu-strip *.node
npm run build:napi -- --release --target aarch64-unknown-linux-gnu
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
Expand All @@ -157,20 +158,17 @@ jobs:
export JEMALLOC_SYS_WITH_LG_PAGE=16 &&
rustup default nightly-2023-10-05 &&
rustup target add aarch64-unknown-linux-musl &&
RUSTFLAGS='-C target-feature=-crt-static -C linker=aarch64-linux-musl-gcc' npm run build:napi -- --release --target aarch64-unknown-linux-musl &&
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
RUSTFLAGS='-C target-feature=-crt-static -C linker=aarch64-linux-musl-gcc' npm run build:napi -- --release --target aarch64-unknown-linux-musl
- host: ubuntu-latest
target: armv7-linux-androideabi
build: >-
set -e &&
npm run build:napi -- --release --target armv7-linux-androideabi &&
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
npm run build:napi -- --release --target armv7-linux-androideabi
- host: ubuntu-latest
target: aarch64-linux-android
build: >-
set -e &&
npm run build:napi -- --release --target aarch64-linux-android &&
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
npm run build:napi -- --release --target aarch64-linux-android
- host: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
setup: |
Expand All @@ -179,8 +177,7 @@ jobs:
build: >-
set -e &&
rustup target add riscv64gc-unknown-linux-gnu &&
npm run build:napi -- --release --target riscv64gc-unknown-linux-gnu &&
riscv64-linux-gnu-strip *.node
npm run build:napi -- --release --target riscv64gc-unknown-linux-gnu
- host: ubuntu-latest
target: powerpc64le-unknown-linux-gnu
setup: |
Expand All @@ -189,8 +186,7 @@ jobs:
build: >-
set -e &&
export CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc && rustup target add powerpc64le-unknown-linux-gnu &&
npm run build:napi -- --release --target powerpc64le-unknown-linux-gnu &&
powerpc64le-linux-gnu-strip *.node
npm run build:napi -- --release --target powerpc64le-unknown-linux-gnu
- host: ubuntu-latest
target: s390x-unknown-linux-gnu
setup: |
Expand All @@ -200,8 +196,7 @@ jobs:
set -e &&
export CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc &&
rustup target add s390x-unknown-linux-gnu &&
npm run build:napi -- --release --target s390x-unknown-linux-gnu &&
s390x-linux-gnu-strip *.node
npm run build:napi -- --release --target s390x-unknown-linux-gnu
name: Build ${{ matrix.settings.name || matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
timeout-minutes: 30
Expand Down Expand Up @@ -273,6 +268,100 @@ jobs:
if-no-files-found: error
if: ${{ !matrix.settings.is-wasm-build }}

# smoke test for some architectures that do not receive the full test suite
smoke-test:
permissions:
packages: write # for caching container images
name: Smoke Test ${{ matrix.settings.target }}
needs:
- build
strategy:
fail-fast: false
matrix:
settings:
- arch: aarch64
distro: ubuntu_latest
target: aarch64-unknown-linux-gnu
- arch: aarch64
distro: alpine_latest
target: aarch64-unknown-linux-musl
- arch: armv7
distro: ubuntu_latest
target: armv7-unknown-linux-gnueabihf
# There is a bug that hangs the build when running npm
# - arch: armv7
# distro: alpine_latest
# target: armv7-unknown-linux-musleabihf
- arch: ppc64le
distro: ubuntu_latest
target: powerpc64le-unknown-linux-gnu
use-nvm: true
- arch: s390x
distro: ubuntu_latest
target: s390x-unknown-linux-gnu
use-nvm: true
# I could not find a way to install Node without compiling from source
# - arch: riscv64
# distro: ubuntu_latest
# target: riscv64gc-unknown-linux-gnu
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Build JS
run: npm run build:cjs
- name: Download napi artifacts
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: dist/
- name: Run Smoke Test
uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.settings.arch }}
distro: ${{ matrix.settings.distro }}
githubToken: ${{ github.token }}
install: |
case "${{ matrix.settings.distro }}" in
ubuntu*)
apt-get update -y
apt-get install -y curl git
if [[ -z "${{ matrix.settings.use-nvm }}" ]]; then
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs
fi
;;
alpine*)
apk add nodejs npm git
;;
esac
run: |
set -e
if [[ -n "${{ matrix.settings.use-nvm }}" ]]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.nvm/nvm.sh
nvm install --lts
fi
echo "Node: $(node -v)"
echo "npm: $(npm -v)"
git config --global --add safe.directory /home/runner/work/rollup/rollup
chmod +x dist/bin/rollup
dist/bin/rollup --version | grep -E 'rollup v[0-9]+\.[0-9]+\.[0-9]+'
mv dist dist-build
node dist-build/bin/rollup --config rollup.config.ts --configPlugin typescript --configTest --forceExit
cp dist-build/rollup.*.node dist/
dist/bin/rollup --version | grep -E 'rollup v[0-9]+\.[0-9]+\.[0-9]+'
test:
name: Test${{ matrix.additionalName || '' }} Node ${{ matrix.node }} (${{ matrix.settings.target }})
needs:
Expand Down Expand Up @@ -352,8 +441,9 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
needs:
- test
- lint
- test
- smoke-test
# This needs to be adapted for Rollup 5
if: startsWith(github.ref_name, 'v4')
steps:
Expand Down
151 changes: 151 additions & 0 deletions .github/workflows/performance-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Performance Report
env:
BUILD_BOOTSTRAP_CJS: mv dist dist-build && node dist-build/bin/rollup --config rollup.config.ts --configPlugin typescript --configTest --forceExit && rm -rf dist-build

on:
pull_request:
types:
- synchronize
- opened
- reopened

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build-artefacts:
strategy:
matrix:
settings:
- name: current
ref: refs/pull/${{ github.event.number }}/merge
- name: previous
ref: ${{github.event.pull_request.base.ref}}
name: Build ${{matrix.settings.name}} artefact
runs-on: ubuntu-latest
steps:
- name: Checkout Commit
uses: actions/checkout@v4
with:
ref: ${{matrix.settings.ref}}
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2023-10-05
targets: x86_64-unknown-linux-gnu
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
rust/target/
key: cargo-cache-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: cargo-cache
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Build artefacts 123
run: npm exec -- concurrently -c green,blue 'npm:build:napi -- --release' 'npm:build:cjs' && npm run build:copy-native && ${{env.BUILD_BOOTSTRAP_CJS}} && npm run build:copy-native
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.settings.name }}
path: dist/
if-no-files-found: error

report:
needs: build-artefacts
permissions:
pull-requests: write
runs-on: ubuntu-latest
name: Report Performance
steps:
- name: Checkout Commit
uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.number }}/merge
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2023-10-05
targets: x86_64-unknown-linux-gnu
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
rust/target/
key: cargo-cache-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: cargo-cache
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: _benchmark
- name: Change rollup import in internal benchmark
run: |
echo "export { rollup as previousRollup, VERSION as previousVersion } from '../../_benchmark/previous/rollup.js';" > ./scripts/perf-report/rollup-artefacts.js
echo "export { rollup as newRollup } from '../../_benchmark/current/rollup.js';" >> ./scripts/perf-report/rollup-artefacts.js
- name: Run internal benchmark
run: node --expose-gc scripts/perf-report/index.js
- name: Install benchmark tool
run: cargo install --locked hyperfine
- name: Run Rough benchmark
run: |
hyperfine --warmup 1 --export-markdown _benchmark/rough-report.md --show-output --runs 3 \
'node _benchmark/previous/bin/rollup -i ./perf/entry.js -o _benchmark/result/previous.js' \
'node _benchmark/current/bin/rollup -i ./perf/entry.js -o _benchmark/result/current.js'
- name: Combine bechmark reports
run: |
echo "# Performance report!" > _benchmark/result.md
echo "## Rough benchmark" >> _benchmark/result.md
cat _benchmark/rough-report.md >> _benchmark/result.md
echo "## Internal benchmark" >> _benchmark/result.md
cat _benchmark/internal-report.md >> _benchmark/result.md
- name: Find Performance report
uses: peter-evans/find-comment@v3
id: findPerformanceReport
with:
issue-number: ${{ github.event.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Performance report'
- name: Create or update Performance report
uses: peter-evans/create-or-update-comment@v4
id: createOrUpdatePerformanceReport
with:
comment-id: ${{ steps.findPerformanceReport.outputs.comment-id }}
issue-number: ${{ github.event.number }}
edit-mode: replace
body-path: _benchmark/result.md
Loading

0 comments on commit aed5919

Please sign in to comment.