Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/build_and_test_libshotscope.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Build & Test libshotscope on Ubuntu
name: Quick Build & Test

on:
push:
Expand All @@ -9,31 +7,33 @@ on:
branches: [ "main" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
quick-check:
name: Quick Ubuntu Build
runs-on: ubuntu-latest

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

- name: Cache CMake build
uses: actions/cache@v4
with:
path: |
build
!build/_deps
key: ubuntu-cmake-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
ubuntu-cmake-

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j$(nproc)

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure

87 changes: 87 additions & 0 deletions .github/workflows/ci-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Multi-Platform CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
BUILD_TYPE: Release

jobs:
build-and-test:
name: ${{ matrix.os }} - ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
compiler: [default]
include:
# Linux builds with GCC and Clang
- os: ubuntu-latest
compiler: gcc
cc: gcc
cxx: g++
- os: ubuntu-latest
compiler: clang
cc: clang
cxx: clang++
# macOS with AppleClang
- os: macos-latest
compiler: default
cc: clang
cxx: clang++
# Windows with MSVC
- os: windows-latest
compiler: default

steps:
- uses: actions/checkout@v4

- name: Set up compiler (Linux)
if: runner.os == 'Linux' && matrix.compiler != 'default'
run: |
if [ "${{ matrix.compiler }}" = "clang" ]; then
sudo apt-get update
sudo apt-get install -y clang
fi

- name: Cache CMake build
uses: actions/cache@v4
with:
path: |
build
!build/_deps
key: ${{ runner.os }}-${{ matrix.compiler }}-cmake-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.compiler }}-cmake-

- name: Configure CMake (Unix)
if: runner.os != 'Windows'
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}

- name: Configure CMake (Windows)
if: runner.os == 'Windows'
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}

- name: Build
run: cmake --build build --config ${{ env.BUILD_TYPE }}

- name: Test
working-directory: build
run: ctest -C ${{ env.BUILD_TYPE }} --output-on-failure

- name: Upload build artifacts
if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc'
uses: actions/upload-artifact@v4
with:
name: libshotscope-${{ runner.os }}
path: |
build/libshotscope.a
build/include/version.hpp
62 changes: 62 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Code Coverage

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y lcov

- name: Configure CMake with Coverage
env:
CC: gcc
CXX: g++
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_COVERAGE=ON

- name: Build
run: cmake --build build

- name: Run tests
working-directory: build
run: ctest --output-on-failure

- name: Generate coverage report
run: |
lcov --directory . --capture --output-file coverage.info --ignore-errors mismatch
lcov --remove coverage.info '/usr/*' '*/build/_deps/*' '*/test/*' --output-file coverage.info --ignore-errors unused
lcov --list coverage.info

- name: Generate HTML coverage report
run: |
genhtml coverage.info --output-directory coverage_html

- name: Generate coverage summary
run: |
echo "## Code Coverage Summary" > coverage-summary.txt
lcov --summary coverage.info 2>&1 | tee -a coverage-summary.txt

- name: Upload coverage HTML
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage_html/

- name: Upload coverage summary
uses: actions/upload-artifact@v4
with:
name: coverage-summary
path: coverage-summary.txt
109 changes: 109 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

permissions:
contents: write

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version from tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
body: |
## libshotscope ${{ steps.get_version.outputs.version }}

### Installation
Download the appropriate binary for your platform below.

### Building from Source
See the [README](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/README.md) for build instructions.

build-release:
name: Build ${{ matrix.os }}
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
artifact_name: libshotscope.a
asset_name: libshotscope-linux-x86_64.a
- os: macos-latest
artifact_name: libshotscope.a
asset_name: libshotscope-macos-x86_64.a
- os: windows-latest
artifact_name: shotscope.lib
asset_name: libshotscope-windows-x86_64.lib

steps:
- uses: actions/checkout@v4

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Release

- name: Build
run: cmake --build build --config Release

- name: Package headers
run: |
mkdir -p package/include
cp -r include/* package/include/
cp build/include/version.hpp package/include/

- name: Create archive (Unix)
if: runner.os != 'Windows'
run: |
cp build/${{ matrix.artifact_name }} package/
cd package
tar -czf ../libshotscope-${{ runner.os }}-${{ needs.create-release.outputs.version }}.tar.gz .

- name: Create archive (Windows)
if: runner.os == 'Windows'
run: |
cp build/Release/${{ matrix.artifact_name }} package/
cd package
7z a ../libshotscope-Windows-${{ needs.create-release.outputs.version }}.zip .

- name: Upload Release Asset (Unix)
if: runner.os != 'Windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./libshotscope-${{ runner.os }}-${{ needs.create-release.outputs.version }}.tar.gz
asset_name: libshotscope-${{ runner.os }}-${{ needs.create-release.outputs.version }}.tar.gz
asset_content_type: application/gzip

- name: Upload Release Asset (Windows)
if: runner.os == 'Windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./libshotscope-Windows-${{ needs.create-release.outputs.version }}.zip
asset_name: libshotscope-Windows-${{ needs.create-release.outputs.version }}.zip
asset_content_type: application/zip
61 changes: 61 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Static Analysis

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
clang-tidy:
name: Clang-Tidy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang clang-tidy

- name: Configure CMake
env:
CC: clang
CXX: clang++
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Run clang-tidy
run: |
find src -name '*.cpp' | xargs clang-tidy -p build --warnings-as-errors='' --format-style=file

cppcheck:
name: Cppcheck
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install cppcheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck

- name: Run cppcheck
run: |
cppcheck --enable=all \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--inline-suppr \
--error-exitcode=1 \
--std=c++17 \
-I include \
src/ \
2>&1 | tee cppcheck-report.txt

- name: Upload cppcheck report
if: always()
uses: actions/upload-artifact@v4
with:
name: cppcheck-report
path: cppcheck-report.txt
Loading