netcorehost 0.13.1

A Rust library for hosting the .NET Core runtime.
Documentation
name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

env:
  CARGO_TERM_COLOR: always
  RUSTDOCFLAGS: "--deny warnings"
  RUSTFLAGS: "--deny warnings"
  RUST_TEST_THREADS: 1
  # COREHOST_TRACE: 2

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        toolchain: ["beta"]
        target: ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "i686-pc-windows-msvc", "x86_64-apple-darwin"]
        dotnet: ["5.0", "6.0", "7.0"]
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            dotnet_install_download_script: curl -sSL https://dot.net/v1/dotnet-install.sh > dotnet-install.sh; chmod +x dotnet-install.sh
            dotnet_install_script: ./dotnet-install.sh
            arch: x64
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            dotnet_install_download_script: Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1
            dotnet_install_script: ./dotnet-install.ps1
            arch: x64
          - target: i686-pc-windows-msvc
            os: windows-latest
            dotnet_install_download_script: Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1
            dotnet_install_script: ./dotnet-install.ps1
            arch: x86
          - target: x86_64-apple-darwin
            os: macos-latest
            dotnet_install_download_script: curl -sSL https://dot.net/v1/dotnet-install.sh > dotnet-install.sh; chmod +x dotnet-install.sh
            dotnet_install_script: ./dotnet-install.sh
            arch: x64
    env:
      NETCOREHOST_TEST_NETCORE_VERSION: net${{ matrix.dotnet }}
    steps:
    - uses: actions/checkout@v3

    - name: Install .NET SDK ${{ matrix.dotnet }}
      run: |

        ${{ matrix.dotnet_install_download_script }}
        ${{ matrix.dotnet_install_script }} -Architecture ${{ matrix.arch }} -Channel 5.0
        ${{ matrix.dotnet_install_script }} -Architecture ${{ matrix.arch }} -Channel 6.0
        ${{ matrix.dotnet_install_script }} -Architecture ${{ matrix.arch }} -Channel 7.0

        if ($Env:DOTNET_INSTALL_DIR) {
            $dotnetRoot = $Env:DOTNET_INSTALL_DIR
        } else {
            if ([System.Environment]::OSVersion.Platform -eq "Win32NT") {
                $dotnetRoot = [IO.Path]::Combine($Env:LOCALAPPDATA, "Microsoft", "dotnet")
            } else {
                $dotnetRoot = [IO.Path]::Combine($Env:HOME, ".dotnet")
            }
        }

        $dotnetRoot >> $env:GITHUB_PATH
        "DOTNET_ROOT=$dotnetRoot" >> $env:GITHUB_ENV
        
        dotnet --info
      shell: pwsh  

    - name: Check .NET Installation
      run: dotnet --info
        
    - name: Install latest ${{ matrix.toolchain }}
      uses: dtolnay/rust-toolchain@master
      with:
          target: ${{ matrix.target }}
          toolchain: ${{ matrix.toolchain }}
          override: true
      
    - name: Build
      run: cargo build --target ${{ matrix.target }}
      
    - name: Test
      run: cargo test --target ${{ matrix.target }} --all-targets --no-fail-fast
 
  cross:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        toolchain: ["beta"]
        target: ["aarch64-unknown-linux-gnu", "armv7-unknown-linux-gnueabihf", "aarch64-pc-windows-msvc"]
          
    steps:
    - uses: actions/checkout@v3

    - name: Install latest ${{ matrix.toolchain }}
      uses: dtolnay/rust-toolchain@master
      with:
          target: ${{ matrix.target }}
          toolchain: ${{ matrix.toolchain }}
          override: true
          
    - name: Install cross
      run: cargo install cross --git https://github.com/cross-rs/cross
          
    - name: Build
      run: cross build --target ${{ matrix.target }}
        
  examples:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Install latest beta
      uses: dtolnay/rust-toolchain@master
      with:
          toolchain: nightly
          override: true
    - name: Run example 'run-app'
      run: cargo run --example run-app
    - name: Run example 'call-managed-function'
      run: cargo run --example call-managed-function
    - name: Run example 'passing-parameters'
      run: cargo run --example passing-parameters

  documentation:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
          - os: windows-latest
    steps:
    - uses: actions/checkout@v3
    - name: Install latest nightly
      uses: dtolnay/rust-toolchain@master
      with:
          profile: minimal
          toolchain: nightly
          override: true
    - name: Generate documentation
      run: cargo doc --all-features
    - name: Install cargo-deadlinks
      run: cargo install cargo-deadlinks
    - name: Check dead links in doc
      run: cargo deadlinks

  clippy:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
          - os: windows-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install latest nightly
        uses: dtolnay/rust-toolchain@master
        with:
            toolchain: nightly
            components: clippy
            override: true
            
      - name: Clippy check
        run: cargo clippy --all-features
          
  fmt:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
          - os: windows-latest
    steps:
    - uses: actions/checkout@v3
    - name: Install latest nightly
      uses: dtolnay/rust-toolchain@master
      with:
          profile: minimal
          toolchain: nightly
          override: true
          components: rustfmt
          
    - name: Format check
      run: cargo fmt --all -- --check