Skip to content

Commit

Permalink
Apply the latest Beman Standard
Browse files Browse the repository at this point in the history
  • Loading branch information
neatudarius committed Jul 25, 2024
1 parent 3742e50 commit e09c5ed
Show file tree
Hide file tree
Showing 19 changed files with 359 additions and 85 deletions.
21 changes: 13 additions & 8 deletions .ci/docker/rockylinux.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
# SPDX-License-Identifier: MIT

FROM rockylinux:9

# Enable EPEL
# Enable EPEL.
RUN dnf update -y
RUN dnf install -y 'dnf-command(config-manager)'
RUN dnf config-manager --set-enabled crb -y
RUN dnf install epel-release -y

# Install dependencies
# Install dependencies.
RUN dnf install -y \
clang \
g++ \
ninja-build \
cmake
cmake \
git
RUN dnf clean all

# Copy code
# Copy code.
WORKDIR /workarea
COPY ./ ./

# Set build arguments.
ARG cc=gcc
ARG cxx=g++
ARG cmake_args=

# Build.
ENV CC="$cc" CXX="$cxx" CMAKE_GENERATOR="Ninja" CMAKE_EXPORT_COMPILE_COMMANDS=on
RUN cmake -B build -S . "$cmake_args" && \
cmake --build build --verbose && \
DESTDIR=build/staging cmake --install build --prefix /opt/example --component libexample-dev && \
find build/staging -type f
RUN cmake -B build -S . "$cmake_args"
RUN cmake --build build --verbose
RUN DESTDIR=build/staging cmake --install build --prefix /opt/beman/example --component libbeman_example-dev
RUN find build/staging -type f
19 changes: 12 additions & 7 deletions .ci/docker/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# Using a non-LTS Ubuntu, just until CMake 3.23 is available on Ubuntu 24.04
# SPDX-License-Identifier: MIT

# Using a non-LTS Ubuntu, just until CMake 3.23 is available on Ubuntu 24.04.
FROM ubuntu:23.10

# Install dependencies
# Install dependencies,
RUN apt-get update
RUN apt-get install -y \
clang \
clang-tidy \
g++ \
ninja-build \
cmake
cmake \
git
RUN apt-get clean

WORKDIR /workarea
COPY ./ ./

# Set build arguments.
ARG cc=gcc
ARG cxx=g++
ARG cmake_args=

# Workaround Ubuntu broken ASan
RUN sysctl vm.mmap_rnd_bits=28

# Build.
ENV CC="$cc" CXX="$cxx" CMAKE_GENERATOR="Ninja" CMAKE_EXPORT_COMPILE_COMMANDS=on
RUN cmake -B build -S . "$cmake_args" && \
cmake --build build --verbose && \
DESTDIR=build/staging cmake --install build --prefix /opt/example --component libexample-dev && \
find build/staging -type f
RUN cmake -B build -S . "$cmake_args"
RUN cmake --build build --verbose
RUN DESTDIR=build/staging cmake --install build --prefix /opt/beman/example --component libbeman_example-dev
RUN find build/staging -type f
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Codeowners for reviews on PRs

* @bbrown105 @dustingooding @JamesAdkison @neatudarius
84 changes: 84 additions & 0 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# SPDX-License-Identifier: MIT

name: CI Test

on:
push:
branches: [ main ]
paths:
- "src/**"
- "test/**"
- "CMakeLists.txt"
pull_request:
branches: [ main ]
paths:
- "src/**"
- "test/**"
- "CMakeLists.txt"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
cfg:
- { id: ubuntu-gcc-werror, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'"}
- { id: ubuntu-gcc-aubsan, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_FLAGS=-fsanitize=address -fsanitize=undefined"}
- { id: ubuntu-gcc-tsan, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_FLAGS=-fsanitize=thread"}
- { id: ubuntu-gcc-static, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: ""}
- { id: ubuntu-gcc-static-cxx98, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=98 -DCMAKE_CXX_STANDARD_REQUIRED=on"}
- { id: ubuntu-gcc-static-cxx11, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=on"}
- { id: ubuntu-gcc-static-cxx14, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=on"}
- { id: ubuntu-gcc-static-cxx17, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=on"}
- { id: ubuntu-gcc-static-cxx20, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=on"}
- { id: ubuntu-gcc-static-cxx23, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=23 -DCMAKE_CXX_STANDARD_REQUIRED=on"}
- { id: ubuntu-gcc-static-cxx26, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=26 -DCMAKE_CXX_STANDARD_REQUIRED=on"}
- { id: ubuntu-gcc-dynamic, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DBUILD_SHARED_LIBS=on"}
- { id: ubuntu-clang-static, platform: ubuntu, cc: clang, cpp: clang++, cmake_args: ""}
- { id: ubuntu-clang-dynamic, platform: ubuntu, cc: clang, cpp: clang++, cmake_args: "-DBUILD_SHARED_LIBS=on"}
# Disabling Rocky until it catches up on CMake versions or a way to sideload newer version of CMake
# is identified.
# - { id: rockylinux-gcc-static, platform: rockylinux, cc: gcc, cpp: g++, cmake_args: ""}
# - { id: rockylinux-clang-static, platform: rockylinux, cc: clang, cpp: clang++, cmake_args: ""}

steps:
- uses: actions/checkout@v2
# GitHub runners have updated the Ubuntu Linux Kernel to use strong ASLR,
# but LLVM is not configured for this change, and thus the address
# sanitizer breaks.
#
# The next image is supposed to fix this, so if the Ubuntu image has been
# updated, this work around is no longer required.
- name: get runner image version
id: runner-image-version
run: |
echo "image-version=$(echo $ImageVersion)" >> "$GITHUB_OUTPUT"
working-directory: .
- name: modify number of bits to use for ASLR entropy
if: ${{ steps.runner-image-version.outputs.ImageVersion }} == '20240310.1.0'
run: |
sudo sysctl -a | grep vm.mmap.rnd
sudo sysctl -w vm.mmap_rnd_bits=28
working-directory: .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: false
load: true
tags: ${{ matrix.cfg.id }}
file: .ci/docker/${{ matrix.cfg.platform }}.Dockerfile
build-args: |
cc=${{ matrix.cfg.cc }}
cxx=${{ matrix.cfg.cpp }}
cmake_args=${{ matrix.cfg.cmake_args }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run tests
run: |
docker run ${{ matrix.cfg.id }} ctest --test-dir build
1 change: 0 additions & 1 deletion .github/workflows/cxx.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Copyright © 2024 Bret Brown
# SPDX-License-Identifier: MIT

name: Test
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake.bld
compile_commands.json
/.build/
/build/
/.cache/
*.pyg
.update-submodules
.vscode/
26 changes: 21 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
# Copyright © 2024 Bret Brown
# SPDX-License-Identifier: MIT

cmake_minimum_required(VERSION 3.23)
project(example

project(beman_example
VERSION 1.0.0
DESCRIPTION "An example Beman library"
LANGUAGES CXX
)
include(CTest)

add_subdirectory(src/example)
# Include the CTest module.
include(CTest)

# Build the tests only if enabled via the CLI flag: BUILD_TESTING.
if (BUILD_TESTING)
add_subdirectory(test/example)
enable_testing()

# Fetch GoogleTest
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # release-1.14.0
)
FetchContent_MakeAvailable(googletest)
endif ()

# Build the library.
add_subdirectory(src/Beman/Example)

# Build the examples.
add_subdirectory(examples)
2 changes: 0 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
MIT License

Copyright (c) 2024 Bret Brown

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Expand Down
Loading

0 comments on commit e09c5ed

Please sign in to comment.