name: Run tests

on:
  pull_request:
    types: [edited]
  push:
    branches:
      - main
      - master

jobs:
  run-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - uses: actions/setup-python@v3
        with:
          python-version: "3.13"
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: clippy, rustfmt
      - name: Install dependencies
        run: |
          cargo install cargo-semver-checks
      - name: Run tests
        run: cargo test
      - name: Check for security vulnerabilities
        run: |
          cargo install --locked --all-features --target x86_64-unknown-linux-gnu cargo-audit
          cargo audit
      - name: Run clippy
        run: cargo clippy --all-targets --all-features -- -D warnings
      - name: Run rustfmt
        run: cargo fmt -- --check
      - name: Run semver checks
        run: cargo semver-checks check-release
