Skip to content

Commit a60bf1d

Browse files
authored
Merge pull request #4 from cm-jones/develop
Refactor entire project
2 parents c9d29f2 + 9f561ad commit a60bf1d

File tree

114 files changed

+7447
-6689
lines changed

Some content is hidden

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

114 files changed

+7447
-6689
lines changed

.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ BasedOnStyle: Google
22
IndentWidth: 4
33
ColumnLimit: 80
44
PointerAlignment: Right
5-
SpaceAfterCStyleCast: true

.clang-tidy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Checks: "-*,bugprone-*,performance-*,readability-identifier-naming"
2+
WarningsAsErrors: "*"
3+
HeaderFilterRegex: ".*"
4+
FormatStyle: file
5+
6+
CheckOptions:
7+
readability-identifier-naming.FunctionCase: lower_case
8+
readability-identifier-naming.ClassCase: lower_case

.devcontainer/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM ubuntu:latest
2+
3+
RUN apt update && apt install -y \
4+
build-essential \
5+
cmake \
6+
devscripts \
7+
debhelper \
8+
gcc \
9+
git \
10+
clang \
11+
clang-format \
12+
clang-tidy \
13+
lintian \
14+
pkg-config \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Create non-root user
18+
ARG USERNAME=vscode
19+
ARG USER_UID=1000
20+
ARG USER_GID=$USER_UID
21+
22+
RUN userdel -f $(getent passwd 1000 | cut -d: -f1) 2>/dev/null || true \
23+
&& groupdel $(getent group 1000 | cut -d: -f1) 2>/dev/null || true \
24+
&& groupadd --gid $USER_GID $USERNAME \
25+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
26+
&& apt-get update \
27+
&& apt-get install -y sudo \
28+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
29+
&& chmod 0440 /etc/sudoers.d/$USERNAME
30+
31+
# Set default shell to bash
32+
ENV SHELL=/bin/bash

.devcontainer/devcontainer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "libdsc Development",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"customizations": {
7+
"vscode": {
8+
"extensions": [
9+
"ms-vscode.cpptools",
10+
"ms-vscode.cmake-tools",
11+
"xaver.clang-format",
12+
"twxs.cmake",
13+
"ms-vscode.cpptools-extension-pack",
14+
"ms-vscode.cpptools-themes",
15+
"jeff-hykin.better-cpp-syntax",
16+
"ms-vscode.makefile-tools"
17+
],
18+
"settings": {
19+
"cmake.configureOnOpen": true,
20+
"editor.formatOnSave": true,
21+
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
22+
"C_Cpp.clang_tidy_path": "/usr/bin/clang-tidy"
23+
}
24+
}
25+
},
26+
"remoteUser": "vscode",
27+
"forwardPorts": [],
28+
"postCreateCommand": "sudo chown vscode:vscode ${containerWorkspaceFolder}",
29+
"remoteEnv": {
30+
"PATH": "${containerEnv:PATH}:/usr/local/bin"
31+
}
32+
}

.github/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!build

.github/FUNDING.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: cm-jones
2+
buy_me_a_coffee: cmjones

.github/FUNDING.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/actions/build/action.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'Build Library'
2+
description: 'Builds the library in release mode'
3+
inputs:
4+
artifact_name:
5+
description: 'Name of the artifact to upload'
6+
required: false
7+
default: 'build-artifacts'
8+
outputs:
9+
build_path:
10+
description: 'Path to the build directory'
11+
value: ${{ steps.build.outputs.build_path }}
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Build
16+
id: build
17+
shell: bash
18+
run: |
19+
mkdir build
20+
cd build
21+
cmake -DCMAKE_BUILD_TYPE=Release ..
22+
make -j$(nproc)
23+
echo "build_path=$(pwd)" >> $GITHUB_OUTPUT
24+
25+
- uses: actions/upload-artifact@v3
26+
with:
27+
name: ${{ inputs.artifact_name }}
28+
path: build/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: 'Download Build Artifacts'
2+
description: 'Downloads build artifacts to specified path'
3+
inputs:
4+
path:
5+
description: 'Path to download artifacts to'
6+
required: false
7+
default: build
8+
runs:
9+
using: composite
10+
steps:
11+
- uses: actions/download-artifact@v3
12+
with:
13+
name: build-artifacts
14+
path: ${{ inputs.path }}

