Skip to content

added sudo rights in ci #2

added sudo rights in ci

added sudo rights in ci #2

name: Build, Format, and Lint CI
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
setup-build-lint:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y check clang-format clang-tidy cmake
- name: Set up workspace
run: |
# Create workspace structure
mkdir -p ws/src ws/build ws/install
- run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
with:
path: "ws/src/${{ env.REPOSITORY_NAME }}/"
- name: Set up build
working-directory: ws
run: |
# Create build directory for the package
mkdir -p build/$REPOSITORY_NAME
# Navigate to the package-specific build directory
cd build/$REPOSITORY_NAME
- name: Configure and build
working-directory: ws/build/${{ env.REPOSITORY_NAME }}
run: |
# Configure with specified flags and set install prefix to install
cmake ../../src/$REPOSITORY_NAME \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_TESTS=ON \
-DCMAKE_INSTALL_PREFIX=../../install
# -DENABLE_DOC=ON \
# Build the package
cmake --build .
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit cmakelang[YAML]
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('**/.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-
- name: Run pre-commit checks
working-directory: ws
run: |
# cd to the package-specific directory
cd src/$REPOSITORY_NAME
pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks
# Run pre-commit checks
pre-commit run --show-diff-on-failure --color=always --all-files