gomez 0.5.1

Framework and implementation for mathematical optimization and solving non-linear systems of equations.
Documentation
name: CI

on:
  push:
    branches: [ main ]
  pull_request:

jobs:
  commits-lint:
    name: Conventional commits
    runs-on: ubuntu-latest
    env:
      COMMITLINT_CONFIG: commitlint.config.js
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      # Only the latest commit only by default
      - name: Get commit range
        run: |
          echo "COMMIT_RANGE_FROM=${{ github.sha }}^" >> $GITHUB_ENV
          echo "COMMIT_RANGE_TO=${{ github.sha }}" >> $GITHUB_ENV

      - name: Update commit range
        if: github.event_name == 'pull_request'
        run: |
          echo "COMMIT_RANGE_FROM=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
          echo "COMMIT_RANGE_TO=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV

      - name: Update commit range
        if: github.event_name == 'push' && !github.event.forced
        run: |
          echo "COMMIT_RANGE_FROM=${{ github.event.before }}" >> $GITHUB_ENV

      - name: Lint conventional commits
        run: |
          npm install -g @commitlint/cli @commitlint/config-conventional
          echo "Linting range ${{ env.COMMIT_RANGE_FROM }}..${{ env.COMMIT_RANGE_TO }}"
          commitlint --config ${{ env.COMMITLINT_CONFIG }} --from ${{ env.COMMIT_RANGE_FROM }} --to ${{ env.COMMIT_RANGE_TO }}

  rust-format:
    name: Rust format
    runs-on: ubuntu-latest
    container: rust:latest
    steps:
      - uses: actions/checkout@v3

      - name: Check Rust code formatting
        run: |
          rustup component add rustfmt
          cargo fmt --all -- --check

  rust-lint:
    name: Rust lint
    runs-on: ubuntu-latest
    container: rust:latest
    steps:
      - uses: actions/checkout@v3

      - name: Install GSL
        run: apt-get update && apt-get install -y clang libgsl-dev

      - name: Lint Rust code
        run: |
          rustup component add clippy
          cargo clippy -- -D warnings
          cargo clippy --tests -- -D warnings

  rust-test:
    name: Rust test
    runs-on: ubuntu-latest
    container: ${{ matrix.container }}
    continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }}
    needs: [rust-format, rust-lint]
    strategy:
      matrix:
        rust-toolchain:
          - stable
          - nightly
        profile:
          - dev
          - release
        include:
          - rust-toolchain: stable
            container: rust:latest
          - rust-toolchain: nightly
            container: rustlang/rust:nightly
    steps:
      - uses: actions/checkout@v3

      - name: Install GSL
        run: apt-get update && apt-get install -y clang libgsl-dev

      - name: Log environment details
        run: |
          rustc --version
          cargo --version

      - name: Compile
        run: cargo build --profile ${{ matrix.profile }} --verbose

      - name: Run tests
        run: cargo test --profile ${{ matrix.profile }}

      - name: Compile (gsl-wrapper)
        working-directory: gsl-wrapper
        run: cargo build --profile ${{ matrix.profile }} --verbose

      - name: Run tests (gsl-wrapper)
        working-directory: gsl-wrapper
        run: cargo test --profile ${{ matrix.profile }}

      - name: Run checks (benches)
        working-directory: gomez-bench
        run: cargo check --profile ${{ matrix.profile }}

  rust-check-docs:
    name: Rust docs check
    runs-on: ubuntu-latest
    container: rust:latest
    needs: [rust-format, rust-lint]
    env:
      RUSTDOCFLAGS: -D warnings
    steps:
      - uses: actions/checkout@v3

      - name: Check Rust docs
        run: cargo doc --no-deps --document-private-items --workspace