diff --git a/.github/actions/setup-geckodriver/action.yml b/.github/actions/setup-geckodriver/action.yml new file mode 100644 index 000000000..57d5578a5 --- /dev/null +++ b/.github/actions/setup-geckodriver/action.yml @@ -0,0 +1,6 @@ +name: 'Setup Geckodriver' +description: 'Setup Geckodriver' + +runs: + using: node12 + main: 'main.js' diff --git a/.github/actions/setup-geckodriver/main.js b/.github/actions/setup-geckodriver/main.js new file mode 100644 index 000000000..d92c3c299 --- /dev/null +++ b/.github/actions/setup-geckodriver/main.js @@ -0,0 +1,24 @@ +const child_process = require('child_process'); +const fs = require('fs'); + +function set_env(name, val) { + fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`) +} + +function fetch(url) { + child_process.execFileSync('curl', ['--retry', '5', '-LO', url]) +} + +const version = '0.24.0'; + +if (process.platform === 'win32') { + const file = `geckodriver-v${version}-win64.zip`; + fetch(`https://github.com/mozilla/geckodriver/releases/download/v${version}/${file}`); + child_process.execFileSync('unzip', [file]); + set_env("GECKODRIVER", process.cwd() + '/geckodriver.exe'); +} else { + const file = `geckodriver-v${version}-linux64.tar.gz`; + fetch(`https://github.com/mozilla/geckodriver/releases/download/v${version}/${file}`); + child_process.execFileSync('tar', ['xf', file]); + set_env("GECKODRIVER", process.cwd() + '/geckodriver'); +} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 08e8a115e..80f7042c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,403 @@ name: CI +on: + push: + branches: [main] + tags-ignore: [dev] + pull_request: + branches: [main] +defaults: + run: + shell: bash + +# Cancel any in-flight jobs for the same PR/branch so there's only one active +# at a time +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - hello: + # Check Code style quickly by running `rustfmt` over all code + rustfmt: + name: Rustfmt runs-on: ubuntu-latest steps: - - run: echo hello + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup component add rustfmt + - run: cargo fmt --all -- --check + + # Run `cargo check` over everything + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: cargo check --all + + test_wasm_bindgen: + name: "Run wasm-bindgen crate tests (unix)" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - uses: actions/setup-node@v2 + with: + node-version: '16' + - uses: ./.github/actions/setup-geckodriver + - run: cargo test --target wasm32-unknown-unknown + - run: cargo test --target wasm32-unknown-unknown + - run: cargo test --target wasm32-unknown-unknown --features serde-serialize + - run: cargo test --target wasm32-unknown-unknown --features enable-interning + - run: cargo test --target wasm32-unknown-unknown -p no-std + - run: cargo test --target wasm32-unknown-unknown -p wasm-bindgen-futures + - run: cargo test --target wasm32-unknown-unknown --test wasm + env: + WASM_BINDGEN_WEAKREF: 1 + - run: cargo test --target wasm32-unknown-unknown --test wasm + env: + WASM_BINDGEN_WEAKREF: 1 + WASM_BINDGEN_NO_DEBUG: 1 + - run: cargo test --target wasm32-unknown-unknown --test wasm --features serde-serialize + env: + WASM_BINDGEN_WEAKREF: 1 + + test_wasm_bindgen_windows: + name: "Run wasm-bindgen crate tests (Windows)" + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - uses: actions/setup-node@v2 + with: + node-version: '16' + - uses: ./.github/actions/setup-geckodriver + - run: cargo test --target wasm32-unknown-unknown + env: + RUST_LOG: wasm_bindgen_test_runner + GECKODRIVER_ARGS: --log trace + - run: cargo test --target wasm32-unknown-unknown -p js-sys + - run: cargo test --target wasm32-unknown-unknown -p webidl-tests + env: + WBINDGEN_I_PROMISE_JS_SYNTAX_WORKS_IN_NODE: 1 + - run: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features "Node Window Document" + + test_wasm_bindgen_nightly: + name: "Run wasm-bindgen crate tests (nightly)" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup default nightly-2021-09-02 + - run: rustup target add wasm32-unknown-unknown + - uses: actions/setup-node@v2 + with: + node-version: '16' + - run: cargo test --target wasm32-unknown-unknown --features nightly --test wasm + + test_native: + name: Run native tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - uses: actions/setup-node@v2 + with: + node-version: '16' + - run: cargo test + - run: cargo test -p wasm-bindgen-cli-support + - run: cargo test -p wasm-bindgen-cli + - run: cargo test -p wasm-bindgen-externref-xform + - run: cargo test -p wasm-bindgen-multi-value-xform + - run: cargo test -p wasm-bindgen-wasm-interpreter + - run: cargo test -p wasm-bindgen-futures + - run: cargo test -p wasm-bindgen-shared + + test_web_sys: + name: "Run web-sys crate tests" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - uses: actions/setup-node@v2 + with: + node-version: '16' + - uses: ./.github/actions/setup-geckodriver + - run: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown + - run: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Node + - run: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Element + - run: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Window + - run: cargo test --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --all-features + - run: cargo test --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --all-features + env: + RUSTFLAGS: --cfg=web_sys_unstable_apis + + check_web_sys: + name: "Verify that web-sys is compiled correctly" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: cd crates/web-sys && cargo run --release --package wasm-bindgen-webidl -- webidls src/features + - run: git diff --exit-code + + test_js_sys: + name: "Run js-sys crate tests" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - uses: actions/setup-node@v2 + with: + node-version: '16' + - uses: ./.github/actions/setup-geckodriver + - run: cargo test -p js-sys --target wasm32-unknown-unknown + + test_webidl: + name: "Run wasm-bindgen-webidl crate tests" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - uses: actions/setup-node@v2 + with: + node-version: '16' + - run: cargo test -p wasm-bindgen-webidl + - run: cargo test -p webidl-tests --target wasm32-unknown-unknown + env: + WBINDGEN_I_PROMISE_JS_SYNTAX_WORKS_IN_NODE: 1 + - run: cargo test -p webidl-tests --target wasm32-unknown-unknown + env: + RUSTFLAGS: --cfg=web_sys_unstable_apis + + test_typescript_output: + name: "Test TypeScript output of wasm-bindgen" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - uses: actions/setup-node@v2 + with: + node-version: '16' + - run: cd crates/typescript-tests && ./run.sh + + test_deno: + name: "Build and test the deno example" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + - run: cd examples/deno && ./build.sh && deno run --allow-read test.ts + + test_ui: + name: Run UI compile-fail tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update 1.56.0 && rustup default 1.56.0 + - run: cargo test -p wasm-bindgen-macro + + build_examples: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f + - run: | + cargo build -p wasm-bindgen-cli + ln -snf `pwd`/target/debug/wasm-bindgen $(dirname `which cargo`)/wasm-bindgen + - run: mv _package.json package.json && npm install && rm package.json + - run: | + for dir in `ls examples | grep -v README | grep -v asm.js | grep -v raytrace | grep -v without-a-bundler | grep -v wasm-in-web-worker | grep -v websockets | grep -v webxr | grep -v deno`; do + (cd examples/$dir && + ln -fs ../../node_modules . && + npm run build -- --output-path ../../exbuild/$dir) || exit 1; + done + - uses: actions/upload-artifact@v2 + with: + name: examples1 + path: exbuild + + build_raytrace: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup default nightly-2021-09-02 + - run: rustup target add wasm32-unknown-unknown + - run: rustup component add rust-src + - run: | + sed -i 's/python/#python/' examples/raytrace-parallel/build.sh + (cd examples/raytrace-parallel && ./build.sh) + mkdir exbuild + cp examples/raytrace-parallel/*.{js,html,wasm} exbuild + - uses: actions/upload-artifact@v2 + with: + name: examples2 + path: exbuild + + build_benchmarks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add wasm32-unknown-unknown + - run: cargo build --manifest-path benchmarks/Cargo.toml --release --target wasm32-unknown-unknown + - run: cargo run -p wasm-bindgen-cli -- target/wasm32-unknown-unknown/release/wasm_bindgen_benchmark.wasm --out-dir benchmarks/pkg --target web + - uses: actions/upload-artifact@v2 + with: + name: benchmarks + path: benchmarks + + dist_linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: rustup target add x86_64-unknown-linux-musl + - run: sudo apt update -y && sudo apt install musl-tools -y + - run: | + cargo build --manifest-path crates/cli/Cargo.toml --target x86_64-unknown-linux-musl --features vendored-openssl --release + strip -g target/x86_64-unknown-linux-musl/release/wasm-bindgen + strip -g target/x86_64-unknown-linux-musl/release/wasm-bindgen-test-runner + strip -g target/x86_64-unknown-linux-musl/release/wasm2es6js + - uses: actions/upload-artifact@v2 + with: + name: dist_linux + path: "target/x86_64-unknown-linux-musl/release/wasm*" + + dist_macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: cargo build --manifest-path crates/cli/Cargo.toml --release + env: + MACOSX_DEPLOYMENT_TARGET: 10.7 + - uses: actions/upload-artifact@v2 + with: + name: dist_macos + path: "target/release/wasm*" + + dist_windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable && rustup default stable + - run: cargo build --manifest-path crates/cli/Cargo.toml --release + env: + RUSTFLAGS: -Ctarget-feature=+crt-static + - uses: actions/upload-artifact@v2 + with: + name: dist_windows + path: "target/release/wasm*" + + doc_book: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: | + curl -L https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.0/mdbook-v0.3.0-x86_64-unknown-linux-gnu.tar.gz | tar xzf - + echo $PWD >> $GITHUB_PATH + - run: (cd guide && mdbook build) + - uses: actions/upload-artifact@v2 + with: + name: doc_book + path: guide/book/html + + doc_api: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update nightly && rustup default nightly + - run: cargo doc --no-deps --features 'nightly serde-serialize' + - run: cargo doc --no-deps --manifest-path crates/js-sys/Cargo.toml + - run: cargo doc --no-deps --manifest-path crates/web-sys/Cargo.toml --all-features + env: + RUSTDOCFLAGS: --cfg=web_sys_unstable_apis + - run: cargo doc --no-deps --manifest-path crates/futures/Cargo.toml + - run: tar czvf docs.tar.gz target/doc + - uses: actions/upload-artifact@v2 + with: + name: doc_api + path: docs.tar.gz + + + deploy: + needs: + - doc_api + - doc_book + - dist_linux + - dist_macos + - dist_windows + - build_examples + - build_raytrace + - build_benchmarks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - run: rustup update nightly && rustup default nightly + - uses: actions/download-artifact@v2 + with: + path: artifacts + - run: find artifacts + - run: | + set -ex + mkdir -p gh-release + tag=`git describe --tags` + mk() { + target=$1 + src=$2 + name=wasm-bindgen-$tag-$target + mkdir -p tmp/$name + rm -f artifacts/$src/*.d + rm -f artifacts/$src/*.pdb + cp README.md \ + LICENSE-MIT \ + LICENSE-APACHE \ + artifacts/$src/wasm* \ + tmp/$name/ + chmod +x tmp/$name/wasm* + tar czvf gh-release/$name.tar.gz -C tmp $name + } + mk x86_64-unknown-linux-musl dist_linux + mk x86_64-apple-darwin dist_macos + mk x86_64-pc-windows-msvc dist_windows + - uses: actions/upload-artifact@v2 + with: + name: gh-release + path: gh-release + - run: | + mv artifacts/doc_book gh-pages + tar xf artifacts/doc_api/docs.tar.gz + mv target/doc gh-pages/api + mv artifacts/examples1 gh-pages/exbuild + mv artifacts/examples2 gh-pages/exbuild/raytrace-parallel + mv artifacts/benchmarks gh-pages/benchmarks + tar czf gh-pages.tar.gz gh-pages + - uses: actions/upload-artifact@v2 + with: + name: gh-pages + path: gh-pages.tar.gz + - uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + branch: gh-pages + folder: gh-pages + single-commit: true + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + - uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: "gh-release/*.tar.gz" diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index cb2ced5c0..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,423 +0,0 @@ -trigger: - branches: - include: - - refs/heads/master - - refs/tags/* - -jobs: - - job: test_formatting - displayName: "Run cargo fmt" - steps: - - template: ci/azure-install-rust.yml - - script: cargo fmt --all -- --check - - - job: cargo_check - displayName: "Run cargo check" - steps: - - template: ci/azure-install-rust.yml - - script: cargo check --all - - - job: test_wasm_bindgen - displayName: "Run wasm-bindgen crate tests (unix)" - steps: - - template: ci/azure-install-rust.yml - - template: ci/azure-install-node.yml - - template: ci/azure-install-geckodriver.yml - - script: cargo test - displayName: "Builds on native" - - script: cargo test --target wasm32-unknown-unknown - displayName: "Crate test suite" - - script: WASM_BINDGEN_NO_DEBUG=1 cargo test --target wasm32-unknown-unknown - displayName: "Crate test suite (no debug)" - - script: cargo test --target wasm32-unknown-unknown --features serde-serialize - displayName: "Crate test suite (with serde)" - - script: cargo test --target wasm32-unknown-unknown --features enable-interning - displayName: "Crate test suite (with enable-interning)" - - script: cargo test --target wasm32-unknown-unknown -p no-std - displayName: "Crate test suite (no_std)" - - script: cargo test -p wasm-bindgen-futures - displayName: "Futures test suite on native" - - script: cargo test -p wasm-bindgen-futures --target wasm32-unknown-unknown - displayName: "Futures test suite on wasm" - - script: cargo test -p wasm-bindgen-multi-value-xform - displayName: "multi-value xform tests on native" - - script: cargo test -p wasm-bindgen-shared - displayName: "Shared test suite on native" - # TODO: re-enable when binary decoding for reference types is updated in - # Node. - # - script: | - # set -e - # echo "##vso[task.setvariable variable=NODE_ARGS]--experimental-wasm-anyref" - # echo "##vso[task.setvariable variable=WASM_BINDGEN_ANYREF]1" - # displayName: "Configure anyref passes" - # - script: cargo test --target wasm32-unknown-unknown --test wasm - # displayName: "(anyref) Crate test suite" - # - script: WASM_BINDGEN_NO_DEBUG=1 cargo test --target wasm32-unknown-unknown --test wasm - # displayName: "(anyref) Crate test suite (no debug)" - # - script: cargo test --target wasm32-unknown-unknown --features serde-serialize --test wasm - # displayName: "(anyref) Crate test suite (with serde)" - - script: | - set -e - echo "##vso[task.setvariable variable=NODE_ARGS]--harmony-weak-refs" - echo "##vso[task.setvariable variable=WASM_BINDGEN_WEAKREF]1" - displayName: "Configure anyref passes" - - script: cargo test --target wasm32-unknown-unknown --test wasm - displayName: "(weakref) Crate test suite" - - script: WASM_BINDGEN_NO_DEBUG=1 cargo test --target wasm32-unknown-unknown --test wasm - displayName: "(weakref) Crate test suite (no debug)" - - script: cargo test --target wasm32-unknown-unknown --features serde-serialize --test wasm - displayName: "(weakref) Crate test suite (with serde)" - - - job: test_wasm_bindgen_windows - displayName: "Run wasm-bindgen crate tests (Windows)" - pool: - vmImage: vs2017-win2016 - steps: - - template: ci/azure-install-rust.yml - - template: ci/azure-install-node.yml - - template: ci/azure-install-geckodriver.yml - - script: cargo test --target wasm32-unknown-unknown - displayName: "wasm-bindgen test suite" - env: - RUST_LOG: wasm_bindgen_test_runner - GECKODRIVER_ARGS: --log trace - - script: cargo test --target wasm32-unknown-unknown -p js-sys - displayName: "js-sys test suite" - - script: cargo test --target wasm32-unknown-unknown -p webidl-tests - displayName: "webidl-tests test suite" - env: - WBINDGEN_I_PROMISE_JS_SYNTAX_WORKS_IN_NODE: 1 - - script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features "Node Window Document" - displayName: "web-sys build" - - - job: test_wasm_bindgen_nightly - displayName: "Run wasm-bindgen crate tests (nightly)" - steps: - - template: ci/azure-install-rust.yml - parameters: - toolchain: nightly-2021-09-02 - - template: ci/azure-install-node.yml - - script: cargo test --target wasm32-unknown-unknown --features nightly --test wasm - - - job: test_cli - displayName: "Run wasm-bindgen-cli crate tests" - steps: - - template: ci/azure-install-rust.yml - - script: rustup target add wasm32-unknown-unknown - displayName: "install wasm target" - - task: NodeTool@0 - inputs: - versionSpec: '>=15.0' - - script: cargo test -p wasm-bindgen-cli-support - displayName: "wasm-bindgen-cli-support tests" - - script: cargo test -p wasm-bindgen-cli - displayName: "wasm-bindgen-cli tests" - - script: cargo test -p wasm-bindgen-externref-xform - displayName: "wasm-bindgen-externref-xform tests" - - script: cargo test -p wasm-bindgen-multi-value-xform - displayName: "wasm-bindgen-multi-value-xform tests" - - script: cargo test -p wasm-bindgen-wasm-interpreter - displayName: "wasm-bindgen-wasm-interpreter tests" - - - job: test_web_sys - displayName: "Run web-sys crate tests" - steps: - - template: ci/azure-install-rust.yml - - template: ci/azure-install-node.yml - - template: ci/azure-install-geckodriver.yml - - script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown - - script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Node - - script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Element - - script: cargo build --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --features Window - - script: cargo test --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --all-features - - script: cargo test --manifest-path crates/web-sys/Cargo.toml --target wasm32-unknown-unknown --all-features - displayName: "web-sys unstable APIs" - env: - RUSTFLAGS: --cfg=web_sys_unstable_apis - - - job: check_web_sys - displayName: "Verify that web-sys is compiled correctly" - steps: - - template: ci/azure-install-rust.yml - - script: cd crates/web-sys && cargo run --release --package wasm-bindgen-webidl -- webidls src/features - - script: git diff --exit-code - - - job: test_js_sys - displayName: "Run js-sys crate tests" - steps: - - template: ci/azure-install-rust.yml - - template: ci/azure-install-node.yml - - template: ci/azure-install-geckodriver.yml - - script: cargo test -p js-sys --target wasm32-unknown-unknown - - - job: test_webidl - displayName: "Run wasm-bindgen-webidl crate tests" - steps: - - template: ci/azure-install-rust.yml - - template: ci/azure-install-node.yml - - script: cargo test -p wasm-bindgen-webidl - - script: cargo test -p webidl-tests --target wasm32-unknown-unknown - env: - WBINDGEN_I_PROMISE_JS_SYNTAX_WORKS_IN_NODE: 1 - - script: cargo test -p webidl-tests --target wasm32-unknown-unknown - displayName: "webidl-tests unstable APIs" - env: - RUSTFLAGS: --cfg=web_sys_unstable_apis - - - job: test_ui - displayName: "Run UI tests" - steps: - - template: ci/azure-install-rust.yml - - template: ci/azure-install-node.yml - - script: cargo test -p wasm-bindgen-macro - - - job: test_typescript_output - displayName: "Test TypeScript output of wasm-bindgen" - steps: - - template: ci/azure-install-rust.yml - - template: ci/azure-install-node.yml - - script: cd crates/typescript-tests && ./run.sh - - - job: build_examples - displayName: "Build almost all examples" - steps: - - template: ci/azure-install-rust.yml - - template: ci/azure-install-wasm-pack.yml - - script: mv _package.json package.json && npm install && rm package.json - displayName: "run npm install" - - script: | - for dir in `ls examples | grep -v README | grep -v asm.js | grep -v raytrace | grep -v without-a-bundler | grep -v wasm-in-web-worker | grep -v websockets | grep -v webxr | grep -v deno`; do - (cd examples/$dir && - ln -fs ../../node_modules . && - npm run build -- --output-path $BUILD_ARTIFACTSTAGINGDIRECTORY/exbuild/$dir) || exit 1; - done - displayName: "build examples" - - task: PublishPipelineArtifact@0 - inputs: - artifactName: examples1 - targetPath: '$(Build.ArtifactStagingDirectory)' - - - job: test_deno - displayName: "Build and test the deno example" - steps: - - template: ci/azure-install-rust.yml - - script: rustup target add wasm32-unknown-unknown - displayName: "install wasm target" - - template: ci/azure-install-deno.yml - - script: cd examples/deno && ./build.sh && $HOME/.deno/bin/deno run --allow-read test.ts - displayName: "build and run deno example" - - - job: build_raytrace - displayName: "Build raytrace examples" - steps: - - template: ci/azure-install-rust.yml - parameters: - toolchain: nightly-2021-09-02 - - script: rustup component add rust-src - displayName: "install rust-src" - - script: | - set -e - sed -i 's/python/#python/' examples/raytrace-parallel/build.sh - (cd examples/raytrace-parallel && ./build.sh) - cp examples/raytrace-parallel/*.{js,html,wasm} $BUILD_ARTIFACTSTAGINGDIRECTORY - displayName: "build example" - - task: PublishPipelineArtifact@0 - inputs: - artifactName: examples2 - targetPath: '$(Build.ArtifactStagingDirectory)' - - - job: build_benchmarks - displayName: "Build benchmarks" - steps: - - template: ci/azure-install-rust.yml - - script: rustup target add wasm32-unknown-unknown - displayName: "add target" - - script: cargo build --manifest-path benchmarks/Cargo.toml --release --target wasm32-unknown-unknown - displayName: "build benchmarks" - - script: cargo run -p wasm-bindgen-cli -- target/wasm32-unknown-unknown/release/wasm_bindgen_benchmark.wasm --out-dir benchmarks/pkg --target web - displayName: "run wasm-bindgen" - - task: PublishPipelineArtifact@0 - inputs: - artifactName: benchmarks - targetPath: benchmarks - - - job: dist_linux - displayName: "Dist Linux binary" - steps: - - template: ci/azure-install-rust.yml - - script: rustup target add x86_64-unknown-linux-musl - - script: | - sudo apt update -y - sudo apt install musl-tools -y - displayName: "Install musl-tools" - - script: | - set -ex - cargo build --manifest-path crates/cli/Cargo.toml --target x86_64-unknown-linux-musl --features vendored-openssl --release - strip -g target/x86_64-unknown-linux-musl/release/wasm-bindgen - strip -g target/x86_64-unknown-linux-musl/release/wasm-bindgen-test-runner - strip -g target/x86_64-unknown-linux-musl/release/wasm2es6js - - template: ci/azure-create-tarball.yml - parameters: - artifacts: target/x86_64-unknown-linux-musl/release - name: dist_linux - - - job: dist_darwin - displayName: "Dist Darwin binary" - pool: - vmImage: macOS-10.15 - steps: - - template: ci/azure-install-rust.yml - - script: cargo build --manifest-path crates/cli/Cargo.toml --release - env: - MACOSX_DEPLOYMENT_TARGET: 10.7 - - template: ci/azure-create-tarball.yml - parameters: - name: dist_darwin - - - job: dist_windows - displayName: "Dist Windows binary" - pool: - vmImage: vs2017-win2016 - steps: - - template: ci/azure-install-rust.yml - - script: cargo build --manifest-path crates/cli/Cargo.toml --release - env: - RUSTFLAGS: -Ctarget-feature=+crt-static - - template: ci/azure-create-tarball.yml - parameters: - name: dist_windows - - - job: doc_book - displayName: "Doc - build the book" - steps: - - script: | - set -e - curl -L https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.0/mdbook-v0.3.0-x86_64-unknown-linux-gnu.tar.gz | tar xzf - - echo "##vso[task.prependpath]$PWD" - displayName: "Install mdbook" - - script: (cd guide && mdbook build) - - task: PublishPipelineArtifact@0 - inputs: - artifactName: doc_book - targetPath: guide/book/html - - - job: doc_api - displayName: "Doc - build the API documentation" - steps: - - template: ci/azure-install-rust.yml - parameters: - toolchain: nightly - - script: cargo doc --no-deps --features 'nightly serde-serialize' - displayName: "Document wasm-bindgen" - - script: cargo doc --no-deps --manifest-path crates/js-sys/Cargo.toml - displayName: "Document js-sys" - - script: cargo doc --no-deps --manifest-path crates/web-sys/Cargo.toml --all-features - displayName: "Document web-sys" - env: - RUSTDOCFLAGS: --cfg=web_sys_unstable_apis - - script: cargo doc --no-deps --manifest-path crates/futures/Cargo.toml - displayName: "Document wasm-bindgen-futures" - # Make a tarball even though a zip is uploaded, it looks like the tarball - # makes the uploading step much speedier. - - script: tar czvf $BUILD_ARTIFACTSTAGINGDIRECTORY/docs.tar.gz target/doc - - task: PublishPipelineArtifact@0 - inputs: - artifactName: doc_api - targetPath: target/doc - - - job: deploy - dependsOn: - - doc_api - - doc_book - - dist_linux - - dist_darwin - - dist_windows - - build_examples - - build_raytrace - - build_benchmarks - displayName: "Deploy everything" - steps: - - template: ci/azure-install-rust.yml - - task: DownloadPipelineArtifact@0 - displayName: "Download docs - api" - inputs: - artifactName: doc_api - targetPath: gh-pages/api - - task: DownloadPipelineArtifact@0 - displayName: "Download docs - book" - inputs: - artifactName: doc_book - targetPath: gh-pages - - task: DownloadPipelineArtifact@0 - displayName: "Download examples" - inputs: - artifactName: examples1 - targetPath: gh-pages - - task: DownloadPipelineArtifact@0 - displayName: "Download examples - raytracer" - inputs: - artifactName: examples2 - targetPath: gh-pages/exbuild/raytrace-parallel - - task: DownloadPipelineArtifact@0 - displayName: "Download benchmarks" - inputs: - artifactName: benchmarks - targetPath: gh-pages/benchmarks - - task: DownloadPipelineArtifact@0 - displayName: "Download dist - windows" - inputs: - artifactName: dist_windows - targetPath: tmp/windows - - task: DownloadPipelineArtifact@0 - displayName: "Download dist - linux" - inputs: - artifactName: dist_linux - targetPath: tmp/linux - - task: DownloadPipelineArtifact@0 - displayName: "Download dist - darwin" - inputs: - artifactName: dist_darwin - targetPath: tmp/darwin - - script: | - set -ex - mkdir -p gh-release - find . - tag=`git describe --tags` - mk() { - target=$1 - src=$2 - name=wasm-bindgen-$tag-$target - mkdir -p tmp/$name - cp README.md \ - LICENSE-MIT \ - LICENSE-APACHE \ - tmp/$src/wasm* \ - tmp/$name/ - chmod +x tmp/$name/wasm* - tar czvf gh-release/$name.tar.gz -C tmp $name - } - mk x86_64-unknown-linux-musl linux - mk x86_64-apple-darwin darwin - mk x86_64-pc-windows-msvc windows - displayName: "prepare the github releases tarball artifacts" - - task: PublishPipelineArtifact@0 - displayName: "publish gh_release artifact" - inputs: - artifactName: gh_release - targetPath: gh-release - - task: PublishPipelineArtifact@0 - displayName: "publish gh_pages artifact" - inputs: - artifactName: gh_pages - targetPath: gh-pages - - script: curl -LsSf https://git.io/fhJ8n | rustc - && (cd gh-pages && ../rust_out) - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - env: - GITHUB_DEPLOY_KEY: $(GITHUB_DEPLOY_KEY) - - task: GithubRelease@0 - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) - displayName: 'Create GitHub Release' - inputs: - gitHubConnection: alexcrichton-token - repositoryName: rustwasm/wasm-bindgen - assets: gh-release/*.tar.gz diff --git a/ci/azure-create-tarball.yml b/ci/azure-create-tarball.yml deleted file mode 100644 index 23a09851d..000000000 --- a/ci/azure-create-tarball.yml +++ /dev/null @@ -1,16 +0,0 @@ -parameters: - artifacts: 'target/release' - name: '' - -steps: - - bash: | - set -ex - dst=$BUILD_ARTIFACTSTAGINGDIRECTORY - rm -f ${{ parameters.artifacts }}/wasm*.d - rm -f ${{ parameters.artifacts }}/wasm*.pdb - cp ${{ parameters.artifacts }}/wasm* $dst/ - displayName: Create distribution tarball - - task: PublishPipelineArtifact@0 - inputs: - artifactName: ${{ parameters.name }} - targetPath: '$(Build.ArtifactStagingDirectory)' diff --git a/ci/azure-install-deno.yml b/ci/azure-install-deno.yml deleted file mode 100644 index b995c7c8b..000000000 --- a/ci/azure-install-deno.yml +++ /dev/null @@ -1,3 +0,0 @@ -steps: - - script: curl -fsSL https://deno.land/x/install/install.sh | sh - displayName: "install deno" diff --git a/ci/azure-install-geckodriver.yml b/ci/azure-install-geckodriver.yml deleted file mode 100644 index 702428b83..000000000 --- a/ci/azure-install-geckodriver.yml +++ /dev/null @@ -1,25 +0,0 @@ -steps: - - bash: | - curl --retry 5 -LO https://github.com/mozilla/geckodriver/releases/download/v0.21.0/geckodriver-v0.21.0-linux64.tar.gz - tar xf geckodriver-v0.21.0-linux64.tar.gz - echo "##vso[task.setvariable variable=GECKODRIVER;]$PWD/geckodriver" - displayName: "Download Geckodriver (Linux)" - condition: eq( variables['Agent.OS'], 'Linux' ) - - - powershell: | - Invoke-WebRequest https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-win64.zip -OutFile gecko.zip - unzip gecko.zip - Write-Host "##vso[task.setvariable variable=GECKODRIVER;]$pwd\geckodriver.exe" - displayName: "Download Geckodriver (Windows)" - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - - # It turns out that geckodriver.exe will fail if firefox takes too long to - # start, and for whatever reason the first execution of `firefox.exe` can - # take upwards of a mimute. It seems that subsequent executions are much - # faster, so have a dedicated step to run Firefox once which should I - # guess warm some cache somewhere so the headless tests later on all - # finish successfully - - script: | - "C:\Program Files\Mozilla Firefox\firefox.exe" --version - displayName: "Load firefox.exe into cache (presumably?)" - condition: eq( variables['Agent.OS'], 'Windows_NT' ) diff --git a/ci/azure-install-node.yml b/ci/azure-install-node.yml deleted file mode 100644 index 147a844e7..000000000 --- a/ci/azure-install-node.yml +++ /dev/null @@ -1,6 +0,0 @@ -steps: - - script: rustup target add wasm32-unknown-unknown - displayName: "Add WebAssembly target via rustup" - - task: NodeTool@0 - inputs: - versionSpec: '>=12.11' diff --git a/ci/azure-install-rust.yml b/ci/azure-install-rust.yml deleted file mode 100644 index d75af37bb..000000000 --- a/ci/azure-install-rust.yml +++ /dev/null @@ -1,29 +0,0 @@ -parameters: - toolchain: 'stable' - -steps: - - bash: | - set -e - if command -v rustup; then - rustup set profile minimal - rustup update $TOOLCHAIN - rustup default $TOOLCHAIN - else - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TOOLCHAIN - echo "##vso[task.prependpath]$HOME/.cargo/bin" - fi - displayName: Install rust - Unix - condition: ne( variables['Agent.OS'], 'Windows_NT' ) - env: - TOOLCHAIN: ${{ parameters.toolchain }} - - - bash: rustup update --no-self-update $TOOLCHAIN && rustup default $TOOLCHAIN - displayName: Install rust - Windows - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - env: - TOOLCHAIN: ${{ parameters.toolchain }} - - - script: | - rustc -Vv - cargo -V - displayName: Query rust and cargo versions diff --git a/ci/azure-install-sccache.yml b/ci/azure-install-sccache.yml deleted file mode 100644 index 0650d2ec0..000000000 --- a/ci/azure-install-sccache.yml +++ /dev/null @@ -1,35 +0,0 @@ -steps: - - bash: | - set -ex - curl -L https://github.com/mozilla/sccache/releases/download/0.2.11/sccache-0.2.11-x86_64-unknown-linux-musl.tar.gz | tar xzf - - sccache=`pwd`/sccache-0.2.11-x86_64-unknown-linux-musl/sccache - echo "##vso[task.setvariable variable=RUSTC_WRAPPER;]$sccache" - displayName: Install sccache - Linux - condition: eq( variables['Agent.OS'], 'Linux' ) - - - bash: | - set -ex - brew install openssl@1.1 - curl -L https://github.com/mozilla/sccache/releases/download/0.2.11/sccache-0.2.11-x86_64-apple-darwin.tar.gz | tar xzf - - sccache=`pwd`/sccache-0.2.11-x86_64-apple-darwin/sccache - echo "##vso[task.setvariable variable=RUSTC_WRAPPER;]$sccache" - displayName: Install sccache - Darwin - condition: eq( variables['Agent.OS'], 'Darwin' ) - - - powershell: | - Invoke-WebRequest https://github.com/mozilla/sccache/releases/download/0.2.11/sccache-0.2.11-x86_64-pc-windows-msvc.tar.gz -OutFile sccache.tar.gz - tar xzf sccache.tar.gz - Write-Host "##vso[task.setvariable variable=RUSTC_WRAPPER;]$pwd/sccache-0.2.11-x86_64-pc-windows-msvc/sccache.exe" - displayName: Install sccache - Windows - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - - - bash: | - set -ex - env - SCCACHE_ERROR_LOG=`pwd`/sccache.log RUST_LOG=debug $RUSTC_WRAPPER --start-server - $RUSTC_WRAPPER -s - cat sccache.log - displayName: "start sccache" - env: - AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID) - AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) diff --git a/ci/azure-install-wasm-pack.yml b/ci/azure-install-wasm-pack.yml deleted file mode 100644 index 8afcbee21..000000000 --- a/ci/azure-install-wasm-pack.yml +++ /dev/null @@ -1,8 +0,0 @@ -steps: - - script: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f - displayName: "install wasm-pack" - - script: | - set -ex - cargo build -p wasm-bindgen-cli - ln -snf `pwd`/target/debug/wasm-bindgen $(dirname `which cargo`)/wasm-bindgen - displayName: "install wasm-bindgen for `wasm-pack` to use" diff --git a/crates/macro/ui-tests/missing-catch.stderr b/crates/macro/ui-tests/missing-catch.stderr index 631adc71d..4c20dbe76 100644 --- a/crates/macro/ui-tests/missing-catch.stderr +++ b/crates/macro/ui-tests/missing-catch.stderr @@ -4,7 +4,14 @@ error[E0277]: the trait bound `Result Result; | ^^^ the trait `FromWasmAbi` is not implemented for `Result` | - ::: $WORKSPACE/src/convert/traits.rs +note: required by a bound in `FromWasmAbi` + --> $DIR/traits.rs:23:1 | - | pub trait FromWasmAbi: WasmDescribe { - | ----------------------------------- required by this bound in `FromWasmAbi` +23 | / pub trait FromWasmAbi: WasmDescribe { +24 | | /// The wasm ABI type that this converts from when coming back out from the +25 | | /// ABI boundary. +26 | | type Abi: WasmAbi; +... | +35 | | unsafe fn from_abi(js: Self::Abi) -> Self; +36 | | } + | |_^ required by this bound in `FromWasmAbi` diff --git a/crates/macro/ui-tests/pub-not-copy.stderr b/crates/macro/ui-tests/pub-not-copy.stderr index 66d7314f6..0cb088cd1 100644 --- a/crates/macro/ui-tests/pub-not-copy.stderr +++ b/crates/macro/ui-tests/pub-not-copy.stderr @@ -1,8 +1,12 @@ error[E0277]: the trait bound `String: std::marker::Copy` is not satisfied --> $DIR/pub-not-copy.rs:5:16 | -3 | #[wasm_bindgen] - | --------------- required by this bound in `assert_copy` -4 | pub struct A { 5 | pub field: String, | ^^^^^^ the trait `std::marker::Copy` is not implemented for `String` + | +note: required by a bound in `assert_copy` + --> $DIR/pub-not-copy.rs:3:1 + | +3 | #[wasm_bindgen] + | ^^^^^^^^^^^^^^^ required by this bound in `assert_copy` + = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/macro/ui-tests/traits-not-implemented.stderr b/crates/macro/ui-tests/traits-not-implemented.stderr index 58d48b4ad..7b0f90f57 100644 --- a/crates/macro/ui-tests/traits-not-implemented.stderr +++ b/crates/macro/ui-tests/traits-not-implemented.stderr @@ -1,12 +1,18 @@ error[E0277]: the trait bound `A: IntoWasmAbi` is not satisfied - --> $DIR/traits-not-implemented.rs:5:1 - | -5 | #[wasm_bindgen] - | ^^^^^^^^^^^^^^^ the trait `IntoWasmAbi` is not implemented for `A` - | - ::: $WORKSPACE/src/convert/traits.rs - | - | pub trait IntoWasmAbi: WasmDescribe { - | ----------------------------------- required by this bound in `IntoWasmAbi` - | - = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) + --> $DIR/traits-not-implemented.rs:5:1 + | +5 | #[wasm_bindgen] + | ^^^^^^^^^^^^^^^ the trait `IntoWasmAbi` is not implemented for `A` + | +note: required by a bound in `IntoWasmAbi` + --> $DIR/traits.rs:9:1 + | +9 | / pub trait IntoWasmAbi: WasmDescribe { +10 | | /// The wasm ABI type that this converts into when crossing the ABI +11 | | /// boundary. +12 | | type Abi: WasmAbi; +... | +16 | | fn into_abi(self) -> Self::Abi; +17 | | } + | |_^ required by this bound in `IntoWasmAbi` + = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)