diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..3ad86d52 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# Copyright (c) 2024 Sebastian Pipping +# Licensed under the 3-Clause BSD License + +version: 2 +updates: + + - package-ecosystem: "github-actions" + commit-message: + include: "scope" + prefix: "Actions" + directory: "/" + labels: + - "enhancement" + schedule: + interval: "weekly" diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000..1facb497 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,86 @@ +# Copyright (c) 2024 Sebastian Pipping +# Licensed under the 3-Clause BSD License + +name: Build using CMake + +# Drop permissions to minimum for security +permissions: + contents: read + +on: + pull_request: + push: + schedule: + - cron: '0 3 * * 5' # Every Friday at 3am + workflow_dispatch: + +jobs: + build_cmake: + name: CMake (${{ matrix.runs-on }}, ${{ matrix.cc }}) + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + include: + # FUSE 3 on Linux + - cc: gcc-14 + clang_major_version: null + runs-on: ubuntu-24.04 + - cc: clang-18 + clang_major_version: 18 + runs-on: ubuntu-24.04 + # macFUSE on macOS + - cc: gcc-13 + clang_major_version: null + runs-on: macos-12 + - cc: clang-15 + clang_major_version: 15 + runs-on: macos-14 + + steps: + - name: Install build dependencies + if: "${{ runner.os == 'Linux' }}" + run: |- + sudo apt-get update + sudo apt-get install --yes --no-install-recommends \ + cmake \ + libfuse3-dev \ + pkg-config + + - name: Add versioned aliases for Clang ${{ matrix.clang_major_version }} + if: "${{ runner.os == 'macOS' && contains(matrix.cc, 'clang') }}" + run: |- + set -x + sudo ln -s "$(brew --prefix llvm@${{ matrix.clang_major_version }})"/bin/clang /usr/local/bin/clang-${{ matrix.clang_major_version }} + + - name: Install build dependencies + if: "${{ runner.os == 'macOS' }}" + run: |- + set -x + brew install --cask macfuse + + - name: Checkout Git branch + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + + - name: 'Configure with CMake' + run: |- + cmake_args=( + -DCMAKE_C_COMPILER="${{ matrix.cc }}" + -DCMAKE_C_FLAGS="-std=gnu99 -Wall -Wextra -pedantic -g -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" + -DCMAKE_{EXE,MODULE,SHARED}_LINKER_FLAGS="-g -fsanitize=address,undefined" + -S ./ + -B build/ + ) + set -x + cmake "${cmake_args[@]}" + + - name: 'Build' + run: |- + set -x + make -C build -j$(nproc) VERBOSE=1 + + - name: 'Install' + run: |- + set -x -o pipefail + make -C build install DESTDIR="${PWD}"/ROOT/ + find ROOT/ | sort | xargs ls -ld diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml new file mode 100644 index 00000000..ba79f5f9 --- /dev/null +++ b/.github/workflows/makefile.yml @@ -0,0 +1,77 @@ +# Copyright (c) 2024 Sebastian Pipping +# Licensed under the 3-Clause BSD License + +name: Build and test using Makefile + +# Drop permissions to minimum for security +permissions: + contents: read + +on: + pull_request: + push: + schedule: + - cron: '0 3 * * 5' # Every Friday at 3am + workflow_dispatch: + +jobs: + build_makefile: + name: Makefile (${{ matrix.runs-on }}, ${{ matrix.cc }}) + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + include: + - cc: gcc-10 + clang_major_version: null + runs-on: ubuntu-22.04 + - cc: clang-13 + clang_major_version: 13 + runs-on: ubuntu-22.04 + env: + CC: ${{ matrix.cc }} + CFLAGS: -std=gnu99 -Wall -Wextra -pedantic -g -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer + LDFLAGS: -g -fsanitize=address,undefined + steps: + - name: Install build dependencies + run: |- + sudo apt-get update + sudo apt-get install --yes --no-install-recommends \ + gcovr \ + libfuse3-dev \ + pkg-config \ + python3-pytest + + - name: Checkout Git branch + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + + - name: 'Build and test (without coverage)' + run: |- + set -x + export ASAN_OPTIONS=detect_leaks=0 # TODO fix memleaks and drop line + make test + + - name: 'Install' + run: |- + set -x -o pipefail + make install DESTDIR="${PWD}"/ROOT/ + find ROOT/ | sort | xargs ls -ld + rm -Rf ROOT/ + + - name: 'Clean (without coverage)' + run: |- + set -x + make clean + diff -u0 <(true) <(git ls-files --other --exclude-standard) + + - name: 'Build and test (with coverage)' + run: |- + set -x + export ASAN_OPTIONS=detect_leaks=0 # TODO fix memleaks and drop line + make test_coverage + + - name: 'Clean (with coverage)' + run: |- + set -x + make clean_coverage clean + diff -u0 <(true) <(git ls-files --other --exclude-standard) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 104904a4..00000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -sudo: required -dist: focal -language: python -python: - - "3.8" -before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq pkg-config fuse3 - - sudo modprobe fuse - - sudo chmod 666 /dev/fuse - - sudo chown root:$USER /etc/fuse.conf -install: - - sudo apt-get install cmake make gcc - - sudo apt-get install libfuse3-dev - #- sudo apt-get install meson ninja-build - #- ./travis_install.sh - #- cmake . - - make -script: ./test diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 898d04dd..7f370308 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,10 +4,10 @@ set(UNIONFS_SRCS unionfs.c opts.c debug.c findbranch.c readdir.c fuse_ops.c) set(UNIONFSCTL_SRCS unionfsctl.c) -SET(CMAKE_C_FLAGS "-pipe -W -Wall -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64") -SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") -SET(CMAKE_C_FLAGS_RELEASE "-O2") -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG") +SET(_COMMON_FLAGS "-pipe -W -Wall -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64") +SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g ${_COMMON_FLAGS}") +SET(CMAKE_C_FLAGS_RELEASE "-O2 ${_COMMON_FLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG ${_COMMON_FLAGS}") add_executable(unionfs ${UNIONFS_SRCS} ${HASHTABLE_SRCS})