diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..0d379fa --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,16 @@ +coverage: + range: 50..75 + round: up + precision: 2 + + status: + project: no + patch: yes + changes: no + +comment: + layout: "header, diff, changes, tree" + behavior: default + +ignore: + - "**/*-test.cpp" # ignore test harness code \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..138ea82 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,101 @@ +name: build + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + BUILD_TYPE: Release + +jobs: + linux: + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + compiler: + - { pkg: clang, exe: 'clang++', version: 18 } + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - run: pip install -U Jinja2 + + - name: Get CMake and Ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: 3.26.1 + ninjaVersion: 1.11.1 + + - name: Install Clang + run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{matrix.compiler.version}} main" + sudo apt update + sudo apt install -y ${{matrix.compiler.pkg}}-${{matrix.compiler.version}} libc++-dev libc++abi-dev + + - name: Install dependencies + run: | + sudo apt update + sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev wayland-protocols libwayland-dev libxkbcommon-dev + sudo apt install libgl-dev + + - name: Configure + env: + CC: ${{matrix.compiler.pkg}}-${{matrix.compiler.version}} + CXX: ${{matrix.compiler.exe}}-${{matrix.compiler.version}} + run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFLUX_GRAPHICS=OpenGL -DFLUX_ENABLE_LTO=NO -B ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} -G Ninja + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} --config ${{env.BUILD_TYPE}} + + windows: + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + os: [windows-latest] + compiler: + - { pkg: clang, exe: 'clang++', version: 18 } + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - run: pip install -U Jinja2 + + - name: Get CMake and Ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: 3.26.1 + ninjaVersion: 1.11.1 + + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v2 + with: + version: ${{matrix.compiler.version}} + + - name: Configure + env: + CC: ${{ matrix.compiler.pkg }} + CXX: ${{ matrix.compiler.exe }} + run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFLUX_GRAPHICS=OpenGL -DFLUX_ENABLE_LTO=NO -B ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} -G Ninja + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} --config ${{env.BUILD_TYPE}} diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..a221024 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,87 @@ +name: coverage + +on: [pull_request] + +env: + BUILD_TYPE: Debug + +jobs: + codecov: + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + compiler: + - { pkg: clang, exe: 'clang++', version: 18 } + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - run: pip install -U Jinja2 + + - name: Get CMake and Ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: 3.26.1 + ninjaVersion: 1.11.1 + + - name: Install Clang + run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{matrix.compiler.version}} main" + sudo apt update + sudo apt install -y llvm-${{matrix.compiler.version}} ${{matrix.compiler.pkg}}-${{matrix.compiler.version}} libc++-dev libc++abi-dev + + - name: Install dependencies + run: | + sudo apt update + sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev wayland-protocols libwayland-dev libxkbcommon-dev + sudo apt install libgl-dev + + - name: Configure + env: + CC: ${{matrix.compiler.pkg}}-${{matrix.compiler.version}} + CXX: ${{matrix.compiler.exe}}-${{matrix.compiler.version}} + run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFLUX_GRAPHICS=OpenGL -DFLUX_ENABLE_COVERAGE=ON -B ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} -G Ninja + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} --config ${{env.BUILD_TYPE}} + + - name: Run tests + working-directory: ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} + env: + CTEST_OUTPUT_ON_FAILURE: 1 + run: ctest --timeout 30 -C Debug -j4 + + - name: Index the raw profile + working-directory: ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} + run: | + llvm-profdata-${{matrix.compiler.version}} merge --output=coverage.profdata */default.profraw + + - name: Create a line-oriented coverage report + working-directory: ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} + run: | + object_files=$(find ./flux-*/ -type f -executable -not -path "./flux-playground/*") + object_list=("$object_files") + objects=$(for object in ${object_list}; do echo "-object=${object} "; done) + echo "$objects" + llvm-cov-${{matrix.compiler.version}} export -format=lcov -instr-profile=coverage.profdata ${objects} > coverage.lcov + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + directory: ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} + token: ${{secrets.CODECOV_TOKEN}} + files: ./coverage.lcov + flags: codecov + name: flux + fail_ci_if_error: true + verbose: true diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..bef3dc6 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,31 @@ +name: linter + +on: + push: + branches: [ "master" ] + paths: ['**.cpp', '**.hpp', '**.inl'] + pull_request: + branches: [ "master" ] + paths: ['**.cpp', '**.hpp', '**.inl'] + +jobs: + lint: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/checkout@v4 + + - uses: cpp-linter/cpp-linter-action@v2 + id: linter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + style: 'file' # Use .clang-format config file. + tidy-checks: '-*' # Disable clang-tidy checks. + # Only 'update' a single comment in a pull request's thread. + thread-comments: ${{ github.event_name == 'pull_request' && 'update' }} + + - name: Fail fast?! + if: steps.linter.outputs.clang-format-checks-failed > 0 + run: exit 1 \ No newline at end of file diff --git a/flux-playground/playground.cpp b/flux-playground/playground.cpp index 01b42eb..1e59f12 100644 --- a/flux-playground/playground.cpp +++ b/flux-playground/playground.cpp @@ -10,7 +10,8 @@ #include #include - +// Window dimensions +const GLuint WIDTH = 400, HEIGHT = 300; GLFWwindow* create_window(const char* name, int major, int minor) { std::cout << "Creating Window, OpenGL " << major << "." << minor << ": " << name << std::endl; @@ -27,9 +28,10 @@ GLFWwindow* create_window(const char* name, int major, int minor) { GladGLContext* create_context(GLFWwindow* window) { glfwMakeContextCurrent(window); - GladGLContext* context = reinterpret_cast(std::calloc(1, sizeof(GladGLContext))); + GladGLContext* context = + reinterpret_cast(std::calloc(1, sizeof(GladGLContext))); if (!context) - return NULL; + return nullptr; int version = gladLoadGLContext(context, glfwGetProcAddress); std::cout << "Loaded OpenGL " << GLAD_VERSION_MAJOR(version) << "." @@ -59,9 +61,6 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod glfwSetWindowShouldClose(window, GL_TRUE); } -// Window dimensions -const GLuint WIDTH = 400, HEIGHT = 300; - int main() { glfwInit();