feat: works

This commit is contained in:
2022-07-17 10:11:20 +08:00
parent 4ba63b4c2e
commit 74a202f1ed
458 changed files with 125067 additions and 8 deletions

View File

@@ -0,0 +1 @@
open_collective: boa

View File

@@ -0,0 +1,52 @@
---
name: "\U0001F41B Bug report"
about: Create a report to help us improve
title: ""
labels: bug
assignees: ""
---
<!--
Thank you for reporting a bug in Boa! This will make us improve the engine. But first, fill the following template so that we better understand what's happening. Feel free to add or remove sections as you feel appropriate.
-->
**Describe the bug**
A clear and concise description of what the bug is.
<!-- E.g.:
The variable statement is not working as expected, it always adds 10 when assigning a number to a variable"
-->
**To Reproduce**
Steps to reproduce the issue, or JavaScript code that causes this failure.
<!-- E.g.:
This JavaScript code reproduces the issue:
```javascript
var a = 10;
a;
```
-->
**Expected behavior**
Explain what you expected to happen, and what is happening instead.
<!-- E.g.:
Running this code, `a` should be set to `10` and printed, but `a` is instead set to `20`. The expected behaviour can be found in the [ECMAScript specification][spec].
[spec]: https://tc39.es/ecma262/#sec-variable-statement-runtime-semantics-evaluation
-->
**Build environment (please complete the following information):**
- OS: [e.g. Fedora Linux]
- Version: [e.g. 32]
- Target triple: [e.g. x86_64-unknown-linux-gnu]
- Rustc version: [e.g. rustc 1.43.0 (4fb7144ed 2020-04-20), running `rustc -V`]
**Additional context**
Add any other context about the problem here.
<!-- E.g.:
You can find more information in [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var).
-->

View File

@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Discord channel
url: https://discord.gg/tUFFk9Y
about: Please ask and answer questions here.

View File

@@ -0,0 +1,13 @@
---
name: Custom
about: Open an issue in the repo that is neither a bug or a feature, such a new idea
title: ""
labels: ""
assignees: ""
---
<!--
Thank you for contributing to Boa! Please, let us know how can we help you.
-->
E.g.: I think we should improve the way the JavaScript interpreter works by...

View File

@@ -0,0 +1,43 @@
---
name: "\U0001F680 Feature request"
about: Suggest a new ECMAScript feature to be implemented, or a new capability of the engine.
title: ""
labels: enhancement
assignees: ""
---
<!--
Thank you for adding a feature request to Boa! As this is an experimental JavaScript engine, there will probably be many ECMAScript features left to implement. In order to understand the feature request as best as possible, please fill the following template. Feel free to add or remove sections as needed.
-->
**ECMASCript feature**
Explain the ECMAScript feature that you'd like to see implemented.
<!-- E.g.:
I would like to see `switch` statement parsing and execution implemented. [ECMAScript specification][spec].
[spec]: https://tc39.es/ecma262/#sec-switch-statement
-->
**Example code**
Give a code example that should work after the implementation of this feature.
<!-- E.g.:
This code should now work and give the expected result:
```javascript
let a = "hello";
let b;
switch (a) {
case 'hello':
b = 'world';
break;
case 'world':
b = 'hello';
break;
default:
b = 'hello world';
}
b;
```
The expected output is `world`.
-->

View File

@@ -0,0 +1,12 @@
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccesary.
--->
This Pull Request fixes/closes #{issue_num}.
It changes the following:
-
-
-

View File

@@ -0,0 +1,10 @@
github_checks:
annotations: false
coverage:
status:
project:
default:
threshold: 5% # allow 5% coverage variance
patch: off

View File

