Skip to content

Commit

Permalink
chore(ci): Add Meson build with Werror (#448)
Browse files Browse the repository at this point in the history
This should be a relatively easy way to enforce -Werror in CI; moved the
Meson build from a scheduled job to be part of the normal CI runs.
  • Loading branch information
WillAyd authored Sep 5, 2024
1 parent 9aa1414 commit 75ef830
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 76 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,35 @@ jobs:
with:
name: nanoarrow-memcheck
path: build/Testing/Temporary/MemoryChecker.*.log

verify-meson:
name: meson-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
run: |
sudo apt-get update && sudo apt-get install -y lcov ninja-build valgrind
- name: Install meson
run: |
python3 -m pip install meson
- name: Cache Arrow C++ Build
id: cache-arrow-build
uses: actions/cache@v4
with:
path: arrow
# Bump the number at the end of this line to force a new Arrow C++ build
key: arrow-${{ runner.os }}-${{ runner.arch }}-2

- name: Build Arrow C++
if: steps.cache-arrow-build.outputs.cache-hit != 'true'
shell: bash
run: |
ci/scripts/build-arrow-cpp-minimal.sh 16.0.0 arrow
- name: Run meson testing script
run: |
PKG_CONFIG_PATH="$(pwd)/arrow/lib/pkgconfig" ci/scripts/build-with-meson.sh
66 changes: 0 additions & 66 deletions .github/workflows/meson-build.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions ci/scripts/build-with-meson.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function main() {
mkdir "${SANDBOX_DIR}"

show_header "Compile project with meson"
meson setup "${SANDBOX_DIR}" --pkg-config-path $PKG_CONFIG_PATH
meson setup "${SANDBOX_DIR}" --pkg-config-path $PKG_CONFIG_PATH -Dwerror=true

pushd "${SANDBOX_DIR}"

Expand All @@ -76,7 +76,6 @@ function main() {
-Db_coverage=false

meson compile
export ASAN_OPTIONS=allocator_may_return_null=1 # allow ENOMEM tests
meson test --print-errorlogs

show_header "Run valgrind test suite"
Expand Down
14 changes: 13 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ project(
# add_project_arguments(['-fvisibility=hidden'], language: 'cpp')
# endif

cc = meson.get_compiler('c')
add_project_arguments(
cc.get_supported_arguments(['-Wno-misleading-indentation']),
language : 'c'
)
cpp = meson.get_compiler('cpp')
add_project_arguments(
cpp.get_supported_arguments(['-Wno-misleading-indentation']),
language : 'cpp'
)

nanoarrow_dep_args = []
if host_machine.system() == 'windows' and get_option('default_library') == 'shared'
add_project_arguments(['-DNANOARROW_BUILD_DLL', '-DNANOARROW_EXPORT_DLL'], language: 'c')
Expand Down Expand Up @@ -161,7 +172,8 @@ if get_option('tests')
# Similarly code coverage has a built in option users should use instead
# https://mesonbuild.com/Unit-tests.html#coverage

arrow_dep = dependency('arrow')
# The system include suppresses compilation warnings from Arrow
arrow_dep = dependency('arrow', include_type: 'system')
gtest_dep = dependency('gtest_main')
gmock_dep = dependency('gmock')

Expand Down
4 changes: 4 additions & 0 deletions src/nanoarrow/common/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ TEST(ArrayTest, ArrayTestAllocateChildren) {
ArrowArrayRelease(&array);

ASSERT_EQ(ArrowArrayInitFromType(&array, NANOARROW_TYPE_STRUCT), NANOARROW_OK);
#if !defined(__SANITIZE_ADDRESS__)
EXPECT_EQ(ArrowArrayAllocateChildren(
&array, std::numeric_limits<int64_t>::max() / sizeof(void*)),
ENOMEM);
#endif
ArrowArrayRelease(&array);

ASSERT_EQ(ArrowArrayInitFromType(&array, NANOARROW_TYPE_STRUCT), NANOARROW_OK);
Expand Down Expand Up @@ -2303,9 +2305,11 @@ TEST(ArrayTest, ArrayViewTestStruct) {
EXPECT_EQ(array_view.layout.element_size_bits[0], 1);

// Expect error for out-of-memory
#if !defined(__SANITIZE_ADDRESS__)
EXPECT_EQ(ArrowArrayViewAllocateChildren(
&array_view, std::numeric_limits<int64_t>::max() / sizeof(void*)),
ENOMEM);
#endif

EXPECT_EQ(ArrowArrayViewAllocateChildren(&array_view, 2), NANOARROW_OK);
EXPECT_EQ(array_view.n_children, 2);
Expand Down
5 changes: 2 additions & 3 deletions src/nanoarrow/common/buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ TEST(BufferTest, BufferTestFill) {
}

ArrowBufferReset(&buffer);

EXPECT_EQ(ArrowBufferAppendFill(&buffer, 0, std::numeric_limits<int64_t>::max()),
ENOMEM);
}

TEST(BufferTest, BufferTestResize0) {
Expand All @@ -184,8 +181,10 @@ TEST(BufferTest, BufferTestResize0) {
TEST(BufferTest, BufferTestError) {
struct ArrowBuffer buffer;
ArrowBufferInit(&buffer);
#if !defined(__SANITIZE_ADDRESS__)
EXPECT_EQ(ArrowBufferResize(&buffer, std::numeric_limits<int64_t>::max(), false),
ENOMEM);
#endif

ASSERT_EQ(ArrowBufferAppend(&buffer, "abcd", 4), NANOARROW_OK);
EXPECT_EQ(ArrowBufferSetAllocator(&buffer, ArrowBufferAllocatorDefault()), EINVAL);
Expand Down
2 changes: 2 additions & 0 deletions src/nanoarrow/common/schema_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ TEST(SchemaTest, SchemaInit) {
EXPECT_EQ(schema.release, nullptr);

ASSERT_EQ(ArrowSchemaInitFromType(&schema, NANOARROW_TYPE_UNINITIALIZED), NANOARROW_OK);
#if !defined(__SANITIZE_ADDRESS__)
EXPECT_EQ(ArrowSchemaAllocateChildren(
&schema, std::numeric_limits<int64_t>::max() / sizeof(void*)),
ENOMEM);
#endif
ArrowSchemaRelease(&schema);
}

Expand Down
4 changes: 4 additions & 0 deletions src/nanoarrow/common/utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,15 @@ TEST(AllocatorTest, AllocatorTestDefault) {

allocator.free(&allocator, buffer, 100);

#if !defined(__SANITIZE_ADDRESS__)
buffer =
allocator.reallocate(&allocator, nullptr, 0, std::numeric_limits<int64_t>::max());
EXPECT_EQ(buffer, nullptr);

buffer =
allocator.reallocate(&allocator, buffer, 0, std::numeric_limits<int64_t>::max());
EXPECT_EQ(buffer, nullptr);
#endif
}

// In a non-trivial test this struct could hold a reference to an object
Expand Down Expand Up @@ -239,13 +241,15 @@ TEST(AllocatorTest, AllocatorTestMemoryPool) {
arrow_allocator.free(&arrow_allocator, buffer, 100);
EXPECT_EQ(CustomMemoryPool::GetInstance()->bytes_allocated, allocated0);

#if !defined(__SANITIZE_ADDRESS__)
buffer = arrow_allocator.reallocate(&arrow_allocator, nullptr, 0,
std::numeric_limits<int64_t>::max());
EXPECT_EQ(buffer, nullptr);

buffer = arrow_allocator.reallocate(&arrow_allocator, buffer, 0,
std::numeric_limits<int64_t>::max());
EXPECT_EQ(buffer, nullptr);
#endif
}

TEST(DecimalTest, Decimal128Test) {
Expand Down
1 change: 1 addition & 0 deletions src/nanoarrow/device/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ void ArrowDeviceInitCpu(struct ArrowDevice* device) {
}

struct ArrowDevice* ArrowDeviceResolve(ArrowDeviceType device_type, int64_t device_id) {
NANOARROW_UNUSED(device_id);
if (device_type == ARROW_DEVICE_CPU) {
return ArrowDeviceCpu();
}
Expand Down
8 changes: 4 additions & 4 deletions subprojects/flatcc.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# under the License.

[wrap-file]
directory = flatcc-0.6.1
source_url = https://github.com/dvidelabs/flatcc/archive/refs/tags/v0.6.1.tar.gz
source_filename = flatcc-0.6.1.tar.gz
source_hash = 2533c2f1061498499f15acc7e0937dcf35bc68e685d237325124ae0d6c600c2b
directory = flatcc-fd3c4ae5cd39f0651eda6a3a1a374278070135d6
source_url = https://github.com/dvidelabs/flatcc/archive/fd3c4ae5cd39f0651eda6a3a1a374278070135d6.tar.gz
source_filename = flatcc-fd3c4ae5cd39f0651eda6a3a1a374278070135d6.tar.gz
source_hash = 353cb04a619865383b87c8077eb39b63b01a3fc44f7bebd558a88f139c6b6f77
patch_directory = flatcc

[provide]
Expand Down

0 comments on commit 75ef830

Please sign in to comment.