Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI #19

Merged
merged 12 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Github CI config
# Inspired by https://github.com/libcpr/cpr/blob/master/.github/workflows/ci.yml
# Runs: clang format check, g++ & clang, release & debug, on Fedora

name: OSTree-TUI CI

on: [push, workflow_dispatch, pull_request]

env:
# standard dependencies for building & project
BUILD_DEPENDENCIES: "gcc-c++ clang git gcc gdb make cmake automake autoconf"
OSTREE_TUI_DEPENDENCIES: "glib2-devel gtk-doc ostree-devel libtool bison liblzf e2fsprogs-devel xz-devel gpgme-devel fuse-devel"
forgottosave marked this conversation as resolved.
Show resolved Hide resolved

jobs:
fedora-clang:
strategy:
matrix:
container: ["fedora:latest"]
buildType: [Debug, Release]
runs-on: ubuntu-latest
container: ${{ matrix.container }}
forgottosave marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Update package list
run: dnf update -y
- name: Install Dependencies
run: |
sudo dnf install -y ${{ env.BUILD_DEPENDENCIES }}
sudo dnf install -y ${{ env.OSTREE_TUI_DEPENDENCIES }}
- name: Checkout
uses: actions/checkout@v3
- name: "Build" # & Test"
env:
CPR_BUILD_TESTS: OFF # ON
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
source-dir: ${{ github.workspace }}
cc: clang
cxx: clang++
build-type: Release
run-test: false # true
ctest-options: ${{ env.CTEST_OPTIONS }}

fedora-gcc:
strategy:
matrix:
container: ["fedora:latest"]
buildType: [Debug, Release]
runs-on: ubuntu-latest
container: ${{ matrix.container }}
forgottosave marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Update package list
run: dnf update -y
- name: Install Dependencies
run: |
sudo dnf install -y ${{ env.BUILD_DEPENDENCIES }}
sudo dnf install -y ${{ env.OSTREE_TUI_DEPENDENCIES }}
- name: Checkout
uses: actions/checkout@v3
- name: "Build" # & Test"
env:
CPR_BUILD_TESTS: OFF # ON
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
source-dir: ${{ github.workspace }}
cc: gcc
cxx: g++
build-type: ${{ matrix.buildType }}
run-test: false # true
ctest-options: ${{ env.CTEST_OPTIONS }}
COM8 marked this conversation as resolved.
Show resolved Hide resolved

fedora-gcc-sanitizer:
strategy:
matrix:
buildType: [UdefSan, LeakSan, AddrSan, ThreadSan]
runs-on: ubuntu-latest
container: "fedora:latest"
steps:
- name: Update package list
run: dnf update -y
- name: Install Dependencies
run: |
sudo dnf install -y ${{ env.BUILD_DEPENDENCIES }}
sudo dnf install -y ${{ env.OSTREE_TUI_DEPENDENCIES }}
sudo dnf install -y libasan libubsan liblsan libtsan
- name: Checkout
uses: actions/checkout@v3
- name: "Build" # & Test
env:
CPR_BUILD_TESTS: OFF
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
source-dir: ${{ github.workspace }}
cc: gcc
cxx: g++
build-type: ${{ matrix.buildType }}
run-test: false # true
ctest-options: ${{ env.CTEST_OPTIONS }}

clang-tidy:
strategy:
matrix:
container: ["fedora:latest"]
buildType: [Debug]
runs-on: ubuntu-latest
container: ${{ matrix.container }}
forgottosave marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Update package list
run: sudo dnf update -y
- name: Install dependencies
run: |
sudo dnf install -y cmake git gcc-c++ clang ninja-build automake autoconf clang-tools-extra
sudo dnf install -y ${{ env.OSTREE_TUI_DEPENDENCIES }}
- name: Checkout
uses: actions/checkout@v3
- name: "Build Debug" # & Test"
env:
CPR_BUILD_TESTS: OFF # ON
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{github.workspace}}/build
source-dir: ${{github.workspace}}
cc: clang
cxx: clang++
build-type: ${{ matrix.buildType }}
run-test: false
configure-options: -DCPR_ENABLE_LINTING=ON

clang-format:
runs-on: ubuntu-latest
container: fedora:latest
steps:
- name: Update package list
run: sudo dnf update -y
- name: Install clang-format
run: sudo dnf install -y clang-tools-extra
- name: Checkout
uses: actions/checkout@v3
- name: Check format
run: bash scripts/check_clang_format.sh

cppcheck:
strategy:
matrix:
container: ["fedora:latest"]
buildType: [Release]
runs-on: ubuntu-latest
container: ${{ matrix.container }}
forgottosave marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Update package list
run: dnf update -y
- name: Install Dependencies
run: |
sudo dnf install -y ${{ env.BUILD_DEPENDENCIES }}
sudo dnf install -y ${{ env.OSTREE_TUI_DEPENDENCIES }}
sudo dnf install -y cppcheck
forgottosave marked this conversation as resolved.
Show resolved Hide resolved
- name: Checkout
uses: actions/checkout@v3
- name: "Build"
env:
CPR_BUILD_TESTS: OFF
CPR_ENABLE_CPPCHECK: ON
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
source-dir: ${{ github.workspace }}
cc: gcc
cxx: g++
build-type: ${{ matrix.buildType }}
run-test: false
44 changes: 44 additions & 0 deletions scripts/check_clang_format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Based on: https://gist.github.com/leilee/1d0915a583f8f29414cc21cd86e7151b
# Checks if all files are formatted based on the clang-format formatting rules.
# Execute as follows:
# ./scripts/check_clang_format.sh src

printf "📑 Checking if your code fulfills all clang-format rules...\n"

RET_CODE=0

function format() {
for f in $(find $@ -name '*.h' -or -name '*.hpp' -or -name '*.c' -or -name '*.cpp'); do
clang-format -i --dry-run --Werror --style=file ${f};
ret=$?
if [ $ret -ne 0 ]; then
RET_CODE=$ret
fi
done

echo "~~~ $@ directory checked ~~~";
}

# Check all of the arguments first to make sure they're all directories
for dir in "$@"; do
if [ ! -d "${dir}" ]; then
echo "${dir} is not a directory";
else
format ${dir};
fi
done

RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

if [ $RET_CODE -eq 0 ]; then
printf "✅ ${GREEN}Everything up to standard :party: ${NC}\n"
else
printf "❌ ${RED}Not up to formatting standard :sad_face: ${NC}\n"
echo "Try running run_clang_format.sh to format all files."
fi

exit $RET_CODE
30 changes: 30 additions & 0 deletions scripts/run_clang_format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Based on: https://gist.github.com/leilee/1d0915a583f8f29414cc21cd86e7151b
# Run from the project root directory as follows:
# ./scripts/run_clang_format.sh tests

printf "📝 Running clang-format...\n"

function format() {
for f in $(find $@ -name '*.h' -or -name '*.hpp' -or -name '*.c' -or -name '*.cpp'); do
echo "format ${f}";
clang-format -i --style=file ${f};
done

echo "~~~ $@ directory formatted ~~~";
}

# Check all of the arguments first to make sure they're all directories
for dir in "$@"; do
if [ ! -d "${dir}" ]; then
echo "${dir} is not a directory";
else
format ${dir};
fi
done

GREEN='\033[0;32m'
NC='\033[0m'

printf "✅ ${GREEN}Done. All files were formatted (if required).${NC}\n"