Skip to content

Commit

Permalink
Added CI support (#4)
Browse files Browse the repository at this point in the history
* Added `CI` support

* Disable `LTO` temporarily for `Release` builds

* Added `linter` config
  • Loading branch information
akukh authored Apr 21, 2024
1 parent de378f9 commit 448249f
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -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
101 changes: 101 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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}}
87 changes: 87 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 5 additions & 6 deletions flux-playground/playground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include <cstdlib>
#include <iostream>


// 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;
Expand All @@ -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<GladGLContext*>(std::calloc(1, sizeof(GladGLContext)));
GladGLContext* context =
reinterpret_cast<GladGLContext*>(std::calloc(1, sizeof(GladGLContext)));
if (!context)
return NULL;
return nullptr;

int version = gladLoadGLContext(context, glfwGetProcAddress);
std::cout << "Loaded OpenGL " << GLAD_VERSION_MAJOR(version) << "."
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 448249f

Please sign in to comment.