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
19 changes: 19 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Checks:
- -*
- cppcoreguidelines-pro-type-member-init
- modernize-redundant-void-arg
- modernize-use-bool-literals
- modernize-use-default-member-init
- modernize-use-nullptr
- readability-braces-around-statements
- readability-redundant-member-init
HeaderFileExtensions: ['', h, hh, hpp, hxx, inc]
ImplementationFileExtensions: [c, cc, cpp, cxx]
HeaderFilterRegex: (extension/src/openvic-dataloader)/
FormatStyle: file
CheckOptions:
cppcoreguidelines-pro-type-member-init.IgnoreArrays: true
cppcoreguidelines-pro-type-member-init.UseAssignment: true
modernize-use-bool-literals.IgnoreMacros: false
modernize-use-default-member-init.IgnoreMacros: false
modernize-use-default-member-init.UseAssignment: true
35 changes: 35 additions & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,44 @@ concurrency:
cancel-in-progress: true

jobs:
static-checks:
name: Code style, file formatting, and docs
runs-on: ubuntu-24.04
steps:
- name: Checkout project
uses: actions/[email protected]
with:
fetch-depth: 2

- name: Install APT dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libxml2-utils

- name: Get changed files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config diff.wsErrorHighlight all
if [ "${{ github.event_name }}" == "pull_request" -o "${{ github.event.forced }}" == "true" -o "${{ github.event.created }}" == "true" ]; then
files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.created }}" == "false" ]; then
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
fi
echo "$files" >> changed.txt
cat changed.txt
files=$(echo "$files" | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ')
echo "CHANGED_FILES=$files" >> $GITHUB_ENV

- name: Style checks via pre-commit
uses: pre-commit/[email protected]
with:
extra_args: --files ${{ env.CHANGED_FILES }}

build:
runs-on: ${{matrix.os}}
name: ${{matrix.name}}
needs: static-checks
permissions: write-all
strategy:
fail-fast: false
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/cache_cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
name: 🧹 Cache Cleanup
on:
pull_request:
types:
- closed

jobs:
cleanup:
name: Cleanup PR caches
runs-on: ubuntu-latest
permissions:
# `actions:write` permission is required to delete caches
actions: write
contents: read
steps:
- name: Cleanup
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
run: |
echo "Fetching list of cache key"
cache_keys_for_pr=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
# Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cache_key in $cache_keys_for_pr; do
gh cache delete $cache_key
echo "Deleted: $cache_key"
done
echo "Done"
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
default_language_version:
python: python3

repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.3
hooks:
- id: clang-format
files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|inc)$
types_or: [text]

- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-tidy
files: \.(c|h|cpp|hpp)$
args: [--fix, --quiet, --use-color]
types_or: [text]
additional_dependencies: [clang-tidy==19.1.0]
require_serial: true
stages: [manual] # Not automatically triggered, invoked via `pre-commit run --hook-stage manual clang-tidy`

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.10
hooks:
- id: ruff
args: [--fix]
files: (\.py|SConstruct|SCsub)$
types_or: [text]
- id: ruff-format
files: (\.py|SConstruct|SCsub)$
types_or: [text]

- repo: https://github.com/crate-ci/typos
rev: v1.30.2
hooks:
- id: typos
# exclude: |
# (?x)^(
# )
additional_dependencies: [tomli]
24 changes: 16 additions & 8 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/usr/bin/env python

import os
import platform
import sys

import SCons

BINDIR = "bin"

Expand All @@ -15,10 +11,22 @@ env.PrependENVPath("PATH", os.getenv("PATH"))
opts = env.SetupOptions()

opts.Add(BoolVariable("run_ovdl_tests", "Build and run the openvic dataloader tests", env.is_standalone))
opts.Add(BoolVariable("build_ovdl_library", "Build the openvic dataloader library.", env.get("build_ovdl_library", not env.is_standalone)))
opts.Add(
BoolVariable(
"build_ovdl_library",
"Build the openvic dataloader library.",
env.get("build_ovdl_library", not env.is_standalone),
)
)
opts.Add(BoolVariable("build_ovdl_headless", "Build the openvic dataloader headless executable", env.is_standalone))

