diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a40c5b280..d97ad12a6 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -52,10 +52,8 @@ jobs: pip3 install --user black black --version gcc --version - git clone -b v0.8.31 --depth 1 https://github.com/citusdata/tools.git ../tools - sudo make -C ../tools install - install_uncrustify - rm -rf uncrustify* + # Install uncrustify the Citus way + make -C ci -f tools.mk tools - name: Check code formatting and banned function if: ${{ env.TEST == 'linting' }} diff --git a/Makefile b/Makefile index c23abed8b..7350ca429 100644 --- a/Makefile +++ b/Makefile @@ -191,7 +191,7 @@ endif .PHONY: indent indent: citus_indent - black . + black --exclude=ci/tools . # make lint; is an alias for make spellcheck # make linting; is an alias for make spellcheck @@ -203,7 +203,7 @@ lint linting: spellcheck ; .PHONY: spellcheck spellcheck: citus_indent --check - black --check . + black --exclude=ci/tools --check . ci/banned.h.sh # diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 000000000..67f445b15 --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,20 @@ +FROM debian:bullseye-slim + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential \ + ca-certificates \ + curl \ + git \ + gawk \ + make \ + cmake \ + python3 \ + sudo \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/src/pg_auto_failover/ci +COPY tools.mk ./ + +WORKDIR /usr/src/pg_auto_failover +RUN make -C ci -f tools.mk tools diff --git a/ci/tools.mk b/ci/tools.mk new file mode 100644 index 000000000..d7987d7b1 --- /dev/null +++ b/ci/tools.mk @@ -0,0 +1,27 @@ +# +# Install CI tools, mostly Citus style checker and linter for C code. +# +# See https://github.com/citusdata/citus/blob/main/STYLEGUIDE.md +# + +CITUS_TOOLS = https://github.com/citusdata/tools.git +UNCRUSTIFY = https://github.com/uncrustify/uncrustify/archive/uncrustify-0.68.1.tar.gz +UNCRUSTIFY_DIR = uncrustify-uncrustify-0.68.1 + +CMAKE_OPTS = -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + +tools: citus-tools ; + +mkdir: + mkdir tools + +uncrustify: mkdir + curl -L $(UNCRUSTIFY) | tar -C tools -xz + mkdir tools/$(UNCRUSTIFY_DIR)/build + cd tools/$(UNCRUSTIFY_DIR)/build && cmake $(CMAKE_OPTS) .. + make -C tools/$(UNCRUSTIFY_DIR)/build -j5 + sudo make -C tools/$(UNCRUSTIFY_DIR)/build install + +citus-tools: uncrustify + git clone --depth 1 $(CITUS_TOOLS) tools/tools + sudo make -C tools/tools uncrustify/.install