Skip to content

Commit

Permalink
Run examples on every test (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass committed Feb 10, 2022
1 parent ac7d591 commit c517925
Show file tree
Hide file tree
Showing 32 changed files with 5,016 additions and 2,658 deletions.
6 changes: 3 additions & 3 deletions .github/actions/rust/rust-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ runs:
override: true

- name: Cache cargo
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
# https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
path: |
Expand All @@ -52,7 +52,7 @@ runs:
command: update

- name: Cache build target
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
path: ${{ inputs.target-cache-path }}
# Add date to the cache to keep it up to date
Expand All @@ -63,7 +63,7 @@ runs:
${{ inputs.os }}-target-
- name: Cache sccache
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
path: ${{ inputs.sccache-path }}
key: ${{ inputs.os }}-sccache-${{ inputs.job }}-${{ hashFiles('**/Cargo.lock') }}
Expand Down
54 changes: 42 additions & 12 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,45 @@ on:
- '.github/actions/**'
- '**.rs'
- '**.toml'
- 'bindings/wasm/'
- '!bindings/wasm/**.md'

env:
RUST_BACKTRACE: full
CARGO_INCREMENTAL: 0 # disabled to reduce target cache size and improve sccache (https://github.com/mozilla/sccache#known-caveats)
SCCACHE_CACHE_SIZE: 2G
SCCACHE_IDLE_TIMEOUT: 0
# SCCACHE_RECACHE: 1 # uncomment to clear sccache cache, then re-comment

jobs:

check-for-modification:
runs-on: ubuntu-latest
outputs:
core-modified: ${{ steps.change-detection.outputs.core-modified }} # map step output to job output
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Run change detection
id: change-detection
run: |
echo comparing $(git rev-parse HEAD^) and $(git rev-parse HEAD)
#https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-emgitdiffemltoptionsgt--ltpathgt82308203
if [[ $(git diff HEAD^ HEAD -- ':!bindings') != '' ]]; then
# modified
CORE_MODIFIED=true
else
# unmodified
CORE_MODIFIED=false
fi
echo CORE_MODIFIED=$CORE_MODIFIED
echo "::set-output name=core-modified::$CORE_MODIFIED"
build-and-test:
runs-on: ${{ matrix.os }}
needs: check-for-modification
if: ${{ needs.check-for-modification.outputs.core-modified == 'true' }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -75,15 +104,22 @@ jobs:
uses: actions-rs/cargo@v1
with:
# Build the library, tests, and examples without running them to avoid recompilation in the run tests step
command: test
args: --all --release --no-run
command: build
args: --workspace --tests --examples --release

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all --release

- name: Run Rust examples
# run examples only on ubuntu for now
if: matrix.os == 'ubuntu-latest'
run: |
cargo read-manifest --manifest-path ./examples/Cargo.toml | \
jq -r '.targets[].name' | \
parallel -k -j 4 --retries 3 cargo run --example {} --release
- name: Stop sccache (Windows)
uses: './.github/actions/rust/sccache/stop-sccache-windows'
if: matrix.os == 'windows-latest'
Expand Down Expand Up @@ -133,7 +169,6 @@ jobs:
sccache-path: /home/runner/.cache/sccache
env:
SCCACHE_DIR: ${{ matrix.sccache-path }}
CARGO_INCREMENTAL: 0 # disabled to reduce target cache size
RUSTC_WRAPPER: sccache

steps:
Expand Down Expand Up @@ -167,9 +202,6 @@ jobs:
with:
node-version: 16.x

- name: Install wasm-pack
run: npm install -g wasm-pack

- name: Install JS dependencies
run: npm install
working-directory: bindings/wasm
Expand All @@ -183,13 +215,11 @@ jobs:
working-directory: bindings/wasm

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path ./bindings/wasm/Cargo.toml --release
run: cargo test --release
working-directory: bindings/wasm

- name: Run wasm-bindgen tests # tests annotated with #[wasm_bindgen_test]
run: wasm-pack test --node
- name: Run Wasm unit tests and examples
run: npm run test
working-directory: bindings/wasm

- name: Stop sccache (Ubuntu/MacOS)
Expand Down
131 changes: 0 additions & 131 deletions .github/workflows/examples.yml

This file was deleted.

5 changes: 5 additions & 0 deletions bindings/wasm/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ pkg/
cypress/screenshots/
cypress/videos/

# files generated by cypress-parallel
multi-reporter-config.json
runner-results
cypress/parallel-weights.json

.DS_STORE
5 changes: 4 additions & 1 deletion bindings/wasm/cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"screenshotOnRunFailure": false,
"video": false
"video": false,
"retries": {
"runMode": 3
}
}
70 changes: 0 additions & 70 deletions bindings/wasm/cypress/integration/browser_test.js

This file was deleted.

25 changes: 25 additions & 0 deletions bindings/wasm/cypress/integration/createDiff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
createDiff,
defaultClientConfig,
initIdentity,
} from '../../examples/dist/web'

describe(
"createDiff",
{
defaultCommandTimeout: 1000*60*3, // 3 minutes to account for spurious network delays
},
() => {
before(async () => {
// The working directory is under __cypress at test runtime, so we need to go up one more level than usual
await initIdentity('../../../examples/dist/identity_wasm_bg.wasm');

// NOTE: `cy.wrap(defaultClientConfig()).as('config')` does not always work to make the config available
// from the shared context as `this.config` because it has a race condition with initializing the wasm.
// So call `defaultClientConfig()` manually for now.
});
it("Diff Chain", async () => {
await createDiff(defaultClientConfig());
});
}
);
Loading

0 comments on commit c517925

Please sign in to comment.