opts.Add(BoolVariable("ubuntu_gcc_invalid_char_hang_bug", "Skips test section which triggers a hang build for gcc-12 on ubuntu-20", False))
opts.Add(
BoolVariable(
"ubuntu_gcc_invalid_char_hang_bug",
"Skips test section which triggers a hang build for gcc-12 on ubuntu-20",
False,
)
)

env.FinalizeOptions()

Expand Down Expand Up @@ -88,7 +96,7 @@ if env["build_ovdl_headless"]:
headless_program = headless_env.Program(
target=os.path.join(BINDIR, headless_name),
source=headless_env.headless_sources,
PROGSUFFIX=".headless" + env["PROGSUFFIX"]
PROGSUFFIX=".headless" + env["PROGSUFFIX"],
)
default_args += [headless_program]

Expand All @@ -105,4 +113,4 @@ if "env" in locals():
# FIXME: This method mixes both cosmetic progress stuff and cache handling...
env.show_progress(env)

Return("env")
Return("env")
76 changes: 52 additions & 24 deletions deps/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import os

Import("env")


def build_lexy(env):
env.Append(CPPDEFINES=["LEXY_HAS_UNICODE_DATABASE=1"])
lexy_env = env.Clone()
Expand All @@ -17,13 +18,19 @@ def build_lexy(env):
else:
lexy_env.Append(CXXFLAGS=["-std=c++20"])

lexy_env.Append(CXXFLAGS=["-pedantic-errors", "-Werror", "-Wall", "-Wextra", "-Wconversion", "-Wsign-conversion"])
lexy_env.Append(
CXXFLAGS=["-pedantic-errors", "-Werror", "-Wall", "-Wextra", "-Wconversion", "-Wsign-conversion"]
)
if lexy_env["CXX"] == "clang++":
lexy_env.Append(CXXFLAGS=["-Wno-shift-op-parentheses", "-Wno-parentheses-equality"])
else:
lexy_env.Append(CXXFLAGS=[
"-Wno-parentheses", "-Wno-unused-local-typedefs", "-Wno-array-bounds" #, "-Wno-maybe-uninitialized", "-Wno-restrict"
])
lexy_env.Append(
CXXFLAGS=[
"-Wno-parentheses",
"-Wno-unused-local-typedefs",
"-Wno-array-bounds", # , "-Wno-maybe-uninitialized", "-Wno-restrict"
]
)

include_path = "lexy/include"
source_path = "lexy/src"
Expand All @@ -46,6 +53,7 @@ def build_lexy(env):
env.Append(LIBPATH=[source_dir])
env.Prepend(LIBS=[library_name])


def build_dryad(env):
include_path = "dryad/include"
include_dir = env.Dir(include_path)
Expand All @@ -59,6 +67,7 @@ def build_dryad(env):

env.exposed_includes += env.dryad["INCPATH"]


def build_fmt(env):
fmt_env = env.Clone()

Expand All @@ -70,26 +79,43 @@ def build_fmt(env):
else:
fmt_env.Append(CXXFLAGS=["-std=c++20"])

