Skip to content

Commit cc28349

Browse files
committed
GHA & Rework docs Makefiles and related Dockerfiles
the main point here is to allow faster builds and regression testing. So instead of building container image with pgaf source code included we build more specialized images without source code. We then pass USE_DOCKER=1 to make in order to trigger building stages in docker, like this: ``` cd docs make USE_DOCKER=1 all ``` Also split the GHA workflow to select only jobs relevant given files changes. For PR: * no ci for docs changes * no docs for !docs changes * no latex for docs changes * latex only for tikz changes * linting alwauys For push: all run, no exception
1 parent f9f4bc5 commit cc28349

File tree

11 files changed

+280
-52
lines changed

11 files changed

+280
-52
lines changed
Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
name: Run Tests
1+
name: Continuous Integration
22

33
on:
4-
push:
4+
pull_request:
55
branches:
66
- main
7-
pull_request:
7+
paths-ignore:
8+
- 'docs/**'
9+
push:
810
branches:
911
- main
10-
1112
workflow_dispatch:
1213

1314
jobs:
@@ -33,8 +34,6 @@ jobs:
3334
include:
3435
- PGVERSION: 14
3536
TEST: tablespaces
36-
- PGVERSION: 14
37-
TEST: linting
3837
steps:
3938
- name: Checkout repository
4039
uses: actions/checkout@v3
@@ -43,38 +42,13 @@ jobs:
4342
run: |
4443
echo "PGVERSION=${{ matrix.PGVERSION }}" >> $GITHUB_ENV
4544
echo "TEST=${{ matrix.TEST }}" >> $GITHUB_ENV
46-
echo "LINTING=${{ matrix.LINTING }}" >> $GITHUB_ENV
4745
echo "TRAVIS_BUILD_DIR=$(pwd)" >> $GITHUB_ENV
4846
49-
- name: Clone and install linting tools
50-
if: ${{ env.TEST == 'linting' }}
51-
run: |
52-
sudo apt-get install python3-pip
53-
pip3 install --user black
54-
black --version
55-
gcc --version
56-
git clone -b v0.8.19 --depth 1 https://github.com/citusdata/tools.git ../tools
57-
sudo make -C ../tools install
58-
install_uncrustify
59-
rm -rf uncrustify*
60-
61-
- name: Check code formatting and banned function
62-
if: ${{ env.TEST == 'linting' }}
63-
run: |
64-
make lint
65-
66-
- name: Build documentation
67-
if: ${{ env.TEST == 'linting' }}
68-
run: |
69-
make build-docs
70-
7147
- name: Build Docker Test Image
72-
if: ${{ env.TEST != 'linting' }}
7348
run: |
7449
make build-test-image
7550
7651
- name: Run Test
77-
if: ${{ env.TEST != 'linting' }}
7852
timeout-minutes: 15
7953
run: |
8054
make ci-test

.github/workflows/docs.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build docs
2+
3+
env:
4+
context: /docs
5+
sphinx_image: hapostgres/sphinx-citus:latest
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- main
11+
paths:
12+
- 'docs/**'
13+
- '!docs/tikz/**'
14+
push:
15+
branches:
16+
- main
17+
workflow_dispatch:
18+
19+
jobs:
20+
docs:
21+
name: Build sphinx html
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: true
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Build hapostgres/sphinx-citus docker image
33+
uses: docker/build-push-action@v5
34+
with:
35+
context: ".${{ env.context }}"
36+
load: true
37+
tags: ${{ env.sphinx_image }}
38+
cache-from: type=gha
39+
cache-to: type=gha,mode=max
40+
41+
- name: Build docs with sphinx
42+
run: "docker run --rm -v .${{ env.context }}:/docs ${{ env.sphinx_image }} make html"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build pictures
2+
3+
env:
4+
context: /docs/tikz
5+
tikz_image: hapostgres/latexmk-pdftocairo:latest
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- main
11+
paths:
12+
- 'docs/tikz/**'
13+
push:
14+
branches:
15+
- main
16+
workflow_dispatch:
17+
18+
jobs:
19+
pictures:
20+
name: Building latexmk/pdftocairo pictures
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: true
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Build hapostgres/latexmk-pdftocairo docker image
32+
uses: docker/build-push-action@v5
33+
with:
34+
context: ".${{ env.context }}"
35+
load: true
36+
tags: ${{ env.tikz_image }}
37+
cache-from: type=gha
38+
cache-to: type=gha,mode=min
39+
40+
- name: Build pdf/png/svg files
41+
run: "docker run --rm -v .${{ env.context }}:/tikz ${{ env.tikz_image }} make all"

