|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [main, develop] |
| 7 | + tags: ["v*"] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + test-rust: |
| 14 | + name: Rust tests |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Setup Rust |
| 20 | + uses: dtolnay/rust-toolchain@stable |
| 21 | + |
| 22 | + - name: Run Rust tests |
| 23 | + run: cargo test -p badwords-core |
| 24 | + |
| 25 | + test-python: |
| 26 | + name: Python tests (${{ matrix.python-version }}) |
| 27 | + runs-on: ubuntu-latest |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + python-version: ["3.10", "3.11", "3.12", "3.13"] |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Setup Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: ${{ matrix.python-version }} |
| 39 | + cache: pip |
| 40 | + |
| 41 | + - name: Install Rust |
| 42 | + uses: dtolnay/rust-toolchain@stable |
| 43 | + |
| 44 | + - name: Create venv |
| 45 | + run: python -m venv .venv |
| 46 | + |
| 47 | + - name: Install dependencies |
| 48 | + run: | |
| 49 | + source .venv/bin/activate |
| 50 | + python -m pip install --upgrade pip |
| 51 | + pip install maturin |
| 52 | + cd python && maturin develop --release |
| 53 | +
|
| 54 | + - name: Install dev dependencies |
| 55 | + run: source .venv/bin/activate && pip install pytest pytest-benchmark |
| 56 | + |
| 57 | + - name: Run Python tests |
| 58 | + run: source .venv/bin/activate && pytest tests/ -v -m "not benchmark" |
| 59 | + |
| 60 | + test-wasm: |
| 61 | + name: WASM tests |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Setup Rust |
| 67 | + uses: dtolnay/rust-toolchain@stable |
| 68 | + with: |
| 69 | + targets: wasm32-unknown-unknown |
| 70 | + |
| 71 | + - name: Install wasm-pack |
| 72 | + run: cargo install wasm-pack |
| 73 | + |
| 74 | + - name: Run WASM tests |
| 75 | + run: cd rust/badwords-wasm && wasm-pack test --node |
0 commit comments