Skip to content

ci: simplify git ls-files (#373) #140

ci: simplify git ls-files (#373)

ci: simplify git ls-files (#373) #140

Workflow file for this run

name: C++ Lint CI
on:
push:
branches: [ main ]
pull_request:
env:
vcpkg_SHA: "dfcd4e4b30799c4ce02fe3939b62576fec444224"
jobs:
clang-tidy:
name: clang-tidy
runs-on: ubuntu-22.04
steps:
- name: install ninja
run: sudo apt install ninja-build clang-tidy-14
- uses: actions/checkout@v2
- name: clone-vcpkg
working-directory: "${{runner.temp}}"
run: >
mkdir -p vcpkg &&
curl -sSL "https://github.com/microsoft/vcpkg/archive/${{env.vcpkg_SHA}}.tar.gz" |
tar -C vcpkg --strip-components=1 -zxf -
- name: cache-vcpkg
id: cache-vcpkg
uses: actions/cache@v2
with:
# Preserve the vcpkg binary *and* the vcpkg binary cache in the build cache
path: |
~/.cache/vcpkg
~/.cache/bin
key: |
vcpkg-${{ env.vcpkg_SHA }}-style-clang-tidy-${{ hashFiles('vcpkg.json') }}
restore-keys: |
vcpkg-${{ env.vcpkg_SHA }}-style-clang-tidy-
- name: boostrap-vcpkg
run: ci/restore-vcpkg-from-cache.sh "${{runner.temp}}/vcpkg"
- name: configure
run: >
cmake -S . -B "${{runner.temp}}/build"
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_TOOLCHAIN_FILE="${{runner.temp}}/vcpkg/scripts/buildsystems/vcpkg.cmake"
- name: tidy
run: >
git ls-files -z -- '*.cc' |
xargs --verbose -P 2 -n 1 -0 clang-tidy-14 -p="${{runner.temp}}/build"
werror-build:
# Using a blank name produces better output on
# the web UI than any other alternative we tried.
name: " "
runs-on: ubuntu-22.04
strategy:
matrix:
compiler: [
{"cxx": "clang++-14", "cc": "clang-14"},
{"cxx": "g++-11", "cc": "gcc-11" },
]
steps:
- name: install ninja
run: sudo apt install ninja-build
- uses: actions/checkout@v2
- name: clone-vcpkg
working-directory: "${{runner.temp}}"
run: >
mkdir -p vcpkg &&
curl -sSL "https://github.com/microsoft/vcpkg/archive/${{env.vcpkg_SHA}}.tar.gz" |
tar -C vcpkg --strip-components=1 -zxf -
- name: cache-vcpkg
id: cache-vcpkg
uses: actions/cache@v2
with:
# Preserve the vcpkg binary *and* the vcpkg binary cache in the build cache
path: |
~/.cache/vcpkg
~/.cache/bin
key: |
vcpkg-${{ env.vcpkg_SHA }}-werror-${{ matrix.compiler.cxx }}-${{ hashFiles('vcpkg.json') }}
restore-keys: |
vcpkg-${{ env.vcpkg_SHA }}-werror-${{ matrix.compiler.cxx }}-
- name: boostrap-vcpkg
run: ci/restore-vcpkg-from-cache.sh "${{runner.temp}}/vcpkg"
- name: compiler=${{matrix.sanitizer}} / configure
run: >
cmake -S . -B "${{runner.temp}}/build" -GNinja
-DFUNCTIONS_FRAMEWORK_CPP_ENABLE_WERROR=ON
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DCMAKE_C_COMPILER=${{matrix.compiler.cc}}
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_TOOLCHAIN_FILE="${{runner.temp}}/vcpkg/scripts/buildsystems/vcpkg.cmake"
- name: compiler=${{matrix.compiler.cxx}} / build
run: cmake --build "${{runner.temp}}/build"
- name: compiler=${{matrix.compiler.cxx}} / test
working-directory: "${{runner.temp}}/build"
run: ctest --output-on-failure --timeout=60s
clang-format:
name: clang-format
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: >
git ls-files -z -- '*.h' '*.cc' |
xargs -P 2 -n 50 -0 clang-format-14 -i
- name: check-diff
run: git diff --ignore-submodules=all --color --exit-code .
cmake-format:
name: cmake-format
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: install cmake-format
run: pip install cmakelang==0.6.13
- name: cmake-format
run: >
git ls-files -z -- '*.cmake' '**/CMakeLists.txt' ./CMakeLists.txt |
xargs -P 2 -n 1 -0 /home/runner/.local/bin/cmake-format -i
- name: check-diff
run: git diff --ignore-submodules=all --color --exit-code .
generated-files:
name: generated-files
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: install ninja
run: sudo apt install moreutils
- name: regenerate-build-examples
run: >
./ci/generate-build-examples.sh >ci/build-examples.yaml
- name: update-markdown-code-snippets
run: >
./ci/update-markdown-code-snippets.sh
- name: check-diff
run: git diff --ignore-submodules=all --color --exit-code .