Skip to content
Draft
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
36 changes: 5 additions & 31 deletions .github/workflows/run-tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Run Tests
name: Continuous Integration

on:
push:
pull_request:
branches:
- main
pull_request:
paths-ignore:
- 'docs/**'
push:
branches:
- main

workflow_dispatch:

jobs:
Expand All @@ -33,8 +34,6 @@ jobs:
include:
- PGVERSION: 14
TEST: tablespaces
- PGVERSION: 14
TEST: linting
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -43,38 +42,13 @@ jobs:
run: |
echo "PGVERSION=${{ matrix.PGVERSION }}" >> $GITHUB_ENV
echo "TEST=${{ matrix.TEST }}" >> $GITHUB_ENV
echo "LINTING=${{ matrix.LINTING }}" >> $GITHUB_ENV
echo "TRAVIS_BUILD_DIR=$(pwd)" >> $GITHUB_ENV

- name: Clone and install linting tools
if: ${{ env.TEST == 'linting' }}
run: |
sudo apt-get install python3-pip
pip3 install --user black
black --version
gcc --version
git clone -b v0.8.19 --depth 1 https://github.com/citusdata/tools.git ../tools
sudo make -C ../tools install
install_uncrustify
rm -rf uncrustify*

- name: Check code formatting and banned function
if: ${{ env.TEST == 'linting' }}
run: |
make lint

- name: Build documentation
if: ${{ env.TEST == 'linting' }}
run: |
make build-docs

- name: Build Docker Test Image
if: ${{ env.TEST != 'linting' }}
run: |
make build-test-image

- name: Run Test
if: ${{ env.TEST != 'linting' }}
timeout-minutes: 15
run: |
make ci-test
42 changes: 42 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build docs

env:
context: /docs
sphinx_image: hapostgres/sphinx-citus:latest

on:
pull_request:
branches:
- main
paths:
- 'docs/**'
- '!docs/tikz/**'
push:
branches:
- main
workflow_dispatch:

