Skip to content

Commit

Permalink
ci (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
petiaccja authored Nov 19, 2023
1 parent f6b25e3 commit f524170
Show file tree
Hide file tree
Showing 11 changed files with 701 additions and 12 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Build & test

on:
push:
branches:
- master
tags:
- v**.**
pull_request:
branches:
- master

jobs:
build-test:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
c_compiler: [gcc, clang, cl]
build_type: [Debug, Release]
cxx_standard: ["20"]
include:
- c_compiler: gcc
cxx_compiler: g++
- c_compiler: clang
cxx_compiler: clang++
- c_compiler: cl
cxx_compiler: cl
- os: windows-latest
binary_ext: ".exe"
- os: ubuntu-latest
binary_ext: ""
- build_type: Debug
conan_preset: "conan-debug"
- build_type: Release
conan_preset: "conan-release"
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

name: ${{ matrix.c_compiler }} - ${{ matrix.build_type }} - ${{ matrix.os }} - c++${{ matrix.cxx_standard }}

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

steps:
- uses: actions/checkout@v4
- uses: seanmiddleditch/gha-setup-ninja@v4
- uses: seanmiddleditch/gha-setup-vsdevenv@master
- uses: KyleMayes/install-llvm-action@v1
with:
version: "17.0"
directory: ${{ runner.temp }}/llvm

- name: Install GCC
shell: bash
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-13 g++-13
sudo update-alternatives --remove-all gcc || true
sudo update-alternatives --remove-all g++ || true
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10 --slave /usr/bin/g++ g++ /usr/bin/g++-13
- name: Install conan
shell: bash
env:
CC: "${{ matrix.c_compiler != 'cl' && matrix.c_compiler || '' }}"
CXX: "${{ matrix.cxx_compiler != 'cl' && matrix.cxx_compiler || '' }}"
run: |
pip install conan
conan profile detect --name ci --force
python $GITHUB_WORKSPACE/support/update-conan-profile.py $(conan profile path ci) ${{matrix.build_type}} ${{matrix.c_compiler}} ${{matrix.cxx_compiler}} ${{matrix.cxx_standard}}
- name: Cache conan packages
id: cache-conan
uses: actions/cache@v3
with:
path: ~/.conan2/p
key: conan-cache-packages-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}-${{ matrix.cxx_standard }}

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
env:
CC: ${{matrix.c_compiler}}
CXX: ${{matrix.cxx_compiler}}
run: |
conan install $GITHUB_WORKSPACE --output-folder=. --build="*" -pr ci -pr:b ci -s build_type=${{ matrix.build_type }}
conan cache clean
cmake $GITHUB_WORKSPACE --preset ${{ matrix.conan_preset }}
- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
cmake --build ./build/${{ matrix.build_type }}
cmake -E make_directory ${{runner.workspace}}/installation/SEDManager
cmake --install ./build/${{ matrix.build_type }} --prefix '${{runner.workspace}}/installation/SEDManager'
- name: Test
working-directory: ${{runner.workspace}}/build
shell: bash
run: ./build/${{ matrix.build_type }}/bin/test
22 changes: 22 additions & 0 deletions .github/workflows/clang_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Clang-Format
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: KyleMayes/install-llvm-action@v1
with:
version: "17.0"
directory: ${{ runner.temp }}/llvm
- name: Verify formatting
run: |
python ./support/run-clang-format.py -r src
python ./support/run-clang-format.py -r test
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

on:
workflow_run:
workflows: [Build & test]
branches: [v**.**]
types: [completed]

jobs:
create_release:
permissions:
actions: read
contents: write
env:
GH_TOKEN: ${{ github.token }}
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch != null }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}

- name: Create release
shell: bash
run: |
gh release create ${{ github.event.workflow_run.head_branch }}
86 changes: 86 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: SonarQube
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: ubuntu-latest
env:
SONAR_SCANNER_VERSION: 4.4.0.2170
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: seanmiddleditch/gha-setup-ninja@v4
- uses: KyleMayes/install-llvm-action@v1
with:
version: "17.0"
directory: ${{ runner.temp }}/llvm

- name: Install GCC
shell: bash
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-13 g++-13
sudo update-alternatives --remove-all gcc || true
sudo update-alternatives --remove-all g++ || true
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10 --slave /usr/bin/g++ g++ /usr/bin/g++-13
- name: Install conan
shell: bash
env:
CC: clang
CXX: clang++
run: |
pip install conan
conan profile detect --name ci --force
python $GITHUB_WORKSPACE/support/update-conan-profile.py $(conan profile path ci) Debug $CC $CXX 20
- name: Cache conan packages
id: cache-conan
uses: actions/cache@v3
with:
path: ~/.conan2/p
key: conan-cache-packages-sonarqube

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

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
env:
CC: clang
CXX: clang++
run: |
conan install $GITHUB_WORKSPACE --output-folder=. --build="*" -pr ci -pr:b ci -s build_type=Debug
conan cache clean
cmake $GITHUB_WORKSPACE --preset conan-debug -DENABLE_LLVM_COV:BOOL=ON
- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{runner.workspace}}/build/build/Debug --clean-first
- name: Generate Test and Code Coverage
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
./build/Debug/bin/test --reporter junit --out ${{runner.workspace}}/build/tests.xml
llvm-profdata merge -sparse default.profraw -o coverage.profdata
llvm-cov show ./build/Debug/bin/test -instr-profile=coverage.profdata > ${{runner.workspace}}/build/coverage.txt
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ option(ENABLE_LLVM_ADDRESS_SANITIZER OFF)
option(ENABLE_LLVM_MEMORY_SANITIZER OFF)
option(ENABLE_LLVM_THREAD_SANITIZER OFF)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if (ENABLE_LLVM_COV)
message("Using source-based coverage")
Expand Down
11 changes: 11 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sonar.projectKey=petiaccja_asyncpp
sonar.organization=petiaccja

sonar.projectName=asyncpp

sonar.sources=./src,./include
#sonar.exclusions=

sonar.cfamily.llvm-cov.reportPath=../build/coverage.txt
sonar.junit.reportPaths=../build/tests.xml
sonar.cfamily.threads=4
Loading

0 comments on commit f524170

Please sign in to comment.