summaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: f9fe0a3695d08a193bd9a969596b099cdfb54820 (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
86
87
88
89
90
91
92
93
name: Bob the Builder

on: [push, pull_request]

env:
  # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
  MAKEFLAGS: -j3
  GCC_CFLAGS: "-Wall -Wextra -Wshadow -Wunused -Wpedantic -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op"
  CLANG_CFLAGS: "-Wall -Wextra -Wshadow -Wunused -Wpedantic"


jobs:
  build:
    strategy:
      matrix:
        name: [ ubuntu-latest-gcc, ubuntu-latest-clang, macos-latest-clang ]
        include:
          - name: ubuntu-latest-gcc
            os: ubuntu-latest
            cc: gcc
          - name: ubuntu-latest-clang
            os: ubuntu-latest
            cc: clang
          - name: macos-latest-clang
            os: macos-latest
            cc: clang

    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - name: Install MacOS dependencies
        if: startsWith(matrix.os,'macos')
        run: |
          brew update
          brew install automake tree doxygen
      - name: Install Linux dependencies
        if: startsWith(matrix.os,'ubuntu')
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential autoconf automake clang tree doxygen
      - name: Configure
        run: |
          ./autogen.sh
          ./configure --prefix=/usr CC=${{ matrix.cc }}
      - name: Build
        run: |
          make V=1
          make install-strip DESTDIR=/tmp
          tree /tmp/usr
  unit-tests:
    strategy:
      matrix:
        name: [ ubuntu-latest-gcc, ubuntu-latest-clang, macos-latest-clang ]
        include:
          - name: ubuntu-latest-gcc
            os: ubuntu-latest
            cc: gcc
          - name: ubuntu-latest-clang
            os: ubuntu-latest
            cc: clang
          - name: macos-latest-clang
            os: macos-latest
            cc: clang

    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - name: Install MacOS dependencies
        if: startsWith(matrix.os,'macos')
        run: |
          brew update
          brew install automake tree doxygen cmocka
      - name: Install Linux dependencies
        if: startsWith(matrix.os,'ubuntu')
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential autoconf automake tree doxygen libcmocka-dev
      - name: Configure
        run: |
          if ${{ matrix.cc == 'gcc' }}; then
              ./autogen.sh
              ./configure --prefix=/usr CC=${{ matrix.cc }} CFLAGS="${GCC_CFLAGS}" --enable-tests
          else
              ./autogen.sh
              ./configure --prefix=/usr CC=${{ matrix.cc }} CFLAGS="${CLANG_CFLAGS}" --enable-tests
          fi
      - name: Build
        run: |
          make V=1
      - name: Run Unit-Test
        run: |
          sudo ./tests/libnet_unit_tests
          ./tests/libnet_udld_unit_tests