summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build.yml
blob: a2500415266dd0dc2c616cfe538ed86d131d7131 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: build

on: [push, pull_request]

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-22.04, macos-11]
        compiler: [gcc, clang]
        buildtool: [autotools, distcheck, cmake]
        exclude:
        - os: macos-11
          buildtool: distcheck
        - compiler: gcc
          buildtool: distcheck

    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v3
    - name: Linux setup
      if: runner.os == 'Linux'
      run: |
        sudo apt-get install \
          g++-12 \
          clang-14 \
          autoconf \
          automake \
          autotools-dev \
          libtool \
          pkg-config \
          libcunit1-dev \
          cmake \
          cmake-data
    - name: MacOS setup
      if: runner.os == 'macOS'
      run: |
        brew install cunit autoconf automake pkg-config libtool
    - name: Setup clang (Linux)
      if: runner.os == 'Linux' && matrix.compiler == 'clang'
      run: |
        echo 'CC=clang-14' >> $GITHUB_ENV
        echo 'CXX=clang++-14' >> $GITHUB_ENV
    - name: Setup clang (MacOS)
      if: runner.os == 'macOS' && matrix.compiler == 'clang'
      run: |
        echo 'CC=clang' >> $GITHUB_ENV
        echo 'CXX=clang++' >> $GITHUB_ENV
    - name: Setup gcc (Linux)
      if: runner.os == 'Linux' && matrix.compiler == 'gcc'
      run: |
        echo 'CC=gcc-12' >> $GITHUB_ENV
        echo 'CXX=g++-12' >> $GITHUB_ENV
    - name: Setup gcc (MacOS)
      if: runner.os == 'macOS' && matrix.compiler == 'gcc'
      run: |
        echo 'CC=gcc' >> $GITHUB_ENV
        echo 'CXX=g++' >> $GITHUB_ENV
    - name: Configure autotools
      if: matrix.buildtool == 'autotools'
      run: |
        autoreconf -i && ./configure --enable-werror
    - name: Configure distcheck
      if: matrix.buildtool == 'distcheck'
      run: |
        autoreconf -i && ./configure
    - name: Configure cmake
      if: matrix.buildtool == 'cmake'
      run: |
        autoreconf -i && ./configure
        make dist

        VERSION=$(grep PACKAGE_VERSION config.h | cut -d' ' -f3 | tr -d '"')
        tar xf nghttp3-$VERSION.tar.gz
        cd nghttp3-$VERSION
        mkdir build
        cd build

        echo 'NGHTTP3_BUILD_DIR='"$PWD" >> $GITHUB_ENV

        cmake $CMAKE_OPTS ..
    - name: Build nghttp3
      if: matrix.buildtool != 'distcheck'
      run: |
        [ -n "$NGHTTP3_BUILD_DIR" ] && cd "$NGHTTP3_BUILD_DIR"
        make
        make check
    - name: Build nghttp3 with distcheck
      if: matrix.buildtool == 'distcheck'
      run: |
        make distcheck

  build-cross:
    strategy:
      matrix:
        host: [x86_64-w64-mingw32, i686-w64-mingw32]

    runs-on: ubuntu-22.04

    env:
      HOST: ${{ matrix.host }}

    steps:
    - uses: actions/checkout@v3
    - name: Linux setup
      run: |
        sudo dpkg --add-architecture i386
        sudo apt-get update
        sudo apt-get install \
          gcc-mingw-w64 \
          autoconf \
          automake \
          autotools-dev \
          libtool \
          pkg-config \
          wine
    - name: Build CUnit
      run: |
        curl -LO https://jaist.dl.sourceforge.net/project/cunit/CUnit/2.1-3/CUnit-2.1-3.tar.bz2
        tar xf CUnit-2.1-3.tar.bz2
        cd CUnit-2.1-3
        ./bootstrap
        ./configure --disable-shared --host="$HOST" --prefix="$PWD/build"
        make -j$(nproc) install
    - name: Configure autotools
      run: |
        autoreconf -i && \
        ./configure --enable-werror --enable-lib-only --with-cunit \
          --host="$HOST" PKG_CONFIG_PATH="$PWD/CUnit-2.1-3/build/lib/pkgconfig"
    - name: Build nghttp3
      run: |
        make -j$(nproc)
        make -j$(nproc) check TESTS=""
    - name: Run tests
      if: matrix.host == 'x86_64-w64-mingw32'
      run: |
        cd tests
        wine main.exe

  build-windows:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v3
    - name: Configure cmake
      run: |
        mkdir build
        cd build
        cmake -DENABLE_LIB_ONLY=ON ..
    - name: Build nghttp3
      run: |
        cmake --build build