summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: 73f5327dd28f200e3a4d56db90fb004152b9542f (plain)
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
78
79
80
81
82
83
84
85
name: Continuous Integration

on:
  push:
    branches:
      - master
      - staging # for bors
      - trying # for bors
  pull_request:
    branches:
      - master
  schedule:
    - cron: "0 0 * * 0"

jobs:
  build:
    name: Build for ${{ matrix.TARGET }} using Rust ${{ matrix.TOOLCHAIN }} (on ${{ matrix.OS }})
    runs-on: ${{ matrix.OS }}
    strategy:
      fail-fast: false
      matrix:
        OS: [ ubuntu-22.04 ]
        TOOLCHAIN: [ stable, nightly ]
        TARGET:
          - x86_64-unknown-linux-gnu
          - x86_64-unknown-linux-musl

    steps:
      - name: Checkout the repository
        uses: actions/checkout@master

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install --allow-unauthenticated -y -qq \
            libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev musl-tools

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.TOOLCHAIN }}
          target: ${{ matrix.TARGET }}
          override: true
          components: rustfmt, clippy

      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --target ${{ matrix.TARGET }}

      - name: Check formatting
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

      - name: Check lints
        if: matrix.TOOLCHAIN == 'stable'
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: -- -D warnings

      - name: Setup cargo-tarpaulin
        if: matrix.TARGET == 'x86_64-unknown-linux-gnu'
        run: |
          curl -s https://api.github.com/repos/xd009642/tarpaulin/releases/latest | \
            grep "browser_download_url.*x86_64-unknown-linux-musl.tar.gz" | cut -d : -f 2,3 | tr -d \" | wget -qi -
          tar -xzf cargo-tarpaulin-*.tar.gz
          mv cargo-tarpaulin ~/.cargo/bin/

      - name: Run tests
        if: matrix.TARGET == 'x86_64-unknown-linux-gnu'
        run: cargo tarpaulin --out Xml --verbose --target ${{ matrix.TARGET }}

      - name: Upload reports to codecov.io
        if: github.event_name != 'pull_request' && matrix.TOOLCHAIN == 'stable' && matrix.TARGET == 'x86_64-unknown-linux-gnu'
        uses: codecov/codecov-action@v4.0.1
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          file: cobertura.xml
          flags: unittests
          name: code-coverage-report
          fail_ci_if_error: true