.github/actions/package/action.yaml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: 'Package libdsc'
2+
description: 'Build Debian, RPM, and Arch Linux packages'
3+
inputs:
4+
distribution:
5+
description: 'Distribution to build package for (debian, rpm, or arch)'
6+
required: true
7+
version:
8+
description: 'Version tag (e.g., v0.1.0-alpha)'
9+
required: true
10+
outputs:
11+
package-path:
12+
description: 'Path to the built package'
13+
value: ${{ steps.get-path.outputs.path }}
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Process version string
18+
id: version
19+
shell: bash
20+
run: |
21+
# Remove 'v' prefix from tag
22+
VERSION="${{ inputs.version }}"
23+
VERSION=${VERSION#v}
24+
25+
# Split version and prerelease
26+
BASE_VERSION=${VERSION%%-*}
27+
PRERELEASE=${VERSION#*-}
28+
if [ "$PRERELEASE" = "$BASE_VERSION" ]; then
29+
PRERELEASE=""
30+
fi
31+
32+
# Format for Debian: 0.1.0~alpha1
33+
if [ -n "$PRERELEASE" ]; then
34+
DEB_VERSION="${BASE_VERSION}~${PRERELEASE}1"
35+
else
36+
DEB_VERSION="$BASE_VERSION"
37+
fi
38+
39+
# Format for Arch: 0.1.0_alpha
40+
if [ -n "$PRERELEASE" ]; then
41+
ARCH_VERSION="${BASE_VERSION}_${PRERELEASE}"
42+
else
43+
ARCH_VERSION="$BASE_VERSION"
44+
fi
45+
46+
# Format for RPM: 0.1.0~alpha
47+
if [ -n "$PRERELEASE" ]; then
48+
RPM_VERSION="${BASE_VERSION}~${PRERELEASE}"
49+
else
50+
RPM_VERSION="$BASE_VERSION"
51+
fi
52+
53+
echo "::set-output name=deb_version::$DEB_VERSION"
54+
echo "::set-output name=arch_version::$ARCH_VERSION"
55+
echo "::set-output name=rpm_version::$RPM_VERSION"
56+
57+
- if: inputs.distribution == 'debian'
58+
name: Update Debian changelog
59+
shell: bash
60+
run: |
61+
dch --newversion "${{ steps.version.outputs.deb_version }}" \
62+
--package libdsc \
63+
--force-distribution \
64+
--distribution unstable \
65+
"Release ${{ inputs.version }}"
66+
67+
- if: inputs.distribution == 'debian'
68+
name: Setup Debian packaging tools
69+
shell: bash
70+
run: |
71+
sudo apt-get update
72+
sudo apt-get install -y devscripts debhelper pkg-config
73+
74+
- if: inputs.distribution == 'debian'
75+
name: Build Debian package
76+
shell: bash
77+
run: |
78+
cd ${{ github.workspace }}
79+
./scripts/build-debian.sh
80+
81+
- if: inputs.distribution == 'rpm'
82+
name: Setup RPM packaging environment
83+
shell: bash
84+
run: |
85+
# Create a container for building RPM
86+
docker run --rm -v ${{ github.workspace }}:/work \
87+
-w /work fedora:latest \
88+
bash -c "dnf install -y rpm-build rpmdevtools cmake gcc make && \
89+
useradd -m builder && \
90+
chown -R builder:builder . && \
91+
su builder -c './scripts/build-rpm.sh'"
92+
93+
- if: inputs.distribution == 'arch'
94+
name: Update PKGBUILD version
95+
shell: bash
96+
run: |
97+
cd packaging/arch
98+
sed -i "s/pkgver=.*/pkgver=${{ steps.version.outputs.arch_version }}/" PKGBUILD
99+
makepkg --printsrcinfo > .SRCINFO
100+
101+
- if: inputs.distribution == 'arch'
102+
name: Setup Arch packaging environment
103+
shell: bash
104+
run: |
105+
docker run --rm -v ${{ github.workspace }}:/work \
106+
-w /work archlinux:base-devel \
107+
bash -c "pacman -Sy --noconfirm base-devel cmake && \
108+
useradd -m builder && \
109+
chown -R builder:builder . && \
110+
su builder -c './scripts/build-arch.sh'"
111+
112+
- id: get-path
113+
shell: bash
114+
run: |
115+
if [ "${{ inputs.distribution }}" = "debian" ]; then
116+
echo "::set-output name=path::packaging/debian/libdsc_${{ steps.version.outputs.deb_version }}_amd64.deb"
117+
elif [ "${{ inputs.distribution }}" = "rpm" ]; then
118+
echo "::set-output name=path::packaging/rpm/libdsc-${{ steps.version.outputs.rpm_version }}-1.*.rpm"
119+
else
120+
echo "::set-output name=path::packaging/arch/libdsc-${{ steps.version.outputs.arch_version }}-1-x86_64.pkg.tar.zst"
121+
fi
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: 'Run Benchmarks'
2+
description: 'Runs all benchmark executables'
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Run Benchmarks
7+
shell: bash
8+
run: cd build && ./benchmark_*

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Run Tests'
2+
description: 'Runs tests and reports results'
3+
outputs:
4+
passed:
5+
description: 'Whether tests passed'
6+
value: ${{ steps.check.outputs.passed }}
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Run Tests
11+
id: run
12+
shell: bash
13+
run: cd build && ctest --output-on-failure
14+
15+
- name: Check Results
16+
id: check
17+
shell: bash
18+
run: |
19+
echo "passed=${{ steps.run.outcome == 'success' }}" >> $GITHUB_OUTPUT
20+
if [[ "${{ steps.run.outcome }}" != "success" ]]; then
21+
exit 1
22+
fi

.github/actions/setup/action.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'Setup Build Environment'
2+
description: 'Sets up the build environment'
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Install Dependencies
7+
shell: bash
8+
run: |
9+
sudo apt-get update
10+
sudo apt-get install -y cmake build-essential

.github/workflows/c.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
permissions: {}
10+
jobs:
11+
ci:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: ./.github/actions/setup
16+
- uses: ./.github/actions/build
17+
- uses: ./.github/actions/run-tests
18+
- uses: ./.github/actions/run-benchmarks

0 commit comments

Comments
 (0)