Skip to content

Commit 4ea6898

Browse files
committed
Merge branch '84-build-add-github-pages-documentation-site-and-ci-integration' into staging
2 parents 4192fdf + 93cd5eb commit 4ea6898

41 files changed

Lines changed: 3360 additions & 29 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ release, staging ]
6+
pull_request:
7+
branches: [ release, staging ]
8+
9+
jobs:
10+
build:
11+
name: ${{ matrix.os }} / ${{ matrix.compiler }}
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-22.04, ubuntu-24.04]
18+
compiler: [gcc-13, gcc-14, gcc-15, clang-17, clang-18, clang-19, clang-20]
19+
include:
20+
- compiler: gcc-13
21+
compiler-version: 13
22+
- compiler: gcc-14
23+
compiler-version: 14
24+
- compiler: gcc-15
25+
compiler-version: 15
26+
- compiler: clang-17
27+
compiler-version: 17
28+
- compiler: clang-18
29+
compiler-version: 18
30+
- compiler: clang-19
31+
compiler-version: 19
32+
- compiler: clang-20
33+
compiler-version: 20
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Set badge output directory
38+
id: path
39+
run: |
40+
if [[ "${GITHUB_REF##*/}" == "staging" ]]; then
41+
echo "dir=status-staging" >> $GITHUB_OUTPUT
42+
else
43+
echo "dir=status" >> $GITHUB_OUTPUT
44+
fi
45+
46+
- name: Check skip list
47+
id: skip_check
48+
run: |
49+
skip_list=(
50+
"ubuntu-22.04:gcc-14"
51+
"ubuntu-22.04:gcc-15"
52+
"ubuntu-24.04:gcc-15"
53+
"ubuntu-24.04:clang-17"
54+
"macos-13:gcc-13"
55+
"macos-13:gcc-14"
56+
"macos-13:gcc-15"
57+
)
58+
59+
combo="${{ matrix.os }}:${{ matrix.compiler }}"
60+
echo "Checking combination: $combo"
61+
for skip in "${skip_list[@]}"; do
62+
if [[ "$combo" == "$skip" ]]; then
63+
echo "SKIP_COMPILE=true" >> "$GITHUB_ENV"
64+
exit 0
65+
fi
66+
done
67+
echo "SKIP_COMPILE=false" >> "$GITHUB_ENV"
68+
69+
- name: Setup compiler on macOS
70+
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'macOS' }}
71+
run: |
72+
brew install llvm@${{ matrix.compiler-version }}
73+
echo "CC=$(brew --prefix llvm@${{ matrix.compiler-version }})/bin/clang" >> $GITHUB_ENV
74+
echo "CXX=$(brew --prefix llvm@${{ matrix.compiler-version }})/bin/clang++" >> $GITHUB_ENV
75+
76+
- name: Setup compiler on Linux
77+
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'Linux' }}
78+
run: |
79+
compiler="${{ matrix.compiler }}"
80+
version="${{ matrix.compiler-version }}"
81+
82+
if [[ "$compiler" == clang-* ]]; then
83+
sudo apt-get update
84+
sudo apt-get install -y wget gnupg lsb-release software-properties-common
85+
wget https://apt.llvm.org/llvm.sh
86+
chmod +x llvm.sh
87+
sudo DISTRIB_CODENAME=jammy ./llvm.sh "$version" all
88+
CXX="clang++-$version"
89+
elif [[ "$compiler" == gcc-* ]]; then
90+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
91+
sudo apt-get update
92+
sudo apt-get install -y g++-"$version"
93+
CXX="g++-$version"
94+
else
95+
CXX="g++"
96+
fi
97+
98+
which "$CXX" || { echo "$CXX not found in PATH"; exit 1; }
99+
echo "CXX=$(which $CXX)" >> "$GITHUB_ENV"
100+
101+
- name: Checkout
102+
uses: actions/checkout@v4
103+
with:
104+
fetch-depth: 0
105+
106+
- name: Install system dependencies on macOS
107+
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'macOS' }}
108+
run: |
109+
brew update
110+
brew install hdf5
111+
112+
- name: Install system dependencies on Linux
113+
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'Linux' }}
114+
run: sudo apt-get update && sudo apt-get install -y libhdf5-dev
115+
116+
117+
- name: Configure
118+
if: env.SKIP_COMPILE == 'false'
119+
run: cmake -B build -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release
120+
121+
- name: Build
122+
if: env.SKIP_COMPILE == 'false'
123+
run: cmake --build build --parallel
124+
125+
- name: Test
126+
if: env.SKIP_COMPILE == 'false'
127+
run: ctest --test-dir build --output-on-failure
128+
129+
- name: Record Badge Status
130+
if: always()
131+
run: |
132+
mkdir -p badge-status
133+
status="skipped"
134+
if [[ "$SKIP_COMPILE" == "false" ]]; then
135+
status="${{ job.status }}"
136+
fi
137+
138+
cat <<EOF > badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json
139+
{
140+
"os": "${{ matrix.os }}",
141+
"compiler": "${{ matrix.compiler }}",
142+
"status": "$status"
143+
}
144+
EOF
145+
- name: Upload Status Artifact
146+
if: always()
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: status-${{ matrix.os }}-${{ matrix.compiler }}
150+
path: badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json
151+
152+
generate-badges:
153+
name: Generate SVG Badges
154+
runs-on: ubuntu-latest
155+
needs: build
156+
if: always()
157+
158+
steps:
159+
- uses: actions/checkout@v4
160+
161+
- name: Determine badge target directory
162+
id: badge_dir
163+
run: |
164+
if [[ "${GITHUB_REF##*/}" == "staging" ]]; then
165+
echo "dir=badges-staging" >> $GITHUB_OUTPUT
166+
else
167+
echo "dir=badges" >> $GITHUB_OUTPUT
168+
fi
169+
170+
- name: Download all badge status artifacts
171+
uses: actions/download-artifact@v4
172+
with:
173+
path: badge-status
174+
pattern: status-*
175+
merge-multiple: true
176+
177+
- name: Generate SVG Badges
178+
run: |
179+
mkdir -p ${{ steps.badge_dir.outputs.dir }}
180+
for f in badge-status/*.json; do
181+
echo "file name: $f"
182+
[[ ! -f "$f" ]] && continue
183+
os=$(jq -r .os "$f")
184+
compiler=$(jq -r .compiler "$f")
185+
status=$(jq -r .status "$f")
186+
187+
color="gray"
188+
symbol="□"
189+
190+
[[ "$status" == "success" ]] && { symbol="✔"; color="green"; prefix="ok"; }
191+
[[ "$status" == "skipped" ]] && { symbol="○"; color="gray"; prefix="na"; }
192+
[[ "$status" == "failure" ]] && { symbol="✘"; color="red"; prefix="failed"; }
193+
194+
label="${os}-${compiler}"
195+
badge="${{ steps.badge_dir.outputs.dir }}/${label}.svg"
196+
echo "https://img.shields.io/badge/${prefix}-${symbol}-${color}.svg $badge"
197+
curl -s "https://img.shields.io/badge/${prefix}-${symbol}-${color}.svg" -o "$badge"
198+
done
199+
200+
- name: Upload badge folder to GitHub Pages
201+
uses: peaceiris/actions-gh-pages@v3
202+
with:
203+
github_token: ${{ secrets.GITHUB_TOKEN }}
204+
publish_dir: ./${{ steps.badge_dir.outputs.dir }}
205+
destination_dir: ${{ steps.badge_dir.outputs.dir }}

.github/workflows/docs.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [release, staging]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.x'
22+
23+
- name: Install MkDocs + Material theme
24+
run: |
25+
pip install mkdocs mkdocs-material
26+
27+
- name: Build documentation
28+
run: mkdocs build
29+
30+
- name: Deploy to GitHub Pages
31+
uses: peaceiris/actions-gh-pages@v4
32+
with:
33+
github_token: ${{ secrets.GITHUB_TOKEN }}
34+
publish_dir: ./site

Makefile

Lines changed: 71 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PREFIX = /usr/local
77

88
VERSION = 1.10.4.6
99
DEB = -1~exp1
10-
PROGRAM_NAME=libh5cpp-dev
10+
PROGRAM_NAME = libh5cpp-dev
1111
BIN_DIR = $(PREFIX)/bin
1212
INCLUDE_DIR = $(PREFIX)/include
1313
EXAMPLE_DIR = $(PREFIX)/share
@@ -16,46 +16,89 @@ MAN_BASE_DIR = $(PREFIX)/man
1616
MAN_DIR = $(MAN_BASE_DIR)/man1
1717
MAN_EXT = 1
1818

19-
20-
INSTALL = install # install : UCB/GNU Install compatiable
21-
22-
RM = rm -f
23-
MKDIR = mkdir -p
19+
INSTALL = install
20+
RM = rm -f
21+
MKDIR = mkdir -p
2422

2523
CC ?= gcc
2624
COMPILER_OPTIONS = -Wall -O -g
2725

2826
INSTALL_PROGRAM = $(INSTALL) -c -m 0755
29-
INSTALL_DATA = $(INSTALL) -c -m 0644
30-
INSTALL_EXAMPLE = $(INSTALL) -c -m 0755
31-
INSTALL_INCLUDE = $(INSTALL) -m 0755
27+
INSTALL_DATA = $(INSTALL) -c -m 0644
28+
INSTALL_EXAMPLE = $(INSTALL) -c -m 0755
29+
INSTALL_INCLUDE = $(INSTALL) -m 0755
30+
31+
OBJECT_FILES =
32+
33+
# ------------------------------------------------------------------
34+
# documentation / mkdocs
35+
# ------------------------------------------------------------------
36+
PYTHON ?= python3
37+
PIP ?= $(PYTHON) -m pip
38+
MKDOCS ?= mkdocs
39+
MKDOCS_CONFIG ?= mkdocs.yml
40+
DOCS_DIR ?= docs
41+
SITE_DIR ?= site
42+
43+
# Optional:
44+
# If you later use Material or plugins, put them here or in requirements-docs.txt
45+
DOCS_REQUIREMENTS ?= requirements-docs.txt
46+
47+
PYTHON ?= python3
48+
VENV_DIR ?= .venv
49+
VENV_PYTHON = $(VENV_DIR)/bin/python
50+
VENV_PIP = $(VENV_PYTHON) -m pip
51+
MKDOCS = $(VENV_PYTHON) -m mkdocs
52+
MKDOCS_CONFIG ?= mkdocs.yml
53+
DOCS_DIR ?= docs
54+
SITE_DIR ?= site
55+
DOCS_REQUIREMENTS ?= requirements-docs.txt
56+
57+
.PHONY: docs docs-build docs-serve docs-strict docs-deploy \
58+
docs-clean docs-install docs-venv docs-bootstrap venv-clean
3259

33-
OBJECT_FILES =
34-
#fdupes.o md5/md5.o $(ADDITIONAL_OBJECTS)
60+
$(VENV_PYTHON):
61+
$(PYTHON) -m venv $(VENV_DIR)
62+
$(VENV_PIP) install --upgrade pip
3563

36-
#####################################################################
37-
# no need to modify anything beyond this point #
38-
#####################################################################
64+
docs-venv: $(VENV_PYTHON)
3965

40-
all:
66+
docs-bootstrap: docs-venv docs-install
4167

68+
docs: docs-build
4269

43-
installdirs:
44-
test -d $(INCLUDE_DIR) || $(MKDIR) $(MAN_DIR)
70+
docs-install: $(VENV_PYTHON)
71+
ifneq ("$(wildcard $(DOCS_REQUIREMENTS))","")
72+
$(VENV_PIP) install -r $(DOCS_REQUIREMENTS)
73+
else
74+
$(VENV_PIP) install mkdocs mkdocs-material
75+
endif
4576

46-
install: installdirs
47-
echo "******** $(INCLUDE_DIR) *******"
48-
$(INSTALL_INCLUDE) -d $(INCLUDE_DIR)/h5cpp
49-
find h5cpp -type f -exec install -Dm 755 "{}" "${INCLUDE_DIR}/{}" \;
50-
$(INSTALL_EXAMPLE) -d $(EXAMPLE_DIR)/h5cpp
51-
find examples -type f -exec install -Dm 644 "{}" "${EXAMPLE_DIR}/h5cpp/{}" \;
77+
docs-build: $(VENV_PYTHON)
78+
$(MKDOCS) build --config-file $(MKDOCS_CONFIG) --site-dir $(SITE_DIR)
79+
80+
docs-strict: $(VENV_PYTHON)
81+
$(MKDOCS) build --strict --config-file $(MKDOCS_CONFIG) --site-dir $(SITE_DIR)
82+
83+
docs-serve: $(VENV_PYTHON)
84+
$(MKDOCS) serve --livereload --config-file $(MKDOCS_CONFIG)
85+
86+
docs-deploy: $(VENV_PYTHON)
87+
$(MKDOCS) gh-deploy --clean --config-file $(MKDOCS_CONFIG)
88+
89+
docs-clean:
90+
rm -rf $(SITE_DIR)
91+
92+
venv-clean:
93+
rm -rf $(VENV_DIR)
5294

5395
tar-gz:
54-
tar --exclude='.[^/]*' --exclude-vcs-ignores -czvf ../libh5cpp_${VERSION}.orig.tar.gz ./
55-
gpg --detach-sign --armor ../libh5cpp_${VERSION}.orig.tar.gz
56-
scp ../libh5cpp_${VERSION}.orig.tar.* osaka:h5cpp.org/download/
57-
clean:
58-
@$(RM) h5cpp-*
96+
tar --exclude='.[^/]*' --exclude-vcs-ignores -czvf ../libh5cpp_${VERSION}.orig.tar.gz ./
97+
gpg --detach-sign --armor ../libh5cpp_${VERSION}.orig.tar.gz
98+
scp ../libh5cpp_${VERSION}.orig.tar.* osaka:h5cpp.org/download/
99+
100+
clean: docs_clean
101+
@$(RM) h5cpp-*
59102

60103
dist-debian-src: tar-gz
61104
debuild -i -us -uc -S
@@ -69,4 +112,3 @@ dist-debian-src-upload: dist-debian-src
69112

70113
dist-rpm: dist-debian
71114
sudo alien -r ../libh5cpp-dev_${VERSION}_all.deb
72-

0 commit comments

Comments
 (0)