xref: /libCEED/.github/workflows/rust-test-with-style.yml (revision 68ebe796ba3a20e3a46fc8d1f708ffe4751e188e)
1name: Rust
2
3on:
4  push:
5    branches:
6      - main
7  pull_request:
8
9jobs:
10  test:
11    strategy:
12      matrix:
13        os: [ubuntu-24.04]
14        compiler: [clang]
15
16    runs-on: ${{ matrix.os }}
17
18    steps:
19    - name: Environment setup
20      uses: actions/checkout@v4
21    - name: Rust setup
22      uses: dtolnay/rust-toolchain@master
23      with:
24        # Note: nightly required for coverage of Doctests
25        toolchain: nightly
26        components: llvm-tools-preview
27    - name: Install cargo-llvm-cov
28      uses: taiki-e/install-action@v2
29      with:
30        tool: cargo-llvm-cov
31    - name: Rust test with coverage
32      env:
33        CC: ${{ matrix.compiler }}
34        FC: gfortran-11
35      run: cargo llvm-cov test --doctests --lcov --output-path lcov.info
36    - name: Codecov upload
37      uses: codecov/codecov-action@v4
38      with:
39        files: lcov.info
40        token: ${{secrets.CODECOV_TOKEN}}
41
42  style:
43    strategy:
44      matrix:
45        os: [ubuntu-24.04]
46        compiler: [clang]
47
48    runs-on: ${{ matrix.os }}
49
50    steps:
51    - name: Environment setup
52      uses: actions/checkout@v4
53    - name: Rust setup
54      uses: dtolnay/rust-toolchain@master
55      with:
56        # Note: rustfmt not always included in nightly, will attempt to downgrade until rustfmt found
57        toolchain: nightly
58        components: rustfmt
59    - name: Rust style
60      run: |
61        cargo +nightly fmt --version
62        cargo +nightly fmt -- --check
63