subtile 0.4.1

A crate of utils to operate traitements on subtitles
Documentation
name: CI - Code Checks & Tests

on:
  push:
    branches-ignore:
      - "wip*"
    paths:
      - ".github/workflows/code_check.yml"
      - "Cargo.*"
      - "src/**"
  pull_request:
    paths:
      - ".github/workflows/code_check.yml"
      - "Cargo.*"
      - "src/**"

concurrency:
  # For a given workflow, if we push to the same branch, cancel all previous builds on that branch.
  # Particularly useful for workflow triggered on release-plz sync.
  # release-plz workflow update de pending pr twice (with cargo readme update)
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -D warnings
  RUSTDOCFLAGS: -D warnings

jobs:
  ci_code_checks_and_tests:
    runs-on: ubuntu-latest
    name: Code Checks and Tests
    steps:
      - name: "Install rust-toolchain stable"
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt

      - name: "Show environment"
        run: |
          rustc -vV
          cargo -vV

      - name: "Checkout"
        uses: actions/checkout@v4

      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true # useful for don't rebuild cargo-readme and dependencies on fix after failure

      - name: Install cargo-readme
        run: cargo install cargo-readme --locked

      - name: Check spelling of entire workspace
        id: typos_check
        if: $${{ always() }}
        uses: crate-ci/typos@master

      - name: "Cargo formatting"
        id: cargo_fmt
        if: $${{ always() }}
        run: |
          cargo fmt --all -- --check

      - name: "Cargo.toml format"
        id: toml_fmt
        if: $${{ always() }}
        uses: gwen-lg/taplo-action@v1
        with:
          format: true
          lint: false

      - name: "Cargo.toml lint"
        id: toml_lint
        if: $${{ always() }}
        uses: gwen-lg/taplo-action@v1
        with:
          format: false
          lint: true

      - name: Check if readme is up to date
        id: cargo_readme
        if: $${{ always() }}
        run: diff README.md <(cargo readme)

      - name: "Cargo doc"
        id: cargo_doc
        env:
          RUSTDOCFLAGS: "-D warnings"
        if: $${{ always() }}
        run: cargo doc --locked

      - name: "Cargo clippy"
        id: cargo_clippy
        if: $${{ always() }}
        run: cargo clippy --profile=test --locked

      - name: "Cargo test"
        id: cargo_test
        if: $${{ always() }}
        run: cargo test --locked

      - name: "Some checks failed"
        if: ${{ failure() }}
        run: |
          echo "### :x: Checks Failed!" >> $GITHUB_STEP_SUMMARY
          echo "" >> $GITHUB_STEP_SUMMARY
          echo "|Job|Status|" >> $GITHUB_STEP_SUMMARY
          echo "|---|------|" >> $GITHUB_STEP_SUMMARY
          echo "|typos|${{ steps.typos_check.outcome}}|" >> $GITHUB_STEP_SUMMARY
          echo "|Cargo fmt|${{ steps.cargo_fmt.outcome }}|" >> $GITHUB_STEP_SUMMARY
          echo "|Taplo fmt|${{ steps.toml_fmt.outcome }}|" >> $GITHUB_STEP_SUMMARY
          echo "|Taplo lint|${{ steps.toml_lint.outcome }}|" >> $GITHUB_STEP_SUMMARY
          echo "|Cargo readme|${{ steps.cargo_readme.outcome }}|" >> $GITHUB_STEP_SUMMARY
          echo "|Cargo doc|${{ steps.cargo_doc.outcome }}|" >> $GITHUB_STEP_SUMMARY
          echo "|Cargo clippy|${{ steps.cargo_clippy.outcome }}|" >> $GITHUB_STEP_SUMMARY
          echo "|Cargo test|${{ steps.cargo_test.outcome }}|" >> $GITHUB_STEP_SUMMARY
          echo "" >> $GITHUB_STEP_SUMMARY
          echo "Please check the failed jobs and fix where needed." >> $GITHUB_STEP_SUMMARY
          echo "" >> $GITHUB_STEP_SUMMARY
          exit 1

      - name: "All checks passed"
        if: ${{ success() }}
        run: |
          echo "### :white_check_mark: Checks Passed!" >> $GITHUB_STEP_SUMMARY
          echo "" >> $GITHUB_STEP_SUMMARY