tick-encoding 0.1.4

A simple encoding scheme to encode binary data into ASCII strings
Documentation
name: Tests

on:
  push:
    branches:
      - main
      - 'build/*'
  pull_request:
  workflow_call:

env:
  NIGHTLY_TOOLCHAIN: nightly-2026-01-05

jobs:
  check:
    name: Run checks
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
      - name: Check formatting
        run: cargo fmt -- --check
      - name: Check Clippy
        run: cargo clippy --all -- -Dwarnings
  test:
    strategy:
      matrix:
        toolchain:
          - "1.70.0"
          - stable
          - beta
        features:
          - "default"
          - "default safe"
          - "std"
          - "std safe"
          - "alloc"
          - "alloc safe"
          - "safe"
          - "none"
    name: Run tests (${{ matrix.toolchain }}, ${{ matrix.features }})
    runs-on: ubuntu-24.04
    env:
      TOOLCHAIN: ${{ matrix.toolchain }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
      - name: Install toolchain
        run: rustup toolchain install "$TOOLCHAIN"
      - name: Run tests
        run: |
          use_default_features=0
          feature_flags=()
          for feature in $FEATURES; do
            case "$feature" in
              "default" )
                use_default_features=1
                ;;
              "none" )
                ;;
              * )
                feature_flags+=(--features "$feature")
                ;;
            esac
          done

          if [ "$use_default_features" -eq 0 ]; then
            feature_flags+=(--no-default-features)
          fi

          cargo +"$TOOLCHAIN" test "${feature_flags[@]}"

        env:
          FEATURES: ${{ matrix.features }}
          PROPTEST_CASES: "10000"
  benchmark:
    strategy:
      matrix:
        include:
          - name: x86_64-linux
            runs-on: ubuntu-24.04
          - name: aarch64-linux
            runs-on: ubuntu-24.04-arm
    name: Run benchmarks [${{ matrix.name }}]
    runs-on: ${{ matrix.runs-on }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
      - name: Run benchmarks
        run: cargo bench
  miri:
    name: Run Miri tests
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
      - name: Install Rust nightly toolchain
        run: |
          rustup toolchain install "$NIGHTLY_TOOLCHAIN" \
            --component miri
      - name: Run tests with Miri
        run: cargo +"$NIGHTLY_TOOLCHAIN" miri test
        env:
          # Tweak proptest settings for Miri
          PROPTEST_CASES: "16"
          PROPTEST_DISABLE_FAILURE_PERSISTENCE: "true"
          MIRIFLAGS: "-Zmiri-env-forward=PROPTEST_DISABLE_FAILURE_PERSISTENCE -Zmiri-env-forward=PROPTEST_CASES"

  # Extra job that succeeds when all test jobs succeed (useful for PR requirements)
  tests-passed:
    name: All tests passed
    needs: [check, test, benchmark, miri]
    if: ${{ !cancelled() }}
    runs-on: ubuntu-24.04
    steps:
      - run: |
          test "$CHECK_RESULT" = 'success'
          test "$TEST_RESULT" = 'success'
          test "$BENCHMARK_RESULT" = 'success'
          test "$MIRI_RESULT" = 'success'
        env:
          CHECK_RESULT: ${{ needs.check.result }}
          TEST_RESULT: ${{ needs.test.result }}
          BENCHMARK_RESULT: ${{ needs.benchmark.result }}
          MIRI_RESULT: ${{ needs.miri.result }}