.github/workflows/linting.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Code Linting/Checking
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
linting:
14+
name: Run Linting and friends
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: true
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: Set environment variables
23+
run: |
24+
echo "TRAVIS_BUILD_DIR=$(pwd)" >> $GITHUB_ENV
25+
26+
- name: Clone and install linting tools
27+
run: |
28+
sudo apt-get install python3-pip
29+
pip3 install --user black
30+
black --version
31+
gcc --version
32+
git clone -b v0.8.19 --depth 1 https://github.com/citusdata/tools.git ../tools
33+
sudo make -C ../tools install
34+
install_uncrustify
35+
rm -rf uncrustify*
36+
37+
- name: Check code formatting and banned function
38+
run: |
39+
make lint

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ docs/tikz/*.png
5252
# Exclude our demo/test tmux directory
5353
tmux/
5454
valgrind/
55+
56+
# Exclude docker ID files
57+
docker.id*

docs/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ARG DEBIAN_TAG="bullseye-slim"
2+
3+
FROM debian:${DEBIAN_TAG} as python-slim
4+
5+
ARG DEBIAN_TAG
6+
7+
LABEL org.opencontainers.image.authors = "Data Bene <https://data-bene.io/>"
8+
LABEL org.opencontainers.image.source = "https://github.com/hapostgres/pg_auto_failover/tree/main/docs/Dockerfile"
9+
LABEL org.opencontainers.image.version = "${DEBIAN_TAG}"
10+
LABEL org.opencontainers.image.licenses = "PostgreSQL License"
11+
LABEL org.opencontainers.image.description = "A better python3 slim with pip"
12+
13+
RUN apt-get update \
14+
&& apt-get install --no-install-recommends --yes \
15+
make \
16+
python3-minimal \
17+
python3-pip \
18+
&& apt-get autoremove \
19+
&& apt-get clean \
20+
&& rm -rf /var/lib/apt/lists/*
21+
22+
FROM python-slim
23+
24+
WORKDIR /docs
25+
COPY requirements.txt .
26+
RUN python3 -m pip install --upgrade --no-cache-dir pip install -r requirements.txt
27+
28+
CMD ["python3", "--help"]

docs/Makefile

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Minimal makefile for Sphinx documentation
2-
#
1+
.DEFAULT_GOAL := all
32

43
# You can set these variables from the command line.
54
SPHINXOPTS =
@@ -8,13 +7,51 @@ SPHINXPROJ = pg_auto_failover
87
SOURCEDIR = .
98
BUILDDIR = _build
109

11-
# Put it first so that "make" without argument is like "make help".
10+
DEPS = $(wildcard *.rst) $(wildcard ref/*.rst)
11+
12+
# If USE_DOCKER variable is defined, we're working with docker and use the tools
13+
# from image/container instead of current OS.
14+
ifdef USE_DOCKER
15+
SPHINX_IMAGE = hapostgres/sphinx-citus:latest
16+
endif
17+
18+
.PHONY: all
19+
all: tikz html
20+
21+
.PHONY: clean
22+
clean:
23+
rm -f docker.id
24+
rm -rf _build _html
25+
$(MAKE) -C tikz $@
26+
27+
.PHONY: maintainer-clean
28+
maintainer-clean: clean
29+
$(MAKE) -C tikz $@
30+
ifdef USE_DOCKER
31+
docker image rm $(SPHINX_IMAGE)
32+
endif
33+
34+
ifdef USE_DOCKER
35+
SPHINXBUILD = docker run --rm -u $(shell id -u):$(shell id -g) -v $(SOURCEDIR)/:/docs $(SPHINX_IMAGE) sphinx-build
36+
docker.id: Dockerfile requirements.txt
37+
docker build --iidfile docker.id --file $< -t $(SPHINX_IMAGE) .
38+
else
39+
docker.id: ;
40+
endif
41+
42+
.PHONY: help
1243
help:
1344
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1445

15-
.PHONY: help Makefile
46+
.PHONY: html
47+
html: $(BUILDDIR)/html
48+
49+
.PHONY: tikz
50+
tikz:
51+
$(MAKE) -C tikz all
1652

1753
# Catch-all target: route all unknown targets to Sphinx using the new
1854
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19-
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
55+
$(BUILDDIR)/html: $(DEPS) docker.id
56+
echo $?
57+
$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __init__(self, **options):
9999
# The theme to use for HTML and HTML Help pages. See the documentation for
100100
# a list of builtin themes.
101101
#
102-
html_theme = "sphinx_rtd_theme"
102+
html_theme = "sphinx_rtd_theme_citus"
103103

104104
# Theme options are theme-specific and customize the look and feel of a theme
105105
# further. For a list of options available for each theme, see the

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Sphinx==4.0.2
1+
Sphinx==5.3.0
22
sphinx_rtd_theme_citus==0.5.25
33
docutils==0.16
4-
readthedocs-sphinx-search==0.1.0
4+
readthedocs-sphinx-search==0.3.1

docs/tikz/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ARG DEBIAN_TAG="bullseye-slim"
2+
3+
FROM debian:${DEBIAN_TAG} as luatex
4+
5+
ARG DEBIAN_TAG
6+
7+
LABEL org.opencontainers.image.authors = "Data Bene <https://data-bene.io/>"
8+
LABEL org.opencontainers.image.source = "https://github.com/hapostgres/pg_auto_failover/tree/main/docs/tikz/Dockerfile"
9+
LABEL org.opencontainers.image.version = "${DEBIAN_TAG}"
10+
LABEL org.opencontainers.image.licenses = "PostgreSQL License"
11+
LABEL org.opencontainers.image.description = "Docs builder with latexmk and pdftocairo"
12+
13+
RUN apt-get update \
14+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
15+
make \
16+
latexmk \
17+
poppler-utils \
18+
texlive \
19+
texlive-luatex \
20+
texlive-latex-extra \
21+
texlive-fonts-extra \
22+
&& apt-get autoremove \
23+
&& apt-get clean \
24+
&& rm -rf /var/lib/apt/lists/*
25+
26+
FROM luatex
27+
28+
WORKDIR /tikz
29+
30+
ENV TERM=dumb
31+
ENV TEXMFHOME = /.cache/
32+
ENV TEXMFVAR = /.cache/texmf-var/
33+
ENV TEXMFCONFIG = $TEXMFSYSCONFIG
34+
35+
RUN luaotfload-tool --update

0 commit comments

Comments
 (0)