Skip to content

Commit

Permalink
feature/add presets for more clang compilers (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-wind authored Mar 8, 2024
1 parent 54f55c2 commit ac11afd
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 38 deletions.
3 changes: 2 additions & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
builtin = clear,rare,en-GB_to_en-US,names,informal,code
check-filenames =
check-hidden =
skip = */.git,*/build,*/prefix,*/.vscode,*/.sonar
skip = */.git,*/build,*/prefix,*/.vscode,*/.sonar,*/llvm
quiet-level = 2
ignore-words-list = deque,dur,lightyears
75 changes: 59 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ on:
workflow_dispatch:

env:
VCPKG_COMMIT: "6f7ffeb18f99796233b958aaaf14ec7bd4fb64b2"
VCPKG_COMMIT: "c8696863d371ab7f46e213d8f5ca923c4aef2a00"

jobs:
version_bump:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -34,33 +34,41 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with: { python-version: "3.8" }

- name: Install codespell
run: pip3 install codespell

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "17.0"

- name: Fix clang-format
run: |
cp ./llvm/bin/clang-format ./llvm/bin/clang-format-17
- name: Lint
run: cmake -D FORMAT_COMMAND=clang-format-14 -P cmake/lint.cmake
run: cmake -D FORMAT_COMMAND=clang-format-17 -P cmake/lint.cmake

- name: Spell check
if: always()
run: cmake -P cmake/spell.cmake

sonarcloud:
if: false # See https://github.com/twig-energy/stronk/issues/37
needs: [lint]
runs-on: ubuntu-22.04
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v1
uses: SonarSource/sonarcloud-github-c-cpp@v2

- name: Install vcpkg
uses: friendlyanon/setup-vcpkg@v1
Expand Down Expand Up @@ -93,12 +101,17 @@ jobs:
if: github.repository_owner == 'twig-energy'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install LCov
run: sudo apt-get update -q
&& sudo apt-get install lcov -q -y

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "17.0"

- name: Install vcpkg
uses: friendlyanon/setup-vcpkg@v1
with:
Expand All @@ -108,7 +121,7 @@ jobs:
}

- name: Configure
env: { CXX: clang++-14 }
env: { CXX: clang++-17 }
run: cmake --preset=ci-coverage

- name: Build
Expand All @@ -122,7 +135,7 @@ jobs:
run: cmake --build build/coverage -t coverage

- name: Submit to codecov.io
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
file: build/coverage/coverage.info

Expand All @@ -132,7 +145,16 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "17.0"

- name: Fix clang++
run: |
cp ./llvm/bin/clang++ ./llvm/bin/clang++-17
- name: Install vcpkg
uses: friendlyanon/setup-vcpkg@v1
Expand All @@ -143,7 +165,7 @@ jobs:
}

- name: Configure
env: { CXX: clang++-14 }
env: { CXX: clang++-17 }
run: cmake --preset=ci-sanitize

- name: Build
Expand All @@ -166,12 +188,16 @@ jobs:
strategy:
matrix:
os: [macos-12, ubuntu-22.04, windows-2022]
compiler: [gcc-11, clang-13, clang-14, msvc]
compiler: [gcc-11, clang-13, clang-14, clang-15, clang-17, msvc]
exclude:
- os: windows-2022
compiler: clang-13
- os: windows-2022
compiler: clang-14
- os: windows-2022
compiler: clang-15
- os: windows-2022
compiler: clang-17
- os: windows-2022
compiler: gcc-11
- os: ubuntu-22.04
Expand All @@ -182,15 +208,32 @@ jobs:
compiler: clang-13
- os: macos-12
compiler: clang-14
- os: macos-12
compiler: clang-15
- os: macos-12
compiler: clang-17

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

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install static analyzers
if: matrix.os == 'ubuntu-22.04'
run: sudo apt-get install clang-tidy-14 cppcheck -y -q
run: sudo apt-get install cppcheck -y -q

- name: Install LLVM and Clang
if: matrix.os == 'ubuntu-22.04'
uses: KyleMayes/install-llvm-action@v1
with:
version: "17.0"

- name: Fix clang installations
if: matrix.os == 'ubuntu-22.04'
run: |
cp ./llvm/bin/clang++ ./llvm/bin/clang++-17
cp ./llvm/bin/clang-format ./llvm/bin/clang-format-17
cp ./llvm/bin/clang-tidy ./llvm/bin/clang-tidy-17
- name: Install vcpkg
uses: friendlyanon/setup-vcpkg@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
schedule:
- cron: "44 8 * * 1"
env:
VCPKG_COMMIT: "6f7ffeb18f99796233b958aaaf14ec7bd4fb64b2"
VCPKG_COMMIT: "c8696863d371ab7f46e213d8f5ca923c4aef2a00"