@@ -0,0 +1,50 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: daily
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
- package-ecosystem: cargo
directory: /
schedule:
interval: daily
- package-ecosystem: cargo
directory: /boa_cli/
schedule:
interval: daily
- package-ecosystem: cargo
directory: /boa_engine/
schedule:
interval: daily
- package-ecosystem: cargo
directory: /boa_gc/
schedule:
interval: daily
- package-ecosystem: cargo
directory: /boa_interner/
schedule:
interval: daily
- package-ecosystem: cargo
directory: /boa_profiler/
schedule:
interval: daily
- package-ecosystem: cargo
directory: /boa_tester/
schedule:
interval: daily
- package-ecosystem: cargo
directory: /boa_unicode/
schedule:
interval: daily
- package-ecosystem: cargo
directory: /boa_wasm/
schedule:
interval: daily
- package-ecosystem: gitsubmodule
directory: /
schedule:
interval: weekly

View File

@@ -0,0 +1,16 @@
# .github/release.yml
changelog:
exclude:
authors:
- dependabot
categories:
- title: Feature Enhancements
labels:
- enhancement
- title: Bug Fixes
labels:
- bug
- title: Internal Improvements
labels:
- Internal

View File

@@ -0,0 +1,162 @@
name: bors
on:
push:
branches:
- staging
- trying
jobs:
test_on_linux:
name: Tests on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: test
args: -v
test_on_windows:
name: Tests on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: test
args: -v
test_on_macos:
name: Tests on MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: test
args: -v
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
components: clippy
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- --verbose
examples:
name: Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-examples-${{ hashFiles('**/Cargo.lock') }}
- run: cd boa_examples
- name: Build examples
uses: actions-rs/cargo@v1
with:
command: build
- name: Run example classes
uses: actions-rs/cargo@v1
with:
command: run
args: --bin classes
doc:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-doc-${{ hashFiles('**/Cargo.lock') }}
- name: Generate documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: -v --document-private-items --all-features

View File

@@ -0,0 +1,54 @@
name: Main workflows
on:
push:
branches:
- main
jobs:
benchmark:
if: ${{ github.actor != 'dependabot[bot]' }}
name: Upload docs and run benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
!target/doc_upload
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-doc-bench-${{ hashFiles('**/Cargo.lock') }}
- name: Generate documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: -v --document-private-items --all-features
- run: echo "<meta http-equiv=refresh content=0;url=boa_engine/index.html>" > target/doc/index.html
- run: |
if [ -d target/doc_upload ]; then rm -rf target/doc_upload; fi
mkdir target/doc_upload && mv target/doc target/doc_upload/doc
- name: Upload documentation
uses: crazy-max/ghaction-github-pages@v3.0.0
with:
target_branch: gh-pages
keep_history: true
build_dir: target/doc_upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run benchmark
run: cargo bench -p boa_engine -- --output-format bencher | tee output.txt
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1.14.0
with:
name: Boa Benchmarks
tool: "cargo"
output-file-path: output.txt
auto-push: true
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,34 @@
name: Benchmarks
on:
pull_request:
branches:
- main
jobs:
runBenchmark:
if: contains(github.event.pull_request.labels.*.name, 'run-benchmark')
name: run benchmark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: boa-dev/criterion-compare-action@v3.2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
branchName: ${{ github.base_ref }}
cwd: ./boa_engine

View File

@@ -0,0 +1,62 @@
name: Publish Release
on:
release:
types: [published]
jobs:
publish:
name: publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install cargo-workspaces
uses: actions-rs/install@v0.1
with:
crate: cargo-workspaces
- name: Release
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
PATCH: ${{ github.run_number }}
shell: bash
run: |
git config --global user.email "runner@gha.local"
git config --global user.name "Github Action"
cargo workspaces publish --from-git --yes minor
doc-publish:
# needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- uses: actions/setup-node@v3
with:
node-version: "16"
- run: npm ci
- name: Cache npm build
uses: actions/cache@v3
with:
path: |
node_modules
target
boa_wasm/pkg
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-npm-build-target-${{ hashFiles('**/package-lock.json') }}
- run: npm run build:prod
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
publish_dir: ./dist
destination_dir: playground
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,166 @@
on:
pull_request:
branches:
- main
push:
branches:
- main
name: Continuous integration
jobs:
test_on_linux:
name: Tests on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo-tarpaulin
uses: actions-rs/tarpaulin@v0.1
with:
args: --features intl --ignore-tests
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
test_on_windows:
name: Tests on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: test
args: -v --features intl
test_on_macos:
name: Tests on MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: test
args: -v --features intl
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
components: clippy
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- --verbose
examples:
name: Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-examples-${{ hashFiles('**/Cargo.lock') }}
- run: cd boa_examples
- name: Build examples
uses: actions-rs/cargo@v1
with:
command: build
- name: Run example classes
uses: actions-rs/cargo@v1
with:
command: run
args: --bin classes
doc:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-doc-${{ hashFiles('**/Cargo.lock') }}
- name: Generate documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: -v --document-private-items --all-features

