Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ permissions:
checks: write

jobs:
format:
runs-on: ubuntu-latest
container: debian:trixie
steps:
- name: Install tools
run: apt-get update && apt-get install -y --no-install-recommends ca-certificates git clang-format

- uses: actions/checkout@v4

- name: Check formatting
run: bash scripts/format.sh --check

build:
strategy:
fail-fast: false
Expand Down
28 changes: 25 additions & 3 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

FILES=$(rg --files -g '*.{h,hpp,cc,cpp,cxx}' include src tests tools)
REQUIRED_CF_VERSION=19

CF_BIN=${CF_BIN:-$(command -v clang-format-${REQUIRED_CF_VERSION} || command -v clang-format)}
CF_VERSION=$(${CF_BIN} --version | sed -n 's/.*version \([0-9]*\)\..*/\1/p' | head -1)
if [[ -z "${CF_VERSION}" ]]; then
echo "error: could not determine clang-format version" >&2
exit 1
fi
if [[ "${CF_VERSION}" -ne "${REQUIRED_CF_VERSION}" ]]; then
echo "error: clang-format ${REQUIRED_CF_VERSION} required, found ${CF_VERSION}" >&2
echo "Install clang-format ${REQUIRED_CF_VERSION}:" >&2
echo " Debian/Ubuntu: apt install clang-format-${REQUIRED_CF_VERSION} (or https://apt.llvm.org)" >&2
echo " macOS: brew install llvm@${REQUIRED_CF_VERSION}" >&2
echo " CentOS/RHEL: yum install clang-tools-extra-${REQUIRED_CF_VERSION}.0 (EPEL/AppStream)" >&2
exit 1
fi

FILES=$(find include src tests tools -name '*.h' -o -name '*.hpp' -o -name '*.cc' -o -name '*.cpp' -o -name '*.cxx')

if [[ -z "${FILES}" ]]; then
echo "No source files found."
exit 0
fi

echo "Formatting files..."
clang-format -i ${FILES}
if [[ "${1:-}" == "--check" ]]; then
echo "Checking formatting..."
${CF_BIN} --dry-run -Werror ${FILES}
else
echo "Formatting files..."
${CF_BIN} -i ${FILES}
fi
3 changes: 1 addition & 2 deletions src/admin/BuiltinRoutes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ void registerBuiltinRoutes(AdminServer& server) {
proxygen::ResponseBuilder(downstream)
.status(200, proxygen::HTTPMessage::getDefaultReason(200))
.header("Content-Type", "application/json")
.body(
folly::IOBuf::copyBuffer("{\"service\":\"o-rly\",\"version\":\"" ORLY_VERSION "\"}\n")
.body(folly::IOBuf::copyBuffer("{\"service\":\"o-rly\",\"version\":\"" ORLY_VERSION "\"}\n")
)
.sendWithEOM();
});
Expand Down