Debian Codegraph @

.github/workflows/c-cpp.yml

raw
1 name: C/C++ CI
2
3 on:
4 push:
5 branches: [ master ]
6 pull_request:
7 branches: [ master ]
8
9 permissions:
10 contents: read
11
12 jobs:
13 build:
14 strategy:
15 fail-fast: false
16 matrix:
17 include:
18 - os: ubuntu-latest
19 configuration: Release
20 compiler: gcc
21 - os: ubuntu-latest
22 configuration: Debug
23 compiler: gcc
24 - os: ubuntu-latest
25 configuration: Release
26 compiler: clang
27 - os: ubuntu-latest
28 configuration: Debug
29 compiler: clang
30 - os: macos-latest
31 configuration: Release
32 compiler: clang
33 - os: macos-latest
34 configuration: Debug
35 compiler: clang
36 runs-on: ${{ matrix.os }}
37
38 steps:
39 - uses: actions/checkout@v6
40
41 - name: Install dependencies on Ubuntu
42 if: matrix.os == 'ubuntu-latest'
43 run: |
44 sudo apt-get update
45 sudo apt-get install -y autoconf automake autopoint gettext git libtool make texinfo
46 if [ "${{ matrix.compiler }}" == "gcc" ]; then sudo apt-get install -y g++; fi
47 if [ "${{ matrix.compiler }}" == "clang" ]; then sudo apt-get install -y clang; fi
48
49 - name: Install dependencies on macOS
50 if: matrix.os == 'macos-latest'
51 run: |
52 brew install autoconf automake gettext libtool texinfo
53 for package in gettext libtool texinfo; do
54 echo "$(brew --prefix "${package}")/bin" >> "${GITHUB_PATH}"
55 done
56 echo "ACLOCAL_PATH=$(brew --prefix gettext)/share/aclocal" >> "${GITHUB_ENV}"
57 echo "LIBTOOLIZE=glibtoolize" >> "${GITHUB_ENV}"
58 echo "CPPFLAGS=-I$(brew --prefix gettext)/include" >> "${GITHUB_ENV}"
59 echo "LDFLAGS=-L$(brew --prefix gettext)/lib" >> "${GITHUB_ENV}"
60
61 - name: Run autogen
62 run: ./autogen.sh
63
64 - name: Configure
65 run: |
66 if [ "${{ matrix.compiler }}" == "gcc" ]; then export CC=gcc CXX=g++; fi
67 if [ "${{ matrix.compiler }}" == "clang" ]; then export CC=clang CXX=clang++; fi
68 if [ "${{ matrix.configuration }}" == "Release" ]; then
69 export CFLAGS="-O2" CXXFLAGS="-O2";
70 else
71 export CFLAGS="-g -O0" CXXFLAGS="-g -O0";
72 fi
73 ./configure
74
75 - name: Build
76 run: make
77
78 - name: Run checks
79 run: make check
80
81 autotools:
82 needs: build
83 if: always()
84 runs-on: ubuntu-latest
85 permissions:
86 contents: read
87 statuses: write
88
89 steps:
90 - name: Report autotools result
91 uses: actions/github-script@v9
92 with:
93 script: |
94 const buildResult = '${{ needs.build.result }}';
95 const state = buildResult === 'success' ? 'success' : 'failure';
96 const description = state === 'success'
97 ? 'Autotools matrix successful'
98 : `Autotools matrix ${buildResult}`;
99
100 if (context.eventName === 'push' && context.ref === 'refs/heads/master') {
101 await github.rest.repos.createCommitStatus({
102 owner: context.repo.owner,
103 repo: context.repo.repo,
104 sha: context.sha,
105 state,
106 context: 'autotools',
107 description,
108 target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
109 });
110 }
111
112 if (state !== 'success') {
113 core.setFailed(description);
114 }