Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration testing on Zotero's Firefox ESR #108

Merged
merged 10 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
ignore:
- dependency-name: "*"
schedule:
interval: "monthly"
8 changes: 4 additions & 4 deletions .github/workflows/build-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Install Rust 1.43.1
- name: Install Rust 1.51.0
uses: actions-rs/toolchain@v1
with:
toolchain: 1.43.1
toolchain: 1.51.0
override: true
- name: Cache cargo directories
uses: actions/cache@v2
Expand Down Expand Up @@ -52,10 +52,10 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Install Rust 1.43.1
- name: Install Rust 1.51.0
uses: actions-rs/toolchain@v1
with:
toolchain: 1.43.1
toolchain: 1.51.0
override: true
- name: Cache cargo directories
uses: actions/cache@v2
Expand Down
34 changes: 20 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Install Rust 1.43.1
- name: Install Rust 1.51.0
uses: actions-rs/toolchain@v1
with:
toolchain: 1.43.1
toolchain: 1.51.0
override: true

- name: Cache cargo directories
uses: actions/cache@v2
with:
Expand All @@ -141,10 +142,6 @@ jobs:
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f

- name: Build WASM
working-directory: crates/wasm/js-tests
run: yarn build

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand All @@ -161,14 +158,23 @@ jobs:
working-directory: crates/wasm/js-tests
run: yarn install

- name: Run tests
- name: Build WASM
working-directory: crates/wasm/js-tests
run: yarn test
run: yarn build

# otherwise, the yarn cache will contain a different @citeproc-rs/wasm
# entry every time.
- name: Clean yarn cache dir of wasm output
run: |
cd "$(yarn cache dir)"
ls | grep citeproc-rs-wasm | xargs rm -rf
- name: Download Firefox ESR from zotero-standalone-build
working-directory: crates/wasm/js-tests
run: ./install_firefox.sh

- name: Run tests, including in Firefox ESR
working-directory: crates/wasm/js-tests
run: MUST_RUN_FIREFOX_TESTS=1 yarn test

# not necessary because we install @citeproc-rs/wasm without yarn knowing now
# # otherwise, the yarn cache will contain a different @citeproc-rs/wasm
# # entry every time.
# - name: Clean yarn cache dir of wasm output
# run: |
# cd "$(yarn cache dir)"
# ls | grep citeproc-rs-wasm | xargs rm -rf

71 changes: 51 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ default-members = [
"crates/citeproc",
]

[profile.dev]
# rust 1.51 release notes -- replaces dsymutil on macOS, faster dev builds
split-debuginfo = "unpacked"

[profile.bench]
lto = "thin"
# flamegraph with cargo test --release
Expand Down
9 changes: 3 additions & 6 deletions crates/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ description = "citeproc-rs, compiled to WebAssembly"
# TODO: Set the opt level on new wasm-pack 0.6.0 config
# when it's released, so as not to interfere with the
# other native binary targets (cargo only lets you set it
# on the workspace root)

# https://github.com/rustwasm/wasm-pack/issues/886#issuecomment-667669802
[package.metadata.wasm-pack.profile.release]
# wasm-opt = ["-O3", "--enable-mutable-globals", "-g"]
wasm-opt = false
wasm-opt = ["-O4", "-g"]

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down Expand Up @@ -56,6 +52,7 @@ serde = "1.0.116"
serde_derive = "1.0.116"
serde_json = "1.0.57"
thiserror = "1.0.22"
wasm-bindgen-test = "0.3.23"

[dependencies.rand]
version = "0.7.3"
Expand All @@ -64,7 +61,7 @@ features = ["wasm-bindgen"]
# getrandom = { version = "0.1.0", features = ["js"] }

[dependencies.wasm-bindgen]
version = "=0.2.62"
version = "0.2.70"
features = ["serde-serialize"]

[dependencies.log]
Expand Down
1 change: 1 addition & 0 deletions crates/wasm/js-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
zotero-standalone-build
23 changes: 23 additions & 0 deletions crates/wasm/js-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Running tests

Requires bash. Sorry Windows.

```sh
yarn
yarn build
./install_firefox.sh
yarn test
```

Running `yarn`/`yarn install` will delete the `node_modules/@citeproc-rs/wasm`
folder, so run `yarn build` again.

## Disabling the Firefox ESR integration test

```sh
yarn
yarn build
yarn test-node-only # this force-disables.
yarn jest # runs it if FIREFOX_BINARY_PATH is set to a firefox binary
```

24 changes: 24 additions & 0 deletions crates/wasm/js-tests/browser/browser.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// selenium-webdriver tests

if (process.env.MUST_RUN_FIREFOX_TESTS == "1" && !global.browser) {
throw new Error(`cannot run firefox tests, probably because no FIREFOX_BINARY_PATH provided`)
}

var suite = describe.skip;
if (global.browser) {
suite = describe;
}
suite("Integration tests for Firefox ESR 60.9", () => {
test("no-modules build works end to end", async () => {
// firefox could be first-booting itself. Give it time.
jest.setTimeout(60000);
await browser.get("file://" + __dirname + '/index.html');
let fail = browser.wait(until.elementLocated(By.id('failure')), 10000);
let succ = browser.wait(until.elementLocated(By.id('success')), 10000);
let el = await Promise.race([fail, succ]);
let id = await el.getAttribute("id");
let text = await el.getText();
expect(text).toBe("success");
expect(id).toBe("success");
})
})
14 changes: 14 additions & 0 deletions crates/wasm/js-tests/browser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title>eyah</title>
<meta charset="utf-8"/>
</head>
<body>
<script type="text/javascript"> console.log('seen before'); </script>
<script type="text/javascript" src="./pkg-nomod/_no_modules/citeproc_rs_wasm_include.js"></script>
<script type="text/javascript" src="./pkg-nomod/_no_modules/citeproc_rs_wasm.js"></script>
<script type="text/javascript"> console.log('seen after entry'); </script>
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript"> console.log('seen after script.js'); </script>
</body>
</html>
Loading