fmt_env.Append(CXXFLAGS=[
"-Werror", "-Wall", "-Wextra", "-pedantic", "-Wconversion", "-Wundef"
])
fmt_env.Append(CXXFLAGS=["-Werror", "-Wall", "-Wextra", "-pedantic", "-Wconversion", "-Wundef"])
if fmt_env["CXX"] == "clang++":
fmt_env.Append(CXXFLAGS=[
"-Wweak-vtables", "-Wshadow",
"-Wno-gnu-zero-variadic-macro-arguments"
])
fmt_env.Append(CXXFLAGS=["-Wweak-vtables", "-Wshadow", "-Wno-gnu-zero-variadic-macro-arguments"])
else:
fmt_env.Append(CXXFLAGS=[
"-Wold-style-cast", "-Wundef", "-Wredundant-decls", "-Wwrite-strings",
"-Wpointer-arith", "-Wcast-qual", "-Wformat=2",
"-Wmissing-include-dirs", "-Wcast-align", "-Wctor-dtor-privacy",
"-Wdisabled-optimization", "-Winvalid-pch", "-Woverloaded-virtual",
"-Wconversion", "-Wundef", "-Wno-ctor-dtor-privacy", "-Wno-format-nonliteral",
"-Wno-dangling-else", "-Wno-unused-local-typedefs", "-Wdouble-promotion",
"-Wtrampolines", "-Wzero-as-null-pointer-constant", "-Wuseless-cast",
"-Wvector-operation-performance", "-Wsized-deallocation", "-Wshadow",
"-Wshift-overflow=2", "-Wnull-dereference", "-Wduplicated-cond"
])
fmt_env.Append(
CXXFLAGS=[
"-Wold-style-cast",
"-Wundef",
"-Wredundant-decls",
"-Wwrite-strings",
"-Wpointer-arith",
"-Wcast-qual",
"-Wformat=2",
"-Wmissing-include-dirs",
"-Wcast-align",
"-Wctor-dtor-privacy",
"-Wdisabled-optimization",
"-Winvalid-pch",
"-Woverloaded-virtual",
"-Wconversion",
"-Wundef",
"-Wno-ctor-dtor-privacy",
"-Wno-format-nonliteral",
"-Wno-dangling-else",
"-Wno-unused-local-typedefs",
"-Wdouble-promotion",
"-Wtrampolines",
"-Wzero-as-null-pointer-constant",
"-Wuseless-cast",
"-Wvector-operation-performance",
"-Wsized-deallocation",
"-Wshadow",
"-Wshift-overflow=2",
"-Wnull-dereference",
"-Wduplicated-cond",
]
)

include_path = "fmt/include"
source_path = "fmt/src"
Expand All @@ -103,7 +129,6 @@ def build_fmt(env):
Default(library)

include_dir = fmt_env.Dir(include_path)
source_dir = fmt_env.Dir(source_path)

env.fmt = {}
env.fmt["INCPATH"] = [include_dir]
Expand All @@ -119,6 +144,7 @@ def build_fmt(env):

env.exposed_includes += env.fmt["INCPATH"]


def build_range_v3(env):
include_path = "range-v3/include"
sources = env.GlobRecursive("*.cpp", [include_path])
Expand All @@ -137,6 +163,7 @@ def build_range_v3(env):

env.exposed_includes += env.range_v3["INCPATH"]


def build_vmcontainer(env):
vmcontainer_env = env.Clone()

Expand Down Expand Up @@ -167,8 +194,9 @@ def build_vmcontainer(env):

env.exposed_includes += env.vmcontainer["INCPATH"]


build_dryad(env)
build_fmt(env)
build_lexy(env)
build_range_v3(env)
build_vmcontainer(env)
build_vmcontainer(env)
4 changes: 3 additions & 1 deletion include/openvic-dataloader/Error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ namespace ovdl::error {
}

inline void AnnotatedError::push_back(AnnotationList p_annotations) {
if (p_annotations.empty()) return;
if (p_annotations.empty()) {
return;
}
insert_child_list_after(_last_annotation, p_annotations);
_last_annotation = p_annotations.back();
}
Expand Down
9 changes: 6 additions & 3 deletions include/openvic-dataloader/NodeLocation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ namespace ovdl {
void set_from(const BasicNodeLocation<OtherCharT>& other) {
if constexpr (sizeof(CharT) <= sizeof(OtherCharT)) {
_begin = reinterpret_cast<const CharT*>(other.begin());
if (other.begin() == other.end())
if (other.begin() == other.end()) {
_end = _begin;
else
} else {
_end = reinterpret_cast<const CharT*>(other.end()) + (sizeof(OtherCharT) - sizeof(CharT));
}
} else {
_begin = reinterpret_cast<const CharT*>(other.begin());
if (other.end() - other.begin() <= 0) {
Expand Down Expand Up @@ -60,7 +61,9 @@ namespace ovdl {

static BasicNodeLocation make_from(const char_type* begin, const char_type* end) {
end++;
if (begin >= end) return BasicNodeLocation(begin);
if (begin >= end) {
return BasicNodeLocation(begin);
}
return BasicNodeLocation(begin, end);
}
};
Expand Down
Loading