aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/coveralls.yaml
blob: f0326a43e1c5d9244714a4b728dc76e307b1a9d5 (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
name: Coveralls

on: [push, pull_request]

jobs:
  gen_coverage:
    name: Calculate test coverage
    runs-on: ubuntu-24.04

    env:
      # We use Rust Nightly, which builds upon LLVM 18. To ensure best
      # compatibility, we use a matching C++ compiler.
      CC: clang-18
      CXX: clang++-18
      # Enable test coverage.
      PROFILE: 1
      # These flags are necessary for grcov to correctly calculate coverage.
      CARGO_INCREMENTAL: 0
      # We add `-A warnings` because we aren't interested in warnings from Rust
      # Nightly -- GitHub turns them into annotations, which is annoying.
      RUSTFLAGS: '-A warnings -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort -Cinstrument-coverage'
      RUSTDOCFLAGS: '-Cpanic=abort'
      LLVM_PROFILE_FILE: 'your_name-%p-%m.profraw'
      # Some of our tests use ncurses, which require a terminal of some sort.
      # We pretend ours is a simple one.
      TERM: 'dumb'
      # This prevents our tests from hogging too much of the CPU and failing
      # due to races.
      RUST_TEST_THREADS: 2

    steps:
      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install --assume-yes --no-install-suggests clang-18 libsqlite3-dev libcurl4-openssl-dev libxml2-dev libstfl-dev libjson-c-dev libncursesw5-dev

      - name: Generate locales
        run: |
          sudo apt-get install --assume-yes locales
          echo 'en_US.UTF-8 UTF-8' | sudo tee --append /etc/locale.gen
          echo 'ru_RU.KOI8-R KOI8-R' | sudo tee --append /etc/locale.gen
          echo 'ru_RU.CP1251 CP1251' | sudo tee --append /etc/locale.gen
          sudo locale-gen

      - name: Install Rust
        uses: dtolnay/rust-toolchain@nightly
        with:
          components: llvm-tools-preview

      - uses: actions/checkout@v4

      - name: Cache ~/.cargo
        uses: actions/cache@v4
        id: cargo_cache
        with:
          key: cargo2-${{ hashFiles('Cargo.lock', '**/Cargo.toml') }}
          path: |
            ~/.cargo/bin
            ~/.cargo/git
            ~/.cargo/registry

      - name: Install grcov
        if: steps.cargo_cache.outputs.cache-hit != 'true'
        run: cargo install grcov

      - name: Run tests
        run: make --jobs=3 NEWSBOAT_RUN_IGNORED_TESTS=1 ci-check

      - name: Calculate test coverage
        run: grcov . --binary-path target/debug --ignore-not-existing --ignore='/*' --ignore='3rd-party/*' --ignore='doc/*' --ignore='test/*' --ignore='target/*' --ignore='newsboat.cpp' --ignore='podboat.cpp' -t lcov -o coverage.lcov

      - name: Submit coverage to Coveralls
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          path-to-lcov: coverage.lcov
          debug: true