File size: 1,898 Bytes
ee56c4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Rust

on:
  pull_request:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
    defaults:
      run:
        working-directory: ./safetensors

    steps:
      - uses: actions/checkout@v3

      - name: Install Rust Stable
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          components: rustfmt, clippy, llvm-tools-preview
          override: true

      - uses: Swatinem/rust-cache@v2

      - name: Install cargo-llvm-cov for Ubuntu
        if: matrix.os == 'ubuntu-latest'
        run: cargo install cargo-llvm-cov

      - name: Install cargo-readme for Ubuntu
        if: matrix.os == 'ubuntu-latest'
        run: cargo install cargo-readme

      - name: Build
        run: cargo build --all-targets --verbose

      - name: Lint with Clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Run Tests
        run: cargo test --verbose

      - name: Run Audit
        # RUSTSEC-2021-0145 is criterion so only within benchmarks
        run: cargo audit -D warnings --ignore RUSTSEC-2021-0145

      - name: Coverage report
        if: matrix.os == 'ubuntu-latest'
        run: cargo llvm-cov --release --lcov --output-path lcov.info

      - name: Upload to codecov.io
        if: matrix.os == 'ubuntu-latest'
        uses: codecov/codecov-action@v3
        with:
          token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
          working-directory: ./safetensors
          fail_ci_if_error: true

      # Verify that Readme.md is up to date.
      - name: Make sure, Readme generated from lib.rs matches actual Readme
        if: matrix.os == 'ubuntu-latest'
        shell: bash
        run: cargo readme > must_match_readme.md && diff must_match_readme.md README.md && diff must_match_readme.md ../README.md