Skip to content

Commit 877206d

Browse files
committed
Switch from shell to npm scripts for demo using webpack and @wasm-tool/wasm-pack-plugin
Also change travis deploy to use new demo directory.
1 parent c38796b commit 877206d

File tree

6 files changed

+103
-102
lines changed

6 files changed

+103
-102
lines changed

.travis.yml

Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
language: rust
32

43
rust:
@@ -7,102 +6,106 @@ rust:
76
- nightly
87

98
script:
10-
- cargo build --verbose --all
11-
- cargo test --verbose --all
9+
- cargo build --verbose --all
10+
- cargo test --verbose --all
1211

1312
env:
14-
# This is used to only capture the regular nightly test in allow_failures
15-
- REGULAR_TEST=true
13+
# This is used to only capture the regular nightly test in allow_failures
14+
- REGULAR_TEST=true
1615

1716
cache: cargo
1817

1918
matrix:
20-
include:
21-
# To test the snippets, we use Travis' Python environment (because
22-
# installing rust ourselves is a lot easier than installing Python)
23-
- language: python
24-
python: 3.6
25-
cache:
26-
pip: true
27-
# Because we're using the Python Travis environment, we can't use
28-
# the built-in cargo cacher
29-
directories:
30-
- /home/travis/.cargo
31-
- target
32-
env:
33-
- TRAVIS_RUST_VERSION=stable
34-
- REGULAR_TEST=false
35-
script: tests/.travis-runner.sh
36-
- language: python
37-
python: 3.6
38-
cache:
39-
pip: true
40-
# Because we're using the Python Travis environment, we can't use
41-
# the built-in cargo cacher
42-
directories:
43-
- /home/travis/.cargo
44-
- target
45-
env:
46-
- TRAVIS_RUST_VERSION=beta
47-
- REGULAR_TEST=false
48-
script: tests/.travis-runner.sh
49-
- name: rustfmt
50-
language: rust
51-
rust: stable
52-
cache: cargo
53-
before_script:
54-
- rustup component add rustfmt-preview
55-
script:
56-
# Code references the generated python.rs, so put something in
57-
# place to make `cargo fmt` happy. (We use `echo` rather than
58-
# `touch` because rustfmt complains about the empty file touch
59-
# creates.)
60-
- echo > parser/src/python.rs
61-
- cargo fmt --all -- --check
62-
env:
63-
- REGULAR_TEST=false
64-
- name: publish documentation
65-
language: rust
66-
rust: stable
67-
cache: cargo
68-
script:
69-
- cargo doc --no-deps --all
70-
if: branch = release
71-
env:
72-
- REGULAR_TEST=false
73-
- name: WASM online demo
74-
language: rust
75-
rust: nightly
76-
cache: cargo
77-
install:
78-
- nvm install node
79-
- curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh # install wasm-pack
80-
script:
81-
- cd wasm
82-
- bash release.sh
83-
if: branch = release
84-
env:
85-
- REGULAR_TEST=false
86-
allow_failures:
87-
- rust: nightly
88-
env: REGULAR_TEST=true
19+
include:
20+
# To test the snippets, we use Travis' Python environment (because
21+
# installing rust ourselves is a lot easier than installing Python)
22+
- language: python
23+
python: 3.6
24+
cache:
25+
pip: true
26+
# Because we're using the Python Travis environment, we can't use
27+
# the built-in cargo cacher
28+
directories:
29+
- /home/travis/.cargo
30+
- target
31+
env:
32+
- TRAVIS_RUST_VERSION=stable
33+
- REGULAR_TEST=false
34+
script: tests/.travis-runner.sh
35+
- language: python
36+
python: 3.6
37+
cache:
38+
pip: true
39+
# Because we're using the Python Travis environment, we can't use
40+
# the built-in cargo cacher
41+
directories:
42+
- /home/travis/.cargo
43+
- target
44+
env:
45+
- TRAVIS_RUST_VERSION=beta
46+
- REGULAR_TEST=false
47+
script: tests/.travis-runner.sh
48+
- name: rustfmt
49+
language: rust
50+
rust: stable
51+
cache: cargo
52+
before_script:
53+
- rustup component add rustfmt-preview
54+
script:
55+
# Code references the generated python.rs, so put something in
56+
# place to make `cargo fmt` happy. (We use `echo` rather than
57+
# `touch` because rustfmt complains about the empty file touch
58+
# creates.)
59+
- echo > parser/src/python.rs
60+
- cargo fmt --all -- --check
61+
env:
62+
- REGULAR_TEST=false
63+
- name: publish documentation
64+
language: rust
65+
rust: stable
66+
cache: cargo
67+
script:
68+
- cargo doc --no-deps --all
69+
if: branch = release
70+
env:
71+
- REGULAR_TEST=false
72+
- name: WASM online demo
73+
language: rust
74+
rust: nightly
75+
cache: cargo
76+
install:
77+
- nvm install node
78+
# install wasm-pack
79+
- curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
80+
script:
81+
- cd wasm/demo
82+
- npm install
83+
- npm run dist
84+
if: branch = release
85+
env:
86+
- REGULAR_TEST=false
87+
allow_failures:
88+
- rust: nightly
89+
env: REGULAR_TEST=true
8990

