Skip to content

Commit

Permalink
[v4.0 release branch] (#5140)
Browse files Browse the repository at this point in the history
* [v4.0] Set minimum Node version to 18

* [v4.0] Switch parser to SWC and introduce native/WASM code (#5073)

* Add native compilation for local NodeJS

* Link instead of copying for faster dev cycles for now

* Parse AST

* Convert first trivial AST to a buffer

* Use SWC for parsing

* Extend AST conversion

* Make AST more similar

* Fix line number issue by creating a new sourcemap (and thus compiler) for each run

* Collect timings

* Add code_length to struct

* Refine parsing

* Extend parsing

* Extend AST: ImportDefaultSpecifier, LiteralBoolean, LiteralNull, ExportDefaultExpression

* Extend AST: ImportNamespaceSpecifier, ExportAll

* Extend AST: BinaryExpression, ArrayPattern, ObjectPattern, AssignmentPatternProperty, ArrayLiteral, ImportExpression

* Extend AST: ConditionalExpression

* Extend AST: FunctionDeclaration, ClassDeclaration, ClassBody, ReturnStatement

* Extend AST: ObjectLiteral, KeyValueProperty

* Extend AST: ShorthandProperty

* Extend AST: GetterProperty, AssignmentExpression, NewExpression, FunctionExpression

* Extend AST: ThrowStatement

* Extend AST: ExportDefaultDeclaration

* Extend AST: AssignmentPattern, AwaitExpression, BreakStatement
Start sorting AST nodes

* Extend AST: TryStatement, CatchClause, ChainExpression

* Extend AST: ClassExpression, ContinueStatement, DebuggerStatement, DoWhileStatement, EmptyStatement

* Extend AST: ExportNamedDeclaration, ForInStatement, ForOfStatement, ForStatement

* Extend AST: IfStatement

* Extend AST: Import attributes

* Extend AST: Literal<RegExp>, Literal<BigInt>

* Extend AST: LogicalExpression

* Extend AST: MetaProperty

* Extend AST: Various Property types

* Extend AST: Progress on classes

* Extend AST: MethodDefinition, PropertyDefinition, PrivateName, ThisExpression

* Extend AST: StaticBlock, Super

* Extend AST: RestElement, SequenceExpression, SwitchCase, SwitchStatement

* Extend AST: TaggedTemplateExpression, TemplateElement, TemplateLiteral, UnaryExpression, UpdateExpression, YieldExpression

* Extend AST: Properties in object patterns

* Finishing Fixes

* More fixes

* Run cargo fmt

* Handle directives

* Minor fixes

* Unicode support

* Fix optional chain expressions

* Adapt tests

* Do not run acorn anymore

* Update lockfile

* Minor fixes

* Move to rust folder

* Separate Rust Node bindings to allow adding WASM bindings in another workspace

* Make Napi build closer to how rs.napi works

* Fix path issues

* Disable browser build for now

* Add native package directories

* Refine runWithEcho

* Try initial steps with Github flow

* Trigger change

* Temporarily add yarn lockfile until we figured out if we get it to work with npm

* Use nightly toolchain

* Use default locations for Napi files to make things easier

* Adapt workflow

* Skip regular tests for now

* Attempt to fix broken workflows

* Attempt to fix broken workflows

* Attempt to fix broken workflows

* Test MacOS/WIndows

* Fix bootstrap build

* Skip tests

* Rename workflow

* Add additional tests

* Use zig differently

* Try to fix musl build

* Skip musl again for now

* Add publish to workflow

* 4.0.0-0

* Remove yarn lock again

* Fix coverage job

* Fix artefact handling

* Revert "4.0.0-0"

This reverts commit 734806f.

* 4.0.0-0

* Do not include default triples twice

* Fix native npm packages

* 4.0.0-1

* Add missing additional tests except browser tests

* Try to fix publish and tests

* 4.0.0-2

* Switch to faster utf-16 conversion

* 4.0.0-3

* Fix positioning algorithm when manually searching the code

* 4.0.0-4

* feat: Add WASM browser build (#5077)

* feat: add wasm browser build

* move wasm binding into a separate cargo workspace

* use imports replacing

* set the targetEnv option of wasm to browser in browser build

* add the wasm build to build command

* fix lint error and ci error

* add more comments to silence the linter

* big change

* trigger change

* run browser tests

* trigger change

* tweak wasm build on CI

* Increase build timeout

* Use shared string constants

* Extract fixed strings into constants

* Remove comment

* Get rid of dbg! calls

* Add lockfile hash to cargo cache

* Use if let over match in some cases

* Return the buffer of the syntax error in parse_ast

* Initial annotation support

* Put annotation types into string table

* Remove invalid annotations

* Support nested calls and new expressions

* Improve tree-shaking for annotations

* Adapt test

* Properly handle line-breaks, commas etc.

* Mark nested pure annotations as pure

* Remove sourcemap comments

* Handle function side effect annotatinos

* Remove old comment-handling code

* Increase timeout for browser tests

* Only skip the tests that still fail

* Run coverage again on CI

* Get the buffer of pos and message from the Syntax error

* Handle the lint errors from SWC

* Reenable tests about parse errors and adjust some relevant code

* Emit native.js to native.cjs

* Add cjs extension for native importee when bundling for ESM

* Change native importee with replace plugin and emit native.cjs in napi build

* Silence the linter for importing native

* Use node:path to resolve native binding files

* Add Node WASM files to Native packages for StackBlitz and similar use cases

* Unignore *.d.ts in the wasm dir

* 4.0.0-5

* Fix copy-wasm-node.js

* 4.0.0-6

* Remove .gitignore in wasm-node directory

* 4.0.0-7

* Include .cjs files when publishing rollup to npm

* 4.0.0-8

* Get readString function at runtime

* eslint: ignore wasm-node and set node extensions of import/resolver

* 4.0.0-9

* Change the required node to >=14.18.0 as before

* 4.0.0-10

* Prepare to fix ESM build

Still requires bug-fix on Rollup side for relative external dependencies
outside the ouput directory

* Update Rollup

* Enable ESM tests

* Re-enable another test

* Remove CJS eslint configuration

* Fix extension

* Fix test

* Fix entension for native import

* Support for publishing a completely separate package @rollup/wasm-node

* 4.0.0-11

* Fix publish for wasm node package

* Add AST verification to function tests

* Only use plugin arrays in form and function tests

* Fix spans in function tests

* Verify AST in form tests as well

* Try to publish @rollup/browser and fix publish-wasm-node-package.js

* 4.0.0-12

* Tweak publish scripts

* Fix importing wasm file in browser

* Parse code as unknown module type for greater compatibility

* Remove acorn options

* Tweak getReadStringFunction

* Fix browser tests

* 4.0.0-13

* Remove polyfills that are no longer needed in browser tests

* Convert to new import attributes AST format

* Rename assertions to attributes

* Deprecate externalImportAssertions in favor of externalImportAttributes

* Update SWC version

* Remove max-call-stack test

SWC is not capable of handling it and we cannot fix it

* Improve coverage

* re-enable repl-artefacts workflow

* Fix test

* Preload wasm file in docs

* docs: add functions to get full path of url

* Delete the build plugin handleImportMetaUrl

* Make 'npm install github/branch' work

* Verify there is a valid changelog entry before releasing

* Create release notes and comments from CI

Minor change to maybe trigger a CI run

* Fix RegExp

* 4.0.0-14

* Minor changes for a test PR (#5139)

* Fix RegExp use

* 4.0.0-15

* Do not rely on current branch to find the PR

* 4.0.0-16

* Fix how to determine git commit range

* 4.0.0-17

* Make sure we fetch all history on publish

* 4.0.0-18

* Add proper permissions

* 4.0.0-19

* Use Double quotation marks instead of Single quotation marks if concurrently scripts with flags

* Remove "engines" from native packages

* Update CONTRIBUTING.md

---------

Co-authored-by: XiaoPi <530257315@qq.com>

* [v4.0] Set the default of skipSelf to true (#5142)

* Set minimum Node version to 18

* Set the default of skipSelf to true

* [v4.0] Switch parser to SWC and introduce native/WASM code (#5073)

* Add native compilation for local NodeJS

* Link instead of copying for faster dev cycles for now

* Parse AST

* Convert first trivial AST to a buffer

* Use SWC for parsing

* Extend AST conversion

* Make AST more similar

* Fix line number issue by creating a new sourcemap (and thus compiler) for each run

* Collect timings

* Add code_length to struct

* Refine parsing

* Extend parsing

* Extend AST: ImportDefaultSpecifier, LiteralBoolean, LiteralNull, ExportDefaultExpression

* Extend AST: ImportNamespaceSpecifier, ExportAll

* Extend AST: BinaryExpression, ArrayPattern, ObjectPattern, AssignmentPatternProperty, ArrayLiteral, ImportExpression

* Extend AST: ConditionalExpression

* Extend AST: FunctionDeclaration, ClassDeclaration, ClassBody, ReturnStatement

* Extend AST: ObjectLiteral, KeyValueProperty

* Extend AST: ShorthandProperty

* Extend AST: GetterProperty, AssignmentExpression, NewExpression, FunctionExpression

* Extend AST: ThrowStatement

* Extend AST: ExportDefaultDeclaration

* Extend AST: AssignmentPattern, AwaitExpression, BreakStatement
Start sorting AST nodes

* Extend AST: TryStatement, CatchClause, ChainExpression

* Extend AST: ClassExpression, ContinueStatement, DebuggerStatement, DoWhileStatement, EmptyStatement

* Extend AST: ExportNamedDeclaration, ForInStatement, ForOfStatement, ForStatement

* Extend AST: IfStatement

* Extend AST: Import attributes

* Extend AST: Literal<RegExp>, Literal<BigInt>

* Extend AST: LogicalExpression

* Extend AST: MetaProperty

* Extend AST: Various Property types

* Extend AST: Progress on classes

* Extend AST: MethodDefinition, PropertyDefinition, PrivateName, ThisExpression

* Extend AST: StaticBlock, Super

* Extend AST: RestElement, SequenceExpression, SwitchCase, SwitchStatement

* Extend AST: TaggedTemplateExpression, TemplateElement, TemplateLiteral, UnaryExpression, UpdateExpression, YieldExpression

* Extend AST: Properties in object patterns

* Finishing Fixes

* More fixes

* Run cargo fmt

* Handle directives

* Minor fixes

* Unicode support

* Fix optional chain expressions

* Adapt tests

* Do not run acorn anymore

* Update lockfile

* Minor fixes

* Move to rust folder

* Separate Rust Node bindings to allow adding WASM bindings in another workspace

* Make Napi build closer to how rs.napi works

* Fix path issues

* Disable browser build for now

* Add native package directories

* Refine runWithEcho

* Try initial steps with Github flow

* Trigger change

* Temporarily add yarn lockfile until we figured out if we get it to work with npm

* Use nightly toolchain

* Use default locations for Napi files to make things easier

* Adapt workflow

* Skip regular tests for now

* Attempt to fix broken workflows

* Attempt to fix broken workflows

* Attempt to fix broken workflows

* Test MacOS/WIndows

* Fix bootstrap build

* Skip tests

* Rename workflow

* Add additional tests

* Use zig differently

* Try to fix musl build

* Skip musl again for now

* Add publish to workflow

* 4.0.0-0

* Remove yarn lock again

* Fix coverage job

* Fix artefact handling

* Revert "4.0.0-0"

This reverts commit 734806f.

* 4.0.0-0

* Do not include default triples twice

* Fix native npm packages

* 4.0.0-1

* Add missing additional tests except browser tests

* Try to fix publish and tests

* 4.0.0-2

* Switch to faster utf-16 conversion

* 4.0.0-3

* Fix positioning algorithm when manually searching the code

* 4.0.0-4

* feat: Add WASM browser build (#5077)

* feat: add wasm browser build

* move wasm binding into a separate cargo workspace

* use imports replacing

* set the targetEnv option of wasm to browser in browser build

* add the wasm build to build command

* fix lint error and ci error

* add more comments to silence the linter

* big change

* trigger change

* run browser tests

* trigger change

* tweak wasm build on CI

* Increase build timeout

* Use shared string constants

* Extract fixed strings into constants

* Remove comment

* Get rid of dbg! calls

* Add lockfile hash to cargo cache

* Use if let over match in some cases

* Return the buffer of the syntax error in parse_ast

* Initial annotation support

* Put annotation types into string table

* Remove invalid annotations

* Support nested calls and new expressions

* Improve tree-shaking for annotations

* Adapt test

* Properly handle line-breaks, commas etc.

* Mark nested pure annotations as pure

* Remove sourcemap comments

* Handle function side effect annotatinos

* Remove old comment-handling code

* Increase timeout for browser tests

* Only skip the tests that still fail

* Run coverage again on CI

* Get the buffer of pos and message from the Syntax error

* Handle the lint errors from SWC

* Reenable tests about parse errors and adjust some relevant code

* Emit native.js to native.cjs

* Add cjs extension for native importee when bundling for ESM

* Change native importee with replace plugin and emit native.cjs in napi build

* Silence the linter for importing native

* Use node:path to resolve native binding files

* Add Node WASM files to Native packages for StackBlitz and similar use cases

* Unignore *.d.ts in the wasm dir

* 4.0.0-5

* Fix copy-wasm-node.js

* 4.0.0-6

* Remove .gitignore in wasm-node directory

* 4.0.0-7

* Include .cjs files when publishing rollup to npm

* 4.0.0-8

* Get readString function at runtime

* eslint: ignore wasm-node and set node extensions of import/resolver

* 4.0.0-9

* Change the required node to >=14.18.0 as before

* 4.0.0-10

* Prepare to fix ESM build

Still requires bug-fix on Rollup side for relative external dependencies
outside the ouput directory

* Update Rollup

* Enable ESM tests

* Re-enable another test

* Remove CJS eslint configuration

* Fix extension

* Fix test

* Fix entension for native import

* Support for publishing a completely separate package @rollup/wasm-node

* 4.0.0-11

* Fix publish for wasm node package

* Add AST verification to function tests

* Only use plugin arrays in form and function tests

* Fix spans in function tests

* Verify AST in form tests as well

* Try to publish @rollup/browser and fix publish-wasm-node-package.js

* 4.0.0-12

* Tweak publish scripts

* Fix importing wasm file in browser

* Parse code as unknown module type for greater compatibility

* Remove acorn options

* Tweak getReadStringFunction

* Fix browser tests

* 4.0.0-13

* Remove polyfills that are no longer needed in browser tests

* Convert to new import attributes AST format

* Rename assertions to attributes

* Deprecate externalImportAssertions in favor of externalImportAttributes

* Update SWC version

* Remove max-call-stack test

SWC is not capable of handling it and we cannot fix it

* Improve coverage

* re-enable repl-artefacts workflow

* Fix test

* Preload wasm file in docs

* docs: add functions to get full path of url

* Delete the build plugin handleImportMetaUrl

* Make 'npm install github/branch' work

* Verify there is a valid changelog entry before releasing

* Create release notes and comments from CI

Minor change to maybe trigger a CI run

* Fix RegExp

* 4.0.0-14

* Minor changes for a test PR (#5139)

* Fix RegExp use

* 4.0.0-15

* Do not rely on current branch to find the PR

* 4.0.0-16

* Fix how to determine git commit range

* 4.0.0-17

* Make sure we fetch all history on publish

* 4.0.0-18

* Add proper permissions

* 4.0.0-19

* Use Double quotation marks instead of Single quotation marks if concurrently scripts with flags

* Remove "engines" from native packages

* Update CONTRIBUTING.md

---------

Co-authored-by: XiaoPi <530257315@qq.com>

* Update tests

* Retrieve the code that was omitted during the merge

* Restore test coverage

* Update docs/plugin-development/index.md

Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>

---------

Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com>
Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>

* [v4.0] Imporve the performance of generating ast and rollup ast nodes (#5144)

* Set TsConfig useDefineForClassFields to false for reducing time consumption

* Adapt annotations props for reducing memory consumption

* [v4.0] Remove deprecated features (#5143)

* Remove hasModuleSideEffects from module info

* Remove this.moduleIds from plugin context

* Remove output.preferConst

* Remove output.dynamicImportFunction

* Remove output.experimentalDeepDynamicChunkOptimization

* Remove output.namespaceToStringTag

* Remove inlineDynamicImports input option

* Remove manualChunks and preserveModules input options as well as maxParallelFileReads

* [v4.0] feat: Do not watch files anymore if their content is returned by the load hook (#5150)

* feat: Do not watch files anymore if their content is returned by the load hook

* tweak test

* [v4.0] Remove onwarn from normalized input options (#5147)

Remove onwarn from normalized input options

Also remove the RollupWarning type

* [v4.0] Add parse option to allow return outside function (#5154)

Allow return outside functions

* [v4.0] Handle empty exports (#5157)

Handle empty exports

* [v4.0] feat: implement hashing content in Rust (#5155)

* [v4.0] fix: also strip BOM from code strings in JS (#5164)

fix: also strip BOM from code strings in JS

* [v4.0] feat: preserve shebang in entry module for CJS and ESM outputs (#5163)

* feat: preserve shebang in entry module for CJS and ESM outputs

* Remove the shebang insertion during cli build

* Parse shebang in JS code

* Render shebang in chunk.render()

---------

Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>

* [v4.0] warn for invalid annotations (#5165)

* Remove annotations for partially removed declarations

* Warn for invalid annotations

* 4.0.0-24

* [v.4.0] Ensure we support new import attribute "with" syntax (#5168)

* Update dependencies

* Use new import attribute syntax in test files

* [v4.0] Expose parser (#5169)

* Expose parser as separate API

* Ensure key and value of a shorthand property have different references

* 4.0.0-25

---------

Co-authored-by: XiaoPi <530257315@qq.com>
  • Loading branch information
lukastaegert and TrickyPi committed Oct 5, 2023
1 parent fac5f1c commit 88ea52d
Show file tree
Hide file tree
Showing 1,690 changed files with 16,184 additions and 14,559 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ module.exports = {
'coverage',
'_tmp',
'cache',
'wasm',
'native*.*',
'/test/*/samples/**/*.*',
'!/test/*/samples/**/_config.js',
'!/test/*/samples/**/rollup.config.js',
'!.vitepress'
'!.vitepress',
'/wasm/',
'/wasm-node/'
],
overrides: [
{
Expand Down
350 changes: 350 additions & 0 deletions .github/workflows/build-and-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,350 @@
name: CI
env:
DEBUG: napi:*
APP_NAME: rollup
MACOSX_DEPLOYMENT_TARGET: '10.13'

on:
push:
branches:
- master
tags:
- 'v*.*.**'
pull_request:
types:
- synchronize
- opened
- reopened
merge_group:

permissions:
contents: read

jobs:
lint:
name: Lint and Audit
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v3
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: Lint
run: npm run ci:lint
- name: Vulnerabilities
run: npm audit
- name: Optional Dependencies
run: npm run test:package
- name: CLI Docs
run: npm run test:options

build:
strategy:
fail-fast: false
matrix:
settings:
- host: windows-latest
target: x86_64-pc-windows-msvc
name: wasm
is-wasm-build: true
build: npm run build:wasm
path: |
wasm/
.empty
- host: windows-latest
target: x86_64-pc-windows-msvc
name: wasm-node
is-wasm-build: true
build: npm run build:wasm:node
path: |
wasm-node/
.empty
- host: macos-latest
target: x86_64-apple-darwin
build: |
npm run build:napi -- --release
strip -x *.node
- host: windows-latest
build: npm run build:napi -- --release
target: x86_64-pc-windows-msvc
- host: windows-latest
build: |
npm run build:napi -- --release --target i686-pc-windows-msvc
target: i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: |-
set -e &&
rustup default nightly &&
npm run build:napi -- --release --target x86_64-unknown-linux-gnu &&
strip *.node
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: |-
set -e &&
rustup default nightly &&
npm run build:napi -- --release && strip *.node
- host: macos-latest
target: aarch64-apple-darwin
build: |
npm run build:napi -- --release --target aarch64-apple-darwin
strip -x *.node
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
build: |-
set -e &&
rustup default nightly &&
rustup target add aarch64-unknown-linux-gnu &&
npm run build:napi -- --release --target aarch64-unknown-linux-gnu &&
aarch64-unknown-linux-gnu-strip *.node
- host: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
zig: true
setup: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf -y
build: |
npm run build:napi -- --release --target armv7-unknown-linux-gnueabihf
arm-linux-gnueabihf-strip *.node
- host: ubuntu-latest
target: aarch64-linux-android
build: |
npm run build:napi -- --release --target aarch64-linux-android
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
- host: ubuntu-latest
target: armv7-linux-androideabi
build: |
npm run build:napi -- --release --target armv7-linux-androideabi
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
# TODO SWC this does not work yet, also add back in package.json
# - host: ubuntu-latest
# target: aarch64-unknown-linux-musl
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
# build: |-
# set -e &&
# rustup default nightly &&
# rustup target add aarch64-unknown-linux-musl &&
# npm run build:napi -- --release --target aarch64-unknown-linux-musl &&
# /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
- host: windows-latest
target: aarch64-pc-windows-msvc
build: npm run build:napi -- --release --target aarch64-pc-windows-msvc
name: Build ${{ matrix.settings.name || matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
timeout-minutes: 30
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
if: ${{ !matrix.settings.docker }}
with:
node-version: 20
- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }}
with:
toolchain: nightly
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
rust/target/
key: ${{ matrix.settings.name || matrix.settings.target }}-cargo-${{ matrix.settings.host }}-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: ${{ matrix.settings.name || matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.zig }}
with:
version: 0.10.1
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v3
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 in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
image: ${{ matrix.settings.docker }}
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
run: ${{ matrix.settings.build }}
- name: Build
run: ${{ matrix.settings.build }}
if: ${{ !matrix.settings.docker }}
shell: bash
- name: Upload wasm artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.settings.name }}
path: ${{ matrix.settings.path }}
if-no-files-found: error
if: ${{ matrix.settings.is-wasm-build }}
- name: Upload napi artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error
if: ${{ !matrix.settings.is-wasm-build }}

test:
name: Test${{ matrix.additionalName || '' }} Node ${{ matrix.node }} (${{ matrix.settings.target }})
needs:
- build
strategy:
fail-fast: false
matrix:
settings:
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: macos-latest
target: x86_64-apple-darwin
node:
- '18.0.0'
- '20'
include:
- settings:
host: ubuntu-latest
target: x86_64-unknown-linux-gnu
node: '20'
command: 'ci:coverage'
additionalName: ' with Coverage'
coverage: true
- settings:
host: ubuntu-latest
target: x86_64-unknown-linux-gnu
node: '18.0.0'
command: 'ci:test:all'
additionalName: ' with Additional Tests'
runs-on: ${{ matrix.settings.host }}
timeout-minutes: 15
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v3
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 napi artifacts
uses: actions/download-artifact@v3
with:
name: bindings-${{ matrix.settings.target }}
path: .
- name: Download wasm artifacts
uses: actions/download-artifact@v3
with:
name: bindings-wasm
- name: Build and test Rollup
run: npm run ${{ matrix.command || 'ci:test:only' }}
env:
CI: true
- name: Upload coverage
uses: codecov/codecov-action@v3
if: matrix.coverage
with:
# It appears adding the token may result in the coverage comment not being added
# token: ${{ secrets.CODECOV_TOKEN }}
commit_parent: ${{ github.event.pull_request.head.sha }}

publish:
permissions:
pull-requests: write # for writing comments
issues: write # for writing comments
contents: write # for creating a release
name: Publish
runs-on: ubuntu-latest
timeout-minutes: 15
needs:
- test
- lint
# TODO SWC once v4 is live, this should be changed
if: startsWith(github.ref_name, 'v4')
steps:
- name: Checkout Commit
uses: actions/checkout@v4
with:
# Necessary to find the commits included in the release
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v3
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@v3
with:
path: artifacts
- name: Copy wasm files
run: cp -R artifacts/bindings-wasm/wasm .
- name: Build JavaScript
run: npm run build:cjs && cp artifacts/*/*.node dist/ && npm run build:bootstrap
- name: Move artifacts
run: npm run ci:artifacts
- name: Publish
run: |
if git --no-pager log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "Publishing regular release"
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git --no-pager log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+$";
then
echo "Publishing beta release"
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag beta --access public
else
echo "Not a release, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
ROLLUP_RELEASE: 'releasing'
2 changes: 1 addition & 1 deletion .github/workflows/repl-artefacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
#TODO: remove after or before merging release-4.0
if: ${{ github.head_ref == 'release-4.0' || github.base_ref == 'release-4.0' }}
run: npm exec -- concurrently -c green,blue,yellow 'npm:build:napi -- --release' 'npm run build:wasm' 'npm:build:cjs' && npm run build:copy-native && npm run build:bootstrap
#TODO: remove after or before merging release-4.0
#TODO: remove after or before merging release-4.0
- name: Build artefacts
if: ${{ github.head_ref != 'release-4.0' && github.base_ref != 'release-4.0' }}
run: npm run build:cjs && npm run build:bootstrap
Expand Down

0 comments on commit 88ea52d

Please sign in to comment.