jobs:
docs:
name: Build sphinx html
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build hapostgres/sphinx-citus docker image
uses: docker/build-push-action@v5
with:
context: ".${{ env.context }}"
load: true
tags: ${{ env.sphinx_image }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build docs with sphinx
run: "docker run --rm -v .${{ env.context }}:/docs ${{ env.sphinx_image }} make html"
41 changes: 41 additions & 0 deletions .github/workflows/latex-pdftocairo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build pictures

env:
context: /docs/tikz
tikz_image: hapostgres/latexmk-pdftocairo:latest

on:
pull_request:
branches:
- main
paths:
- 'docs/tikz/**'
push:
branches:
- main
workflow_dispatch:

jobs:
pictures:
name: Building latexmk/pdftocairo pictures
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build hapostgres/latexmk-pdftocairo docker image
uses: docker/build-push-action@v5
with:
context: ".${{ env.context }}"
load: true
tags: ${{ env.tikz_image }}
cache-from: type=gha
cache-to: type=gha,mode=min

- name: Build pdf/png/svg files
run: "docker run --rm -v .${{ env.context }}:/tikz ${{ env.tikz_image }} make all"
39 changes: 39 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Code Linting/Checking

on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

jobs:
linting:
name: Run Linting and friends
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set environment variables
run: |
echo "TRAVIS_BUILD_DIR=$(pwd)" >> $GITHUB_ENV

- name: Clone and install linting tools
run: |
sudo apt-get install python3-pip
pip3 install --user black
black --version
gcc --version
git clone -b v0.8.19 --depth 1 https://github.com/citusdata/tools.git ../tools
sudo make -C ../tools install
install_uncrustify
rm -rf uncrustify*

- name: Check code formatting and banned function
run: |
make lint
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ docs/tikz/*.png
# Exclude our demo/test tmux directory
tmux/
valgrind/

# Exclude docker ID files
docker.id*
28 changes: 28 additions & 0 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG DEBIAN_TAG="bullseye-slim"

FROM debian:${DEBIAN_TAG} as python-slim

ARG DEBIAN_TAG

LABEL org.opencontainers.image.authors = "Data Bene <https://data-bene.io/>"
LABEL org.opencontainers.image.source = "https://github.com/hapostgres/pg_auto_failover/tree/main/docs/Dockerfile"
LABEL org.opencontainers.image.version = "${DEBIAN_TAG}"
LABEL org.opencontainers.image.licenses = "PostgreSQL License"
LABEL org.opencontainers.image.description = "A better python3 slim with pip"

RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
make \
python3-minimal \
python3-pip \
&& apt-get autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

FROM python-slim

WORKDIR /docs
COPY requirements.txt .
RUN python3 -m pip install --upgrade --no-cache-dir pip install -r requirements.txt

CMD ["python3", "--help"]
49 changes: 43 additions & 6 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Minimal makefile for Sphinx documentation
#
.DEFAULT_GOAL := all

# You can set these variables from the command line.
SPHINXOPTS =
Expand All @@ -8,13 +7,51 @@ SPHINXPROJ = pg_auto_failover
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
DEPS = $(wildcard *.rst) $(wildcard ref/*.rst)

# If USE_DOCKER variable is defined, we're working with docker and use the tools
# from image/container instead of current OS.
ifdef USE_DOCKER
SPHINX_IMAGE = hapostgres/sphinx-citus:latest
endif

.PHONY: all
all: tikz html

.PHONY: clean
clean:
rm -f docker.id
rm -rf _build _html
$(MAKE) -C tikz $@

.PHONY: maintainer-clean
maintainer-clean: clean
$(MAKE) -C tikz $@
ifdef USE_DOCKER
docker image rm $(SPHINX_IMAGE)
endif

ifdef USE_DOCKER
SPHINXBUILD = docker run --rm -u $(shell id -u):$(shell id -g) -v $(SOURCEDIR)/:/docs $(SPHINX_IMAGE) sphinx-build
docker.id: Dockerfile requirements.txt
docker build --iidfile docker.id --file $< -t $(SPHINX_IMAGE) .
else
docker.id: ;
endif

.PHONY: help
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile
.PHONY: html
html: $(BUILDDIR)/html

.PHONY: tikz
tikz:
$(MAKE) -C tikz all

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
$(BUILDDIR)/html: $(DEPS) docker.id
echo $?
$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, **options):
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_theme = "sphinx_rtd_theme_citus"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sphinx==4.0.2
Sphinx==5.3.0
sphinx_rtd_theme_citus==0.5.25
docutils==0.16
readthedocs-sphinx-search==0.1.0
readthedocs-sphinx-search==0.3.1
35 changes: 35 additions & 0 deletions docs/tikz/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ARG DEBIAN_TAG="bullseye-slim"

FROM debian:${DEBIAN_TAG} as luatex

ARG DEBIAN_TAG

LABEL org.opencontainers.image.authors = "Data Bene <https://data-bene.io/>"
LABEL org.opencontainers.image.source = "https://github.com/hapostgres/pg_auto_failover/tree/main/docs/tikz/Dockerfile"
LABEL org.opencontainers.image.version = "${DEBIAN_TAG}"
LABEL org.opencontainers.image.licenses = "PostgreSQL License"
LABEL org.opencontainers.image.description = "Docs builder with latexmk and pdftocairo"

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
make \
latexmk \
poppler-utils \
texlive \
texlive-luatex \
texlive-latex-extra \
texlive-fonts-extra \
&& apt-get autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

FROM luatex

WORKDIR /tikz

ENV TERM=dumb
ENV TEXMFHOME = /.cache/
ENV TEXMFVAR = /.cache/texmf-var/
ENV TEXMFCONFIG = $TEXMFSYSCONFIG

RUN luaotfload-tool --update
Loading