diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 206c534962..0855907f05 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -204,9 +204,103 @@ jobs: uses: './.github/actions/iota-sandbox/setup' - name: Run Wasm examples - run: npm run test:examples + run: npm run test:readme && npm run test:node working-directory: bindings/wasm - name: Tear down iota sandbox if: always() uses: './.github/actions/iota-sandbox/tear-down' + + test-wasm-firefox: + needs: build-wasm + if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + include: + - os: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 16.x + + - name: Install JS dependencies + run: npm ci + working-directory: bindings/wasm + + - name: Download bindings/wasm artifacts + uses: actions/download-artifact@v2 + with: + name: identity-wasm-bindings-build + path: bindings/wasm + + - name: Start iota sandbox + uses: './.github/actions/iota-sandbox/setup' + + - name: Build Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: bindings/wasm/ + file: bindings/wasm/cypress/Dockerfile + push: false + labels: cypress-test:latest + + - name: Run cypress + run: docker run cypress-test --browser firefox + + - name: Tear down iota sandbox + if: always() + uses: './.github/actions/iota-sandbox/tear-down' + + test-wasm-chrome: + needs: build-wasm + if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + include: + - os: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 16.x + + - name: Install JS dependencies + run: npm ci + working-directory: bindings/wasm + + - name: Download bindings/wasm artifacts + uses: actions/download-artifact@v2 + with: + name: identity-wasm-bindings-build + path: bindings/wasm + + - name: Start iota sandbox + uses: './.github/actions/iota-sandbox/setup' + + - name: Build Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: bindings/wasm/ + file: bindings/wasm/cypress/Dockerfile + push: false + labels: cypress-test:latest + + - name: Run cypress + run: docker run cypress-test --browser chrome + + - name: Tear down iota sandbox + if: always() + uses: './.github/actions/iota-sandbox/tear-down' diff --git a/bindings/wasm/.dockerignore b/bindings/wasm/.dockerignore new file mode 100644 index 0000000000..2c085d1d2f --- /dev/null +++ b/bindings/wasm/.dockerignore @@ -0,0 +1,2 @@ +node_modules +target diff --git a/bindings/wasm/cypress/Dockerfile b/bindings/wasm/cypress/Dockerfile new file mode 100644 index 0000000000..5ea3f7433b --- /dev/null +++ b/bindings/wasm/cypress/Dockerfile @@ -0,0 +1,11 @@ +FROM cypress/browsers:latest + +COPY ./ /e2e + +WORKDIR /e2e + +RUN npm ci + +RUN npm run build:examples:web + +ENTRYPOINT [ "npm", "run" ] \ No newline at end of file diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 2aef8087ba..6aacd6014d 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -19,8 +19,7 @@ "build:examples:web": "tsc --project ./examples/tsconfig.web.json && node ./build/replace_paths ./examples/tsconfig.web.json ./examples/dist resolve", "build": "npm run build:web && npm run build:nodejs && npm run build:docs", "example:node": "ts-node --project tsconfig.node.json -r tsconfig-paths/register ./examples/src/main.ts", - "test": "npm run test:unit:node && npm run test:examples", - "test:examples": "npm run test:readme && concurrently -g --timings \"npm run test:node\" \"npm run test:browser:parallel\"", + "test": "npm run test:unit:node && npm run test:readme && npm run test:node && test:browser:parallel", "test:node": "ts-mocha -r tsconfig-paths/register -p tsconfig.node.json ./examples/src/tests/*.ts --parallel --jobs 4 --retries 3 --timeout 180000 --exit", "test:browser:parallel": "npm run build:examples:web && cypress-parallel -s test:browser -t 4 -d cypress/e2e -a '\"--quiet\"'", "test:browser": "cypress run --headless",