Skip to content

Add a simple CI: Build, code formatting and clang-tidy checks. #26

Add a simple CI: Build, code formatting and clang-tidy checks.

Add a simple CI: Build, code formatting and clang-tidy checks. #26

Workflow file for this run

name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
Build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazelcache_test
- name: Test
run: |
export CC=gcc-13
export CXX=g++-13
bazel test ...
MacOsBuild:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Dependencies
run: |
echo "USE_BAZEL_VERSION=6.5.0" >> $GITHUB_ENV

Check failure on line 42 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/ci.yml

Invalid workflow file

You have an error in your yaml syntax on line 42
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazelcache_mac_test
- name: Test
run: |
bazel test ...
CodeFormatting:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Dependencies
run: |
sudo apt-get install clang-format-15
go install github.com/bazelbuild/buildtools/buildifier@latest
echo "PATH=$PATH:$(go env GOPATH)/bin/" >> $GITHUB_ENV
- name: Run formatting style check
run: |
scripts/run-format.sh
git diff > /tmp/format-diff
if [ -s "/tmp/format-diff" ]; then
echo "Difference to optimal formatting"
cat /tmp/format-diff
echo
echo "=================== To Fix ==========================="
echo "Run scripts/run-format.sh"
echo "then"
echo " git commit -a --amend"
echo " git push -f"
exit 1
fi
ClangTidy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Cache Timestamp
id: cache_timestamp
uses: nanzm/[email protected]
with:
format: 'YYYY-MM-DD-HH-mm-ss'
- name: Mount clang-tidy cache
uses: actions/cache@v4
with:
path: |
~/.cache/clang-tidy
~/.cache/bazel
key: clang-tidy-cache
- name: Get latest clang-tidy
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 17
sudo apt-get install clang-tidy-17
- name: Build Compilation DB
run: |
scripts/make-compilation-db.sh
- name: Run clang-tidy
run: |
CLANG_TIDY=clang-tidy-17 scripts/run-clang-tidy-cached.cc