Skip to content

Add end2end testing for examples #398

Add end2end testing for examples

Add end2end testing for examples #398

Workflow file for this run

name: Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
CARGO_TERM_COLOR: always
jobs:
lib_test:
name: Test ${{ matrix.package }} package
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ["leptos_i18n", "leptos_i18n_macro"]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Load cargo toolchain"
uses: dtolnay/rust-toolchain@stable
- name: "Install cargo-all-features"
run: cargo install cargo-all-features
- name: "Test all features"
run: cargo test-all-features --n-chunks ${{ strategy.job-total }} --chunk $(expr ${{ strategy.job-index }} + 1)
test_ssr_examples:
name: Test ${{ matrix.examples }} example
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
examples: [hello_world_actix, hello_world_axum, workspace, axum_island]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version: 18
- name: "Setup Rust toolchain"
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "stable"
targets: "wasm32-unknown-unknown"
- name: "Install cargo-leptos"
run: cargo install cargo-leptos
- name: "Install Playwright"
working-directory: examples/${{ matrix.examples }}/e2e
run: |
npm ci
npx playwright install --with-deps
- name: "Build ${{ matrix.examples }} example"
working-directory: examples/${{ matrix.examples }}
run: cargo leptos build
- name: "e2e testing ${{ matrix.examples }} example"
working-directory: examples/${{ matrix.examples }}
run: cargo leptos end-to-end
- name: "Upload e2e report"
uses: actions/upload-artifact@v4
# upload artifact only if test failed
if: ${{ failure() && !cancelled() }}
with:
name: playwright-report-${{ matrix.examples }}
path: examples/${{ matrix.examples }}/e2e/playwright-report/
test_csr_examples:
name: Test ${{ matrix.examples }} example
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
examples:
[counter, counter_plurals, interpolation, namespaces, subkeys, yaml]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version: 18
- name: "Setup Rust toolchain"
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "stable"
targets: "wasm32-unknown-unknown"
- name: "Install trunk"
run: cargo install trunk
- name: "Install Playwright"
working-directory: examples/${{ matrix.examples }}
run: |
npm ci
npx playwright install --with-deps
cargo install trunk
- name: "Build ${{ matrix.examples }} example"
working-directory: examples/${{ matrix.examples }}
run: trunk build
- name: "e2e testing ${{ matrix.examples }} example"
working-directory: examples/${{ matrix.examples }}
run: npx playwright test
- name: "Upload e2e report"
uses: actions/upload-artifact@v4
# upload artifact only if test failed
if: ${{ failure() && !cancelled() }}
with:
name: playwright-report-${{ matrix.examples }}
path: examples/${{ matrix.examples }}/playwright-report/
test_suite:
name: Test suite ${{ matrix.tests_suites }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tests_suites: [json, yaml, namespaces]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Install wasm32-unknown-unknown"
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "stable"
- name: Running test suite ${{ matrix.tests_suites }}
working-directory: tests/${{ matrix.tests_suites }}
run: cargo test