View File

@@ -0,0 +1,12 @@
name: Security audit
on:
schedule:
- cron: "0 0 * * *"
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/audit-check@v1.2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,119 @@
name: EcmaScript official test suite (test262)
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
jobs:
run_test262:
name: Run the test262 test suite
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
submodules: true
path: boa
- name: Install the Rust toolchain
uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-test262-${{ hashFiles('**/Cargo.lock') }}
# Run the test suite and upload the results
- name: Checkout GitHub pages
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
- name: Run the test262 test suite
run: |
cd boa
mkdir ../results
cargo run --release --bin boa_tester -- run -v -o ../results/test262
cd ..
# Run the results comparison
- name: Compare results
if: github.event_name == 'pull_request'
id: compare-non-vm
shell: bash
run: |
cd boa
comment="$(./target/release/boa_tester compare ../gh-pages/test262/refs/heads/main/latest.json ../results/test262/pull/latest.json -m)"
comment="${comment//'%'/'%25'}"
comment="${comment//$'\n'/'%0A'}"
comment="${comment//$'\r'/'%0D'}"
echo "::set-output name=comment::$comment"
- name: Get the PR number
if: github.event_name == 'pull_request'
id: pr-number
uses: kkak10/pr-number-action@v1.3
- name: Find Previous Comment
if: github.event_name == 'pull_request'
uses: peter-evans/find-comment@v2
id: previous-comment
with:
issue-number: ${{ steps.pr-number.outputs.pr }}
body-includes: Test262 conformance changes
- name: Update comment
if: github.event_name == 'pull_request' && steps.previous-comment.outputs.comment-id
uses: peter-evans/create-or-update-comment@v2
continue-on-error: true
with:
comment-id: ${{ steps.previous-comment.outputs.comment-id }}
body: |
### Test262 conformance changes
${{ steps.compare-non-vm.outputs.comment }}
${{ steps.compare-vm.outputs.comment }}
edit-mode: replace
- name: Write a new comment
if: github.event_name == 'pull_request' && !steps.previous-comment.outputs.comment-id
uses: peter-evans/create-or-update-comment@v2
continue-on-error: true
with:
issue-number: ${{ steps.pr-number.outputs.pr }}
body: |
### Test262 conformance changes
${{ steps.compare-non-vm.outputs.comment }}
${{ steps.compare-vm.outputs.comment }}
# Commit changes to GitHub pages.
- name: Commit files
if: github.event_name == 'push'
run: |
cp -r ./results/test262/* ./gh-pages/test262/
cd gh-pages
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add test262
git commit -m "Add new test262 results" -a
cd ..
- name: Upload results
if: github.event_name == 'push'
uses: ad-m/github-push-action@v0.6.0
with:
directory: gh-pages
branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,49 @@
on:
pull_request:
branches:
- main
push:
branches:
- main
name: Webassembly demo
jobs:
check_style:
name: Check webassembly demo style
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check code formatting
run: npx prettier --check .
build:
name: Build webassembly demo
runs-on: ubuntu-latest
env:
WASM_PACK_PATH: ~/.cargo/bin/wasm-pack
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Cache npm build
uses: actions/cache@v3
with:
path: |
node_modules
target
~/.cargo/git
~/.cargo/registry
boa_wasm/pkg
key: ${{ runner.os }}-npm-build-target-${{ hashFiles('**/package-lock.json') }}
- uses: actions/setup-node@v3
with:
node-version: "16"
- run: npm ci
- run: npm run build