Skip to content

Commit 417aa78

Browse files
authored
Merge pull request #5 from cm-jones/develop
Update
2 parents a60bf1d + 3be6b59 commit 417aa78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1856
-2162
lines changed

.SRCINFO

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
pkgbase = libdsc
2+
pkgdesc = Generic implementations of C++ Standard Library containers in C
3+
pkgver = 0.1.0_alpha
4+
pkgrel = 1
5+
url = https://github.com/cm-jones/libdsc
6+
arch = x86_64
7+
arch = aarch64
8+
arch = armv7h
9+
license = GPL3
10+
makedepends = cmake>=3.10
11+
makedepends = gcc>=9.3
12+
makedepends = make
13+
options = !strip
14+
source = libdsc-0.1.0_alpha.tar.gz::https://github.com/cm-jones/libdsc/archive/v0.1.0-alpha.tar.gz
15+
sha256sums = SKIP
16+
17+
pkgname = libdsc
18+
depends = glibc
19+
provides = libdsc.so
20+
backup = etc/libdsc.conf
21+
22+
pkgname = libdsc-docs
23+
pkgdesc = Documentation for libdsc
24+
arch = any
25+
26+
pkgname = libdsc-debug
27+
pkgdesc = Debug symbols for libdsc
28+
depends = libdsc

.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ BasedOnStyle: Google
22
IndentWidth: 4
33
ColumnLimit: 80
44
PointerAlignment: Right
5+
DerivePointerAlignment: false
6+
QualifierAlignment: Right

.devcontainer/Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
FROM ubuntu:latest
22

