Skip to content

Commit aec210a

Browse files
authored
Update docs image, move it to hub.docker.com/u/libfn (#129)
* Update README.md * Rewrite ci-docs * Minor Dockerfile changes * Add docs to ci workflow * Update docs workflow * Minor fixes in license workflow
1 parent fba2b02 commit aec210a

File tree

9 files changed

+189
-44
lines changed

9 files changed

+189
-44
lines changed

.github/workflows/ci.yml

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ name: ci
33
on:
44
schedule:
55
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07
6-
# This is meant to run at 13:17 on 11th of every month
6+
# This is meant to run at 13:17 UTC on 11th and 26th of every month
77
- cron: '17 13 11 * *'
8+
- cron: '17 13 26 * *'
89
push:
910
branches:
1011
- main
@@ -17,6 +18,7 @@ on:
1718
env:
1819
REGISTRY_IMAGE_BUILD: libfn/ci-build
1920
REGISTRY_IMAGE_PRE_COMMIT: libfn/ci-pre-commit
21+
REGISTRY_IMAGE_DOCS: libfn/ci-docs
2022

2123
jobs:
2224

@@ -251,3 +253,108 @@ jobs:
251253
- name: Inspect image
252254
run: |
253255
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE_PRE_COMMIT }}:${{ steps.meta.outputs.version }}
256+
257+
docs:
258+
runs-on: ubuntu-latest
259+
strategy:
260+
fail-fast: false
261+
matrix:
262+
platform:
263+
- linux/amd64
264+
- linux/arm64
265+
266+
steps:
267+
- name: Prepare
268+
run: |
269+
platform=${{ matrix.platform }}
270+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
271+
272+
- name: Docker meta
273+
id: meta
274+
uses: docker/metadata-action@v5
275+
with:
276+
images: ${{ env.REGISTRY_IMAGE_DOCS }}
277+
tags: |
278+
type=schedule,pattern={{date 'YYYYMMDD'}}
279+
type=raw,value=latest,enable={{is_default_branch}}
280+
type=sha
281+
282+
- name: Set up QEMU
283+
uses: docker/setup-qemu-action@v3
284+
285+
- name: Set up Docker Buildx
286+
uses: docker/setup-buildx-action@v3
287+
288+
- name: Login to Docker Hub
289+
uses: docker/login-action@v3
290+
with:
291+
username: ${{ secrets.DOCKERHUB_USERNAME }}
292+
password: ${{ secrets.DOCKERHUB_TOKEN }}
293+
294+
- name: Build and push by digest
295+
id: build
296+
uses: docker/build-push-action@v6
297+
with:
298+
platforms: ${{ matrix.platform }}
299+
context: "{{defaultContext}}:ci/docs/"
300+
file: Dockerfile
301+
labels: ${{ steps.meta.outputs.labels }}
302+
outputs: type=image,name=${{ env.REGISTRY_IMAGE_DOCS }},push-by-digest=true,name-canonical=true,push=true
303+
sbom: true
304+
provenance: mode=max
305+
306+
- name: Export digest
307+
run: |
308+
mkdir -p /tmp/digests
309+
digest="${{ steps.build.outputs.digest }}"
310+
touch "/tmp/digests/${digest#sha256:}"
311+
312+
- name: Upload digest
313+
uses: actions/upload-artifact@v4
314+
with:
315+
name: digests-docs-${{ env.PLATFORM_PAIR }}
316+
path: /tmp/digests/*
317+
if-no-files-found: error
318+
retention-days: 1
319+
320+
merge-docs:
321+
runs-on: ubuntu-latest
322+
needs:
323+
- docs
324+
325+
steps:
326+
- name: Download digests
327+
uses: actions/download-artifact@v4
328+
with:
329+
path: /tmp/digests
330+
pattern: digests-docs-*
331+
merge-multiple: true
332+
333+
- name: Set up Docker Buildx
334+
uses: docker/setup-buildx-action@v3
335+
336+
- name: Docker meta
337+
id: meta
338+
uses: docker/metadata-action@v5
339+
with:
340+
images: ${{ env.REGISTRY_IMAGE_DOCS }}
341+
tags: |
342+
type=schedule,pattern={{date 'YYYYMMDD'}}
343+
type=raw,value=latest,enable={{is_default_branch}}
344+
type=sha
345+
346+
- name: Login to Docker Hub
347+
uses: docker/login-action@v3
348+
with:
349+
username: ${{ secrets.DOCKERHUB_USERNAME }}
350+
password: ${{ secrets.DOCKERHUB_TOKEN }}
351+
352+
- name: Create manifest list and push
353+
working-directory: /tmp/digests
354+
run: |
355+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
356+
$(printf '${{ env.REGISTRY_IMAGE_DOCS }}@sha256:%s ' *)
357+
358+
- name: Inspect image
359+
run: |
360+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE_DOCS }}:${{ steps.meta.outputs.version }}

.github/workflows/docs.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,20 @@ permissions:
1919
pages: write
2020
id-token: write
2121

22-
concurrency:
23-
group: "pages"
24-
cancel-in-progress: true
25-
2622
jobs:
2723
generate_docs:
28-
name: Generate and upload docs
29-
runs-on: ubuntu-20.04
30-
container:
31-
image: godexsoft/functional-ci:0.0.4
24+
runs-on:
25+
group: default
26+
strategy:
27+
fail-fast: false
28+
container: libfn/ci-docs:latest
3229
steps:
3330
- uses: actions/checkout@v3
3431
with:
3532
submodules: 'true'
3633

3734
- name: Export docs
3835
continue-on-error: false
39-
shell: bash
40-
id: run_cmake
4136
run: |
4237
mkdir .build
4338
cd .build

.github/workflows/licence.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- 'CMakeLists.txt'
1212
- 'cmake/**'
1313
- '.fossa.yml'
14+
- 'LICENSE.md'
1415
pull_request:
1516
branches:
1617
- main
@@ -21,6 +22,7 @@ on:
2122
- 'CMakeLists.txt'
2223
- 'cmake/**'
2324
- '.fossa.yml'
25+
- 'LICENSE.md'
2426
workflow_dispatch:
2527
inputs:
2628
run_licence_check:
@@ -59,5 +61,6 @@ jobs:
5961
- name: What happened?
6062
if: failure() && steps.assert.outcome == 'failure'
6163
run:
62-
echo "You branch appear to have attempted to modify ${LICENCE_FILE}"
64+
echo "Your pull request appear to have attempted to modify ${LICENCE_FILE}"
65+
echo "If you want your name added to ${LICENCE_FILE}, please ask project maintainers."
6366
exit 1

.pre-commit-config.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
# pre-commit install
66
# pre-commit install-hooks
77
#
8-
# precommit hooks installation
9-
#
10-
# - pre-commit autoupdate
11-
#
12-
# - pre-commit run black
13-
#
148
# continuous integration
159
# ======================
1610
#
1711
# - pre-commit run --all-files
1812
#
1913
# See https://pre-commit.com for more information
2014
# See https://pre-commit.com/hooks.html for more hooks
15+
#
16+
# NOTE repo and rev listed below must match ci/pre-commit/requirements.txt
17+
#
2118
repos:
2219
- repo: https://github.com/pre-commit/pre-commit-hooks
2320
rev: v5.0.0

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,31 @@ The maintainers are unable to guarantee that no significant refactoring will eve
5050
[ripple]: https://ripple.com/
5151

5252
## Pre-commit
53-
This repository supports [pre-commit](https://pre-commit.com/) to install git commit hooks which will run checks on the repository (currently just clang-format). Pre-commit will install git commit hooks locally so that they run on each commit. To set up locally you configure a virtual environment, install the requirements and run pre-commit install.
5453

55-
```
54+
This repository uses [pre-commit](https://pre-commit.com/) to enforce formatting of the C++ source code and perform other checks. The details can be seen in `.pre-commit-config.yaml`. To install git commit hooks, which will run checks on the repository as you commit changes:
55+
56+
* configure a Python virtual environment
57+
* install the requirements from `ci/pre-commit/requirements.txt`
58+
* run `pre-commit install` in your local repository
59+
60+
```bash
5661
# Set up a virtual environment to install pre-commit
5762
python3 -m venv .venv
58-
source ./.venv/bin/activate
59-
pip install pre-commit
63+
source .venv/bin/activate
64+
pip install -r ci/pre-commit/requirements.txt
6065
# Now install the pre-commit hooks locally
6166
pre-commit install
6267
```
6368

64-
You can run the check manually as follows:
65-
```
69+
You can run all checks manually as follows:
70+
71+
```bash
6672
# Source the virtual environment to access pre-commit
67-
source ./.venv/bin/activate
73+
source .venv/bin/activate
6874
# Run pre-commit on local files.
6975
pre-commit run --all-files
7076
```
7177

7278
## License
79+
7380
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Flibfn%2Ffunctional.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Flibfn%2Ffunctional?ref=badge_large)

ci/build/clang/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM debian:bookworm
22

33
ARG CLANG_RELEASE=19
4+
ENV CLANG_RELEASE=${CLANG_RELEASE}
45
ENV DEBIAN_FRONTEND=noninteractive
56
RUN set -ex ;\
67
apt-get update ;\
@@ -32,6 +33,7 @@ ENV CMAKE_BUILD_TYPE=Debug
3233

3334
WORKDIR /work
3435
ARG CATCH_RELEASE=3.7.1
36+
ENV CATCH_RELEASE=${CATCH_RELEASE}
3537
RUN set -ex ;\
3638
git clone https://github.com/catchorg/Catch2.git ;\
3739
cd Catch2 ;\

ci/build/gcc/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ ARG GCC_DIST=${GCC_RELEASE}-bookworm
33
FROM gcc:${GCC_DIST} AS gcc
44
RUN set -ex ;\
55
find /usr/local/ -type f ;\
6-
cat /etc/ld.so.conf.d/000-local-lib.conf ;\
6+
cat /etc/ld.so.conf.d/* ;\
77
cat /etc/os-release ;\
88
/usr/local/bin/gcc --version
99

1010
FROM debian:bookworm
1111
COPY --from=gcc /usr/local/ /usr/local/
12-
COPY --from=gcc /etc/ld.so.conf.d/000-local-lib.conf /etc/ld.so.conf.d/000-local-lib.conf
12+
COPY --from=gcc /etc/ld.so.conf.d/ /etc/ld.so.conf.d/
1313

1414
WORKDIR /root
15-
ENV DEBIAN_FRONTEND=noninteractive
1615
RUN set -ex ;\
1716
ldconfig -v ;\
1817
dpkg-divert --divert /usr/bin/gcc.orig --rename /usr/bin/gcc ;\
@@ -32,6 +31,7 @@ RUN set -ex ;\
3231
update-alternatives --auto cc ;\
3332
update-alternatives --auto gcc
3433

34+
ENV DEBIAN_FRONTEND=noninteractive
3535
RUN set -ex ;\
3636
apt-get update ;\
3737
apt-get install -y --no-install-recommends \

ci/docs/Dockerfile

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,57 @@
1-
FROM fedora:39
1+
ARG GCC_RELEASE=14
2+
ARG GCC_DIST=${GCC_RELEASE}-bookworm
3+
FROM gcc:${GCC_DIST} AS gcc
4+
RUN set -ex ;\
5+
find /usr/local/ -type f ;\
6+
cat /etc/ld.so.conf.d/* ;\
7+
cat /etc/os-release ;\
8+
/usr/local/bin/gcc --version
9+
10+
FROM debian:bookworm
11+
COPY --from=gcc /usr/local/ /usr/local/
12+
COPY --from=gcc /etc/ld.so.conf.d/ /etc/ld.so.conf.d/
213

314
WORKDIR /root
15+
RUN set -ex ;\
16+
ldconfig -v ;\
17+
dpkg-divert --divert /usr/bin/gcc.orig --rename /usr/bin/gcc ;\
18+
dpkg-divert --divert /usr/bin/g++.orig --rename /usr/bin/g++ ;\
19+
dpkg-divert --divert /usr/bin/gfortran.orig --rename /usr/bin/gfortran ;\
20+
update-alternatives --install /usr/bin/cc cc /usr/local/bin/gcc 999 ;\
21+
update-alternatives --install \
22+
/usr/bin/gcc gcc /usr/local/bin/gcc 100 \
23+
--slave /usr/bin/g++ g++ /usr/local/bin/g++ \
24+
--slave /usr/bin/gcc-ar gcc-ar /usr/local/bin/gcc-ar \
25+
--slave /usr/bin/gcc-nm gcc-nm /usr/local/bin/gcc-nm \
26+
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/local/bin/gcc-ranlib \
27+
--slave /usr/bin/gcov gcov /usr/local/bin/gcov \
28+
--slave /usr/bin/gcov-tool gcov-tool /usr/local/bin/gcov-tool \
29+
--slave /usr/bin/gcov-dump gcov-dump /usr/local/bin/gcov-dump \
30+
--slave /usr/bin/lto-dump lto-dump /usr/local/bin/lto-dump ;\
31+
update-alternatives --auto cc ;\
32+
update-alternatives --auto gcc
433

5-
RUN dnf -y update ;\
6-
dnf -y install redhat-lsb python3.11 gcc libstdc++-static ccache \
7-
vim wget sudo curl git grep sed gdb zsh cmake doxygen ninja-build \
8-
unzip java-latest-openjdk clang git-clang-format clang-tools-extra llvm ;\
9-
dnf -y clean all
34+
ENV DEBIAN_FRONTEND=noninteractive
35+
RUN set -ex ;\
36+
apt-get update ;\
37+
apt-get install -y --no-install-recommends \
38+
ca-certificates gpg gpg-agent wget vim \
39+
cmake ninja-build binutils libc6-dev git \
40+
openjdk-17-jdk doxygen unzip ;\
41+
apt-get clean
1042

11-
# Fail build if unexpected gcc version
12-
RUN gcc --version | grep -E "^gcc \(GCC\) 13"
43+
ARG ZNAI_RELEASE=1.73
44+
ENV ZNAI_RELEASE=${ZNAI_RELEASE}
45+
WORKDIR /work
46+
RUN set -ex ;\
47+
DIST="https://repo.maven.apache.org/maven2/org/testingisdocumenting/znai/znai-dist" ;\
48+
wget ${DIST}/${ZNAI_RELEASE}/znai-dist-${ZNAI_RELEASE}-znai.zip ;\
49+
unzip znai-dist-${ZNAI_RELEASE}-znai.zip -d znai_tmp ;\
50+
mv znai_tmp/dist /opt/znai ;\
51+
rm -rf znai-dist-${ZNAI_RELEASE}-znai.zip znai_tmp
1352

14-
RUN wget https://repo.maven.apache.org/maven2/org/testingisdocumenting/znai/znai-dist/1.70/znai-dist-1.70-znai.zip ;\
15-
unzip znai-dist-1.70-znai.zip -d znai_tmp; mv znai_tmp/dist /opt/znai ;\
16-
rm -rf znai-dist-1.70-znai.zip znai_tmp
1753
ENV PATH=/opt/znai:${PATH}
18-
1954
ENV CC=/usr/bin/gcc
2055
ENV CXX=/usr/bin/g++
21-
ENV CMAKE_GENERATOR='Ninja'
22-
ENV CMAKE_C_COMPILER=${CC}
23-
ENV CMAKE_CXX_COMPILER=${CXX}
56+
ENV CMAKE_GENERATOR=Ninja
57+
ENV CMAKE_BUILD_TYPE=Debug

ci/pre-commit/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pre-commit<5
2-
# NOTE versions listed below must match .pre-commit-config.yaml
2+
# NOTE packages and versions listed below must match .pre-commit-config.yaml
33
clang-format==18.1.8
44
pre-commit-hooks==5.0.0

0 commit comments

Comments
 (0)