jobs:
analyze:
Expand All @@ -40,7 +40,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update_readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
auto-update-readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Update Readme
run: python tools/embed_code.py -i --file ./README.md

- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Updated README.md
11 changes: 8 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"clang-format.executable": "clang-format-14",
"clangd.path": "clangd-17",
"clang-format.executable": "clang-format-17",
"cpplint.filters": [
"-build/c++11",
"-build/include_order",
Expand Down Expand Up @@ -108,5 +109,9 @@
"structs",
"VCPKG"
],
"sonarlint.pathToCompileCommands": "${workspaceFolder}/build/dev/compile_commands.json"
}
"sonarlint.pathToCompileCommands": "${workspaceFolder}/build/dev/compile_commands.json",
"sonarlint.connectedMode.project": {
"connectionId": "twig-energy",
"projectKey": "twig-energy_stronk"
}
}
58 changes: 54 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,43 @@
"name": "clang-tidy",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_CLANG_TIDY": "clang-tidy-13;--header-filter=${sourceDir}/*"
"CMAKE_CXX_CLANG_TIDY": "clang-tidy-17;--header-filter=${sourceDir}/*"
}
},
{
"name": "clang-13",
"hidden": true,
"environment": {
"CXX": "clang++-13",
"CC": "clang-13"
"CC": "clang-13",
"LLVM_SYMBOLIZER_PATH": "llvm-symbolizer-13"
}
},
{
"name": "clang-14",
"hidden": true,
"environment": {
"CXX": "clang++-14",
"CC": "clang-14"
"CC": "clang-14",
"LLVM_SYMBOLIZER_PATH": "llvm-symbolizer-14"
}
},
{
"name": "clang-15",
"hidden": true,
"environment": {
"CXX": "clang++-15",
"CC": "clang-15",
"LLVM_SYMBOLIZER_PATH": "llvm-symbolizer-15"
}
},
{
"name": "clang-17",
"hidden": true,
"environment": {
"CXX": "clang++-17",
"CC": "clang-17",
"LLVM_SYMBOLIZER_PATH": "llvm-symbolizer-17"
}
},
{
Expand All @@ -74,6 +94,14 @@
"CC": "gcc-12"
}
},
{
"name": "gcc-13",
"hidden": true,
"environment": {
"CXX": "g++-13",
"CC": "gcc-13"
}
},
{
"name": "msvc",
"hidden": true
Expand Down Expand Up @@ -159,7 +187,8 @@
"inherits": [
"ci-unix",
"dev-mode",
"vcpkg"
"vcpkg",
"clang-17"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Sanitize",
Expand Down Expand Up @@ -216,6 +245,13 @@
"gcc-12"
]
},
{
"name": "ci-ubuntu-gcc-13",
"inherits": [
"ci-ubuntu",
"gcc-13"
]
},
{
"name": "ci-ubuntu-clang-13",
"inherits": [
Expand All @@ -230,6 +266,20 @@
"clang-14"
]
},
{
"name": "ci-ubuntu-clang-15",
"inherits": [
"ci-ubuntu",
"clang-15"
]
},
{
"name": "ci-ubuntu-clang-17",
"inherits": [
"ci-ubuntu",
"clang-17"
]
},
{
"name": "ci-codeql",
"inherits": [
Expand Down
2 changes: 1 addition & 1 deletion CMakeUserPresets.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"inherits": [
"dev-common",
"ci-unix",
"clang-14"
"clang-17"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
Expand Down
5 changes: 1 addition & 4 deletions benchmarks/src/unit_benchmarks.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include <chrono>
#include <cstdint>
#include <string>

#include <array>
#include <benchmark/benchmark.h>
#include <fmt/core.h>

Expand Down
2 changes: 1 addition & 1 deletion cmake/lint-targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(FORMAT_PATTERNS
)

set(FORMAT_COMMAND
clang-format-14
clang-format-17
CACHE STRING "Formatter to use"
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/lint.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ macro (default name)
endif ()
endmacro ()

default(FORMAT_COMMAND clang-format-14)
default(FORMAT_COMMAND clang-format-17)
default(
PATTERNS
source/*.cpp
Expand Down
Loading

0 comments on commit ac11afd

Please sign in to comment.