3-
RUN apt update && apt install -y \
3+
RUN apt-get update && apt-get install -y \
44
build-essential \
5+
clang \
6+
clang-format \
7+
clang-tidy \
58
cmake \
69
devscripts \
710
debhelper \
11+
doxygen \
812
gcc \
13+
gdb \
914
git \
10-
clang \
11-
clang-format \
12-
clang-tidy \
1315
lintian \
16+
linux-tools \
17+
lldb \
1418
pkg-config \
1519
&& rm -rf /var/lib/apt/lists/*
1620

.github/actions/build/action.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
name: 'Build Library'
2-
description: 'Builds the library in release mode'
1+
name: "Build"
2+
description: "Builds the library"
33
inputs:
4+
build_type:
5+
description: "Build type (Debug or Release)"
6+
required: false
7+
default: "Release"
48
artifact_name:
5-
description: 'Name of the artifact to upload'
9+
description: "Name of the artifact to upload"
610
required: false
7-
default: 'build-artifacts'
11+
default: "build-artifacts"
812
outputs:
913
build_path:
10-
description: 'Path to the build directory'
14+
description: "Path to the build directory"
1115
value: ${{ steps.build.outputs.build_path }}
1216
runs:
1317
using: composite
@@ -18,11 +22,11 @@ runs:
1822
run: |
1923
mkdir build
2024
cd build
21-
cmake -DCMAKE_BUILD_TYPE=Release ..
25+
cmake -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} ..
2226
make -j$(nproc)
2327
echo "build_path=$(pwd)" >> $GITHUB_OUTPUT
2428
25-
- uses: actions/upload-artifact@v3
29+
- uses: actions/upload-artifact@v4
2630
with:
2731
name: ${{ inputs.artifact_name }}
2832
path: build/

.github/actions/coverage/action.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Coverage"
2+
description: "Generates and uploads code coverage report"
3+
inputs:
4+
artifact_name:
5+
description: "Name of the artifact to upload"
6+
required: false
7+
default: "coverage-report"
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Install Dependencies
12+
shell: bash
13+
run: |
14+
sudo apt-get update
15+
sudo apt-get install -y lcov
16+
17+
- name: Run Tests
18+
shell: bash
19+
run: |
20+
cd build
21+
ctest --output-on-failure
22+
23+
- name: Generate Coverage Report
24+
shell: bash
25+
run: |
26+
cd build
27+
lcov --capture --directory . --output-file coverage.info --rc lcov_branch_coverage=1 --rc geninfo_function_coverage=1 --rc geninfo_unexecuted_blocks=1 --ignore-errors mismatch
28+
lcov --remove coverage.info '/usr/*' --output-file coverage.info
29+
genhtml coverage.info --output-directory coverage_report
30+
31+
- uses: actions/upload-artifact@v4
32+
with:
33+
name: ${{ inputs.artifact_name }}
34+
path: build/coverage_report
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
name: 'Download Build Artifacts'
2-
description: 'Downloads build artifacts to specified path'
1+
name: "Download Artifacts"
2+
description: "Downloads build artifacts to specified path"
33
inputs:
44
path:
5-
description: 'Path to download artifacts to'
5+
description: "Path to download artifacts to"
66
required: false
77
default: build
88
runs:
99
using: composite
1010
steps:
11-
- uses: actions/download-artifact@v3
11+
- uses: actions/download-artifact@v4
1212
with:
1313
name: build-artifacts
1414
path: ${{ inputs.path }}

.github/actions/package/action.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
name: 'Package libdsc'
2-
description: 'Build Debian, RPM, and Arch Linux packages'
1+
name: "Package libdsc"
2+
description: "Build Debian, RPM, and Arch Linux packages"
33
inputs:
44
distribution:
5-
description: 'Distribution to build package for (debian, rpm, or arch)'
5+
description: "Distribution to build package for (debian, rpm, or arch)"
66
required: true
77
version:
8-
description: 'Version tag (e.g., v0.1.0-alpha)'
8+
description: "Version tag (e.g., v0.1.0-alpha)"
99
required: true
1010
outputs:
1111
package-path:
12-
description: 'Path to the built package'
12+
description: "Path to the built package"
1313
value: ${{ steps.get-path.outputs.path }}
1414
runs:
1515
using: composite
@@ -21,35 +21,35 @@ runs:
2121
# Remove 'v' prefix from tag
2222
VERSION="${{ inputs.version }}"
2323
VERSION=${VERSION#v}
24-
24+
2525
# Split version and prerelease
2626
BASE_VERSION=${VERSION%%-*}
2727
PRERELEASE=${VERSION#*-}
2828
if [ "$PRERELEASE" = "$BASE_VERSION" ]; then
2929
PRERELEASE=""
3030
fi
31-
31+
3232
# Format for Debian: 0.1.0~alpha1
3333
if [ -n "$PRERELEASE" ]; then
3434
DEB_VERSION="${BASE_VERSION}~${PRERELEASE}1"
3535
else
3636
DEB_VERSION="$BASE_VERSION"
3737
fi
38-
38+
3939
# Format for Arch: 0.1.0_alpha
4040
if [ -n "$PRERELEASE" ]; then
4141
ARCH_VERSION="${BASE_VERSION}_${PRERELEASE}"
4242
else
4343
ARCH_VERSION="$BASE_VERSION"
4444
fi
45-
45+
4646
# Format for RPM: 0.1.0~alpha
4747
if [ -n "$PRERELEASE" ]; then
4848
RPM_VERSION="${BASE_VERSION}~${PRERELEASE}"
4949
else
5050
RPM_VERSION="$BASE_VERSION"
5151
fi
52-
52+
5353
echo "::set-output name=deb_version::$DEB_VERSION"
5454
echo "::set-output name=arch_version::$ARCH_VERSION"
5555
echo "::set-output name=rpm_version::$RPM_VERSION"

.github/actions/run-benchmarks/action.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ runs:
55
steps:
66
- name: Run Benchmarks
77
shell: bash
8-
run: cd build && ./benchmark_*
8+
run: |
9+
cd build/benchmarks && for benchmark in benchmark_*; do
10+
if [ -x "$benchmark" ]; then
11+
./$benchmark
12+
fi
13+
done

.github/actions/setup/action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: 'Setup Build Environment'
2-
description: 'Sets up the build environment'
1+
name: "Setup"
2+
description: "Sets up the build environment"
33
runs:
44
using: composite
55
steps:

.github/workflows/benchmark.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Benchmarks
2+
on:
3+
schedule:
4+
# Run weekly on Sunday at 00:00 UTC
5+
- cron: '0 0 * * 0'
6+
# Allow manual trigger
7+
workflow_dispatch:
8+
9+
permissions: {}
10+
11+
jobs:
12+
benchmark:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- uses: ./.github/actions/setup
18+
19+
- uses: ./.github/actions/build
20+
with:
21+
build_type: Release # Use Release mode for benchmarks
22+
23+
- uses: ./.github/actions/run-benchmarks
24+
25+
# Store benchmark results
26+
- uses: actions/upload-artifact@v4
27+
with:
28+
name: benchmark-results
29+
path: build/benchmarks
30+
retention-days: 90 # Keep results for trend analysis

.github/workflows/ci.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@ on:
66
pull_request:
77
branches:
88
- main
9-
permissions: {}
9+
permissions:
10+
contents: read # Required for actions/checkout
11+
id-token: write # Required for codecov token authentication
12+
actions: read # Required for artifact upload
1013
jobs:
1114
ci:
1215
runs-on: ubuntu-latest
1316
steps:
1417
- uses: actions/checkout@v3
1518
- uses: ./.github/actions/setup
1619
- uses: ./.github/actions/build
17-
- uses: ./.github/actions/run-tests
18-
- uses: ./.github/actions/run-benchmarks
20+
with:
21+
build_type: Debug
22+
- uses: ./.github/actions/coverage
23+
24+
- name: Upload to Codecov
25+
uses: codecov/codecov-action@v4
26+
with:
27+
token: ${{ secrets.CODECOV_TOKEN }}
28+
files: build/coverage.info
29+
fail_ci_if_error: true

.github/workflows/release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
- uses: actions/checkout@v3
1414
- uses: ./.github/actions/setup
1515
- uses: ./.github/actions/build
16+
with:
17+
build_type: Release
1618
- id: tests
1719
uses: ./.github/actions/run-tests
1820

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ CTestTestfile.cmake
8686
_deps
8787

8888
# Test coverage
89-
coverage/
9089
*.gcno
9190
*.gcda
9291
*.gcov
@@ -121,3 +120,5 @@ packaging/arch/src/
121120
packaging/arch/*.tar.gz
122121
packaging/arch/*.tar.xz
123122
packaging/arch/*.tar.zst
123+
124+
.cache

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ if(NOT CMAKE_BUILD_TYPE)
1313
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
1414
endif()
1515

16+
# Options
17+
option(ENABLE_COVERAGE "Enable coverage reporting" OFF)
18+
1619
# Debug and Release build flags
1720
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
1821
# Debug build flags
@@ -22,6 +25,13 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
2225
# Release build flags
2326
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
2427
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
28+
29+
# Enable coverage in Debug mode
30+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
31+
set(ENABLE_COVERAGE ON)
32+
add_compile_options(--coverage)
33+
add_link_options(--coverage)
34+
endif()
2535
endif()
2636

2737
# Enable sanitizers in Debug mode
@@ -37,6 +47,11 @@ option(BUILD_TESTS "Build tests" ON)
3747
option(BUILD_BENCHMARKS "Build benchmarks" ON)
3848
option(BUILD_EXAMPLES "Build examples" ON)
3949

50+
# Set default build type if not specified
51+
if(NOT CMAKE_BUILD_TYPE)
52+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
53+
endif()
54+
4055
# Library target
4156
add_library(dsc
4257
src/vector.c
@@ -65,7 +80,6 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
6580
-Wnested-externs
6681
-Wmissing-include-dirs
6782
)
68-
6983
endif()
7084

7185
# Include directories
File renamed without changes.

0 commit comments

Comments
 (0)