From 75ef830c80b0edcbd3604eb013497e1792dfca69 Mon Sep 17 00:00:00 2001 From: William Ayd Date: Thu, 5 Sep 2024 11:25:48 -0400 Subject: [PATCH] chore(ci): Add Meson build with Werror (#448) 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. --- .github/workflows/build-and-test.yaml | 32 +++++++++++++ .github/workflows/meson-build.yaml | 66 --------------------------- ci/scripts/build-with-meson.sh | 3 +- meson.build | 14 +++++- src/nanoarrow/common/array_test.cc | 4 ++ src/nanoarrow/common/buffer_test.cc | 5 +- src/nanoarrow/common/schema_test.cc | 2 + src/nanoarrow/common/utils_test.cc | 4 ++ src/nanoarrow/device/device.c | 1 + subprojects/flatcc.wrap | 8 ++-- 10 files changed, 63 insertions(+), 76 deletions(-) delete mode 100644 .github/workflows/meson-build.yaml diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 143a53ca7..d0c0494c5 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -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 diff --git a/.github/workflows/meson-build.yaml b/.github/workflows/meson-build.yaml deleted file mode 100644 index 926c18ead..000000000 --- a/.github/workflows/meson-build.yaml +++ /dev/null @@ -1,66 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -name: Meson Build Testing - -on: - schedule: - - cron: '5 0 * * 0' - pull_request: - branches: - - main - paths: - - '**meson.build' - - 'meson.options' - - '.github/workflows/meson-build.yaml' - - 'ci/scripts/build-with-meson.sh' - -permissions: - contents: read - -jobs: - 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 }}-1 - - - name: Build Arrow C++ - if: steps.cache-arrow-build.outputs.cache-hit != 'true' - shell: bash - run: | - ci/scripts/build-arrow-cpp-minimal.sh 15.0.2 arrow - - - name: Run meson testing script - run: | - PKG_CONFIG_PATH="$(pwd)/arrow/lib/pkgconfig" ci/scripts/build-with-meson.sh diff --git a/ci/scripts/build-with-meson.sh b/ci/scripts/build-with-meson.sh index d8c2cf1bd..e2330aba9 100755 --- a/ci/scripts/build-with-meson.sh +++ b/ci/scripts/build-with-meson.sh @@ -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}" @@ -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" diff --git a/meson.build b/meson.build index f7475208c..eec773f0e 100644 --- a/meson.build +++ b/meson.build @@ -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') @@ -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') diff --git a/src/nanoarrow/common/array_test.cc b/src/nanoarrow/common/array_test.cc index b41ba9d27..dec7366fa 100644 --- a/src/nanoarrow/common/array_test.cc +++ b/src/nanoarrow/common/array_test.cc @@ -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::max() / sizeof(void*)), ENOMEM); +#endif ArrowArrayRelease(&array); ASSERT_EQ(ArrowArrayInitFromType(&array, NANOARROW_TYPE_STRUCT), NANOARROW_OK); @@ -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::max() / sizeof(void*)), ENOMEM); +#endif EXPECT_EQ(ArrowArrayViewAllocateChildren(&array_view, 2), NANOARROW_OK); EXPECT_EQ(array_view.n_children, 2); diff --git a/src/nanoarrow/common/buffer_test.cc b/src/nanoarrow/common/buffer_test.cc index 41775e834..e294d8f1a 100644 --- a/src/nanoarrow/common/buffer_test.cc +++ b/src/nanoarrow/common/buffer_test.cc @@ -156,9 +156,6 @@ TEST(BufferTest, BufferTestFill) { } ArrowBufferReset(&buffer); - - EXPECT_EQ(ArrowBufferAppendFill(&buffer, 0, std::numeric_limits::max()), - ENOMEM); } TEST(BufferTest, BufferTestResize0) { @@ -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::max(), false), ENOMEM); +#endif ASSERT_EQ(ArrowBufferAppend(&buffer, "abcd", 4), NANOARROW_OK); EXPECT_EQ(ArrowBufferSetAllocator(&buffer, ArrowBufferAllocatorDefault()), EINVAL); diff --git a/src/nanoarrow/common/schema_test.cc b/src/nanoarrow/common/schema_test.cc index 175ea993a..a6a2ea5b8 100644 --- a/src/nanoarrow/common/schema_test.cc +++ b/src/nanoarrow/common/schema_test.cc @@ -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::max() / sizeof(void*)), ENOMEM); +#endif ArrowSchemaRelease(&schema); } diff --git a/src/nanoarrow/common/utils_test.cc b/src/nanoarrow/common/utils_test.cc index 6a753da03..e42990c44 100644 --- a/src/nanoarrow/common/utils_test.cc +++ b/src/nanoarrow/common/utils_test.cc @@ -150,6 +150,7 @@ TEST(AllocatorTest, AllocatorTestDefault) { allocator.free(&allocator, buffer, 100); +#if !defined(__SANITIZE_ADDRESS__) buffer = allocator.reallocate(&allocator, nullptr, 0, std::numeric_limits::max()); EXPECT_EQ(buffer, nullptr); @@ -157,6 +158,7 @@ TEST(AllocatorTest, AllocatorTestDefault) { buffer = allocator.reallocate(&allocator, buffer, 0, std::numeric_limits::max()); EXPECT_EQ(buffer, nullptr); +#endif } // In a non-trivial test this struct could hold a reference to an object @@ -239,6 +241,7 @@ 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::max()); EXPECT_EQ(buffer, nullptr); @@ -246,6 +249,7 @@ TEST(AllocatorTest, AllocatorTestMemoryPool) { buffer = arrow_allocator.reallocate(&arrow_allocator, buffer, 0, std::numeric_limits::max()); EXPECT_EQ(buffer, nullptr); +#endif } TEST(DecimalTest, Decimal128Test) { diff --git a/src/nanoarrow/device/device.c b/src/nanoarrow/device/device.c index 352db2537..3d2f07af6 100644 --- a/src/nanoarrow/device/device.c +++ b/src/nanoarrow/device/device.c @@ -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(); } diff --git a/subprojects/flatcc.wrap b/subprojects/flatcc.wrap index 811cf38c9..fdabe179d 100644 --- a/subprojects/flatcc.wrap +++ b/subprojects/flatcc.wrap @@ -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]