• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: linux
2
3on: [push, pull_request]
4
5permissions:
6  contents: read
7
8jobs:
9  build:
10    runs-on: ubuntu-20.04
11    strategy:
12      matrix:
13        cxx: [g++-4.9, g++-10, clang++-9]
14        build_type: [Debug, Release]
15        std: [11]
16        shared: [""]
17        include:
18          - cxx: g++-4.9
19            install: sudo apt install g++-4.9
20          - cxx: g++-8
21            build_type: Debug
22            std: 14
23            install: sudo apt install g++-8
24          - cxx: g++-8
25            build_type: Debug
26            std: 17
27            install: sudo apt install g++-8
28          - cxx: g++-9
29            build_type: Debug
30            std: 17
31          - cxx: g++-10
32            build_type: Debug
33            std: 17
34          - cxx: g++-11
35            build_type: Debug
36            std: 20
37            install: sudo apt install g++-11
38          - cxx: clang++-8
39            build_type: Debug
40            std: 17
41            cxxflags: -stdlib=libc++
42            install: sudo apt install clang-8 libc++-8-dev libc++abi-8-dev
43          - cxx: clang++-9
44            install: sudo apt install clang-9
45          - cxx: clang++-9
46            build_type: Debug
47            fuzz: -DFMT_FUZZ=ON -DFMT_FUZZ_LINKMAIN=ON
48            std: 17
49            install: sudo apt install clang-9
50          - cxx: clang++-11
51            build_type: Debug
52            std: 20
53          - cxx: clang++-11
54            build_type: Debug
55            std: 20
56            cxxflags: -stdlib=libc++
57            install: sudo apt install libc++-11-dev libc++abi-11-dev
58          - cxx: g++-13
59            build_type: Release
60            std: 23
61            install: sudo apt install g++-13
62            shared: -DBUILD_SHARED_LIBS=ON
63
64    steps:
65    - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
66
67    - name: Set timezone
68      run: sudo timedatectl set-timezone 'Asia/Yekaterinburg'
69
70    - name: Add repositories for older GCC
71      run: |
72        # Below repo provides GCC 4.9.
73        sudo apt-add-repository 'deb http://dk.archive.ubuntu.com/ubuntu/ xenial main'
74        sudo apt-add-repository 'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe'
75      if: ${{ matrix.cxx == 'g++-4.9' }}
76
77    - name: Add repositories for newer GCC
78      run: |
79        sudo apt-add-repository ppa:ubuntu-toolchain-r/test
80      if: ${{ matrix.cxx == 'g++-11' || matrix.cxx == 'g++-13' }}
81
82    - name: Add Ubuntu mirrors
83      run: |
84        # Github Actions caching proxy is at times unreliable
85        # see https://github.com/actions/runner-images/issues/7048
86        printf 'http://azure.archive.ubuntu.com/ubuntu\tpriority:1\n' | sudo tee /etc/apt/mirrors.txt
87        curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt
88        sudo sed -i 's~http://azure.archive.ubuntu.com/ubuntu/~mirror+file:/etc/apt/mirrors.txt~' /etc/apt/sources.list
89
90    - name: Create Build Environment
91      run: |
92        sudo apt update
93        ${{matrix.install}}
94        sudo apt install locales-all
95        cmake -E make_directory ${{runner.workspace}}/build
96
97    - name: Configure
98      working-directory: ${{runner.workspace}}/build
99      env:
100        CXX: ${{matrix.cxx}}
101        CXXFLAGS: ${{matrix.cxxflags}}
102      run: |
103        cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.fuzz}} ${{matrix.shared}} \
104              -DCMAKE_CXX_STANDARD=${{matrix.std}} -DFMT_DOC=OFF \
105              -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
106              -DFMT_PEDANTIC=ON -DFMT_WERROR=ON $GITHUB_WORKSPACE
107
108    - name: Build
109      working-directory: ${{runner.workspace}}/build
110      run: |
111        threads=`nproc`
112        cmake --build . --config ${{matrix.build_type}} --parallel $threads
113
114    - name: Test
115      working-directory: ${{runner.workspace}}/build
116      run: ctest -C ${{matrix.build_type}}
117      env:
118        CTEST_OUTPUT_ON_FAILURE: True
119