nucs 0.3.1

Library for working with nucleotide and amino acid sequences
Documentation
name: CI

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  CARGO_TERM_COLOR: always

jobs:

  setup:
    name: Setup
    timeout-minutes: 5
    runs-on: ubuntu-latest
    outputs:
      rust-versions: ${{ steps.determine-rust-versions.outputs.rust-versions }}
    steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@stable
    - name: Check crate version matches RELEASES.md
      run: |
        CRATE_VERSION=$(cargo read-manifest | jq -r .version)
        RELEASES_VERSION=$(grep -oPm1 '(?<=^## Version )\S+' RELEASES.md)
        echo crate=$CRATE_VERSION releases=$RELEASES_VERSION
        test "$CRATE_VERSION" = "$RELEASES_VERSION"
    - name: Determine supported rust versions
      id: determine-rust-versions
      run: |
        # Produce JSON list of supported versions, e.g. ["1.88","1.89","1.90"]
        # Rust should always be 1.X; find the minor version component of...
        REQUIRED_VERSION=$(cargo read-manifest | jq -r '.rust_version | split(".")[1]')
        TOOLCHAIN_VERSION=$(rustc --version | grep -oP '(?<=^rustc 1\.)\d+')
        VERSION_RANGE='["1.'$(seq -s'","1.' "$REQUIRED_VERSION" "$TOOLCHAIN_VERSION")'"]'
        echo "Supported rust versions: $VERSION_RANGE"
        echo "rust-versions=$VERSION_RANGE" >> $GITHUB_OUTPUT

  tests:
    name: Tests
    needs: setup
    timeout-minutes: 5
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust_version: ${{fromJson(needs.setup.outputs.rust-versions)}}
        features: [ "default", "proptest", "rand", "serde", "unsafe", "all" ]
    env:
      RUSTDOCFLAGS: -Dwarnings
      # Our tests are pretty fast with release, so might as well crank up the number of proptests
      PROPTEST_CASES: 1000000
    steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@master
      with:
        toolchain: ${{matrix.rust_version}}
        components: clippy,rustfmt
    - name: Check formatting
      run: cargo fmt --check --all
    - name: Clippy # ensure nothing depends on test-only code
      run: cargo clippy --features "${{matrix.features}}" --benches -- --deny warnings
    - name: Clippy (with tests) # find code-smells in tests
      run: cargo clippy --features "${{matrix.features}}" --tests -- --deny warnings
    - name: Run tests
      run: cargo test --release --features ${{matrix.features}}
    - name: Cargo doc
      run: cargo doc --features "${{matrix.features}}"
    - name: Repo is clean # mainly prevents forgetting to commit Cargo.lock
      run: |
        if [ -n "$(git status --porcelain)" ]; then
            echo Dirty files:
            git -c color.status=always status --short
            exit 1
        fi

  nightly:
    name: docs.rs and Miri
    timeout-minutes: 5
    runs-on: ubuntu-latest
    env:
      RUSTDOCFLAGS: -Dwarnings
      # Disable isolation so proptest doesn't always run through the same few cases
      MIRIFLAGS: -Zmiri-strict-provenance -Zmiri-symbolic-alignment-check -Zrandomize-layout -Zmiri-disable-isolation
      # Miri is slow, so do fewer tries.
      PROPTEST_CASES: 32
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: miri
      - uses: dtolnay/install@cargo-docs-rs
      - name: Check docs.rs build
        run: cargo docs-rs
      - name: Setup Miri
        run: cargo miri setup
      - name: Run Miri
        run: cargo miri test --features all

  # Provide a single check for branch protection rules to rely on
  # (needed due to the tests matrix)
  ci-passed:
    name: Everything passed
    timeout-minutes: 5
    runs-on: ubuntu-latest
    needs: [ tests, nightly ]
    steps:
        - run: echo "CI passed!"