esplugin 6.1.4

A free software library for reading Elder Scrolls plugin (.esp/.esm/.esl) files.
Documentation
name: CI

on: [push, pull_request]

env:
  CARGO_TERM_COLOR: always
  TESTING_PLUGINS_VERSION: "1.6.2"

jobs:
  rustfmt:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v4

      - name: Check formatting
        run: |
          cargo fmt -- --version
          cargo fmt --all -- --check

  clippy:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v4

      - name: Prepare test resources
        shell: bash
        run: |
          curl -sSfLO "https://github.com/Ortham/testing-plugins/archive/${{ env.TESTING_PLUGINS_VERSION }}.zip"
          7z x "${{ env.TESTING_PLUGINS_VERSION }}.zip"
          mv "testing-plugins-${{ env.TESTING_PLUGINS_VERSION }}" testing-plugins

      - name: Run clippy
        run: |
          cargo clippy -- --version
          cargo clippy --workspace --all-targets -- -Dwarnings

  cargo-vet:
    runs-on: ubuntu-24.04

    env:
      CARGO_VET_VERSION: 0.10.1

    steps:
    - uses: actions/checkout@v4

    - uses: actions/cache@v4
      with:
        path: ${{ runner.tool_cache }}/cargo-vet
        key: cargo-vet-bin-${{ env.CARGO_VET_VERSION }}

    - name: Add the tool cache directory to the search path
      run: echo "${{ runner.tool_cache }}/cargo-vet/bin" >> $GITHUB_PATH

    - name: Ensure that the tool cache is populated with the cargo-vet binary
      run: cargo install --root ${{ runner.tool_cache }}/cargo-vet --version ${{ env.CARGO_VET_VERSION }} cargo-vet

    - name: Invoke cargo-vet
      run: cargo vet --locked

  build:
    strategy:
      matrix:
        os:
          - windows-2025
          - ubuntu-24.04

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4

      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

      - name: Install cbindgen
        run: cargo install --force cbindgen --version 0.27.0

      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov

      - name: Prepare test resources
        shell: bash
        run: |
          curl -sSfLO "https://github.com/Ortham/testing-plugins/archive/${{ env.TESTING_PLUGINS_VERSION }}.zip"
          7z x "${{ env.TESTING_PLUGINS_VERSION }}.zip"
          mv "testing-plugins-${{ env.TESTING_PLUGINS_VERSION }}" testing-plugins

      - name: Build and run tests with code coverage
        run: cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info

      - name: Upload code coverage to Coveralls
        uses: coverallsapp/github-action@v2
        continue-on-error: true

      # Need to rebuild the FFI wrapper so that its binary is given a filename
      # without a hash.
      - name: Build FFI wrapper
        shell: bash
        run: |
          cargo build --manifest-path ffi/Cargo.toml
          cbindgen ffi/ -o ffi/include/esplugin.h

      - name: Build and run C++ tests
        shell: bash
        run: |
          cmake -B ffi/build ffi
          cmake --build ffi/build
          ctest --test-dir ffi/build --output-on-failure