9091
deploy:
9192
- provider: pages
9293
repo: RustPython/website
9394
target-branch: master
9495
local-dir: target/doc
9596
skip-cleanup: true
96-
github-token: $WEBSITE_GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
97+
# Set in the settings page of your repository, as a secure variable
98+
github-token: $WEBSITE_GITHUB_TOKEN
9799
keep-history: true
98100
on:
99101
branch: release
100102
- provider: pages
101103
repo: RustPython/demo
102104
target-branch: master
103-
local-dir: wasm/app/dist
105+
local-dir: wasm/demo/dist
104106
skip-cleanup: true
105-
github-token: $WEBSITE_GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
107+
# Set in the settings page of your repository, as a secure variable
108+
github-token: $WEBSITE_GITHUB_TOKEN
106109
keep-history: true
107110
on:
108111
branch: release

wasm/build.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

wasm/demo/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"codemirror": "^5.42.0"
88
},
99
"devDependencies": {
10+
"@wasm-tool/wasm-pack-plugin": "0.2.0",
1011
"webpack": "^4.16.3",
1112
"webpack-cli": "^3.1.0",
1213
"webpack-dev-server": "^3.1.5",
@@ -16,7 +17,9 @@
1617
"css-loader": "^2.0.1"
1718
},
1819
"scripts": {
19-
"test": "echo \"Error: no test specified\" && exit 1"
20+
"dev": "webpack-dev-server -d",
21+
"build": "webpack",
22+
"dist": "webpack --mode production"
2023
},
2124
"repository": {
2225
"type": "git",

wasm/demo/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const HtmlWebpackPlugin = require('html-webpack-plugin');
22
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
3+
const WasmPackPlugin = require('@wasm-tool/wasm-pack-plugin');
34
const path = require('path');
45

56
module.exports = {
@@ -21,6 +22,9 @@ module.exports = {
2122
}),
2223
new MiniCssExtractPlugin({
2324
filename: 'styles.css'
25+
}),
26+
new WasmPackPlugin({
27+
crateDirectory: path.join(__dirname, '../lib')
2428
})
2529
]
2630
};

wasm/demo/yarn.lock

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
# yarn lockfile v1
33

44

5+
"@wasm-tool/[email protected]":
6+
version "0.2.0"
7+
resolved "https://registry.yarnpkg.com/@wasm-tool/wasm-pack-plugin/-/wasm-pack-plugin-0.2.0.tgz#d8936ce3483f27c8ff4241c418273434305b8b4d"
8+
integrity sha512-L4xdsFLfO6wtXbjNXeJ0c/ZxvdFCYYimYybcnDOJpPnz3pMr4lXOJkQcm8PKkbjTEgzojwioytUAzH79jzKvkQ==
9+
dependencies:
10+
chalk "^2.4.1"
11+
command-exists "^1.2.7"
12+
watchpack "^1.6.0"
13+
514
"@webassemblyjs/[email protected]":
615
version "1.7.11"
716
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.11.tgz#b988582cafbb2b095e8b556526f30c90d057cace"
@@ -711,6 +720,11 @@ [email protected]:
711720
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
712721
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
713722

723+
command-exists@^1.2.7:
724+
version "1.2.8"
725+
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.8.tgz#715acefdd1223b9c9b37110a149c6392c2852291"
726+
integrity sha512-PM54PkseWbiiD/mMsbvW351/u+dafwTJ0ye2qB60G1aGQP9j3xK2gmMDc+R34L3nDtx4qMCitXT75mkbkGJDLw==
727+
714728
[email protected], commander@~2.17.1:
715729
version "2.17.1"
716730
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
@@ -4089,7 +4103,7 @@ [email protected]:
40894103
dependencies:
40904104
indexof "0.0.1"
40914105

4092-
watchpack@^1.5.0:
4106+
watchpack@^1.5.0, watchpack@^1.6.0:
40934107
version "1.6.0"
40944108
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00"
40954109
integrity sha512-i6dHe3EyLjMmDlU1/bGQpEw25XSjkJULPuAVKCbNRefQVq48yXKUpwg538F7AZTf9kyr57zj++pQFltUa5H7yA==

wasm/release.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)