Skip to content

Commit b8cc26e

Browse files
committed
Add development tooling and QA infrastructure
Build System: - Add timing output to Makefile targets showing duration - Add parallel build support with -j auto - Add fasthtml, draft, serve targets for development Development Environment (flake.nix): - Add codespell, yamllint, doc8 for linting - Add shell hook with command reference table - Add nix run targets for all build and utility commands Pre-commit (.pre-commit-config.yaml): - Add trailing-whitespace, end-of-file-fixer - Add check-yaml, check-json, check-merge-conflict - Add rstcheck, doc8, codespell, yamllint - Add custom check-image-refs script GitHub Actions: - Add qa.yml workflow using Nix for reproducible CI - Add optimize-images.yml for PNG optimization Neovim Integration: - Add .nvim.lua with which-key project menu - Add .exrc with quick access shortcuts Scripts: - benchmark_build.sh - performance comparison - build_all_languages.sh - parallel i18n builds - optimize_images.sh - PNG optimization - check_image_refs.sh - validate image references
1 parent 6fa3482 commit b8cc26e

11 files changed

Lines changed: 2543 additions & 61 deletions

File tree

.exrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
" QGIS Documentation Project Configuration
2+
" Source the Lua config for full functionality
3+
if has('nvim')
4+
lua dofile('.nvim.lua')
5+
endif
6+
7+
" Basic settings for RST/Sphinx development
8+
set expandtab
9+
set tabstop=3
10+
set shiftwidth=3
11+
set softtabstop=3
12+
set textwidth=79
13+
set colorcolumn=80
14+
15+
" RST file settings
16+
autocmd FileType rst setlocal spell spelllang=en_us
17+
autocmd FileType rst setlocal foldmethod=expr
18+
19+
" Recognize .rst files
20+
autocmd BufRead,BufNewFile *.rst set filetype=rst
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Optimize Images
2+
3+
on:
4+
# Manual trigger
5+
workflow_dispatch:
6+
inputs:
7+
mode:
8+
description: 'Compression mode'
9+
required: true
10+
default: 'lossless'
11+
type: choice
12+
options:
13+
- lossless
14+
- lossy
15+
path:
16+
description: 'Path to optimize (default: build/html/)'
17+
required: false
18+
default: 'build/html/'
19+
20+
# Run on PRs that add/modify images
21+
pull_request:
22+
paths:
23+
- '**.png'
24+
- '**.PNG'
25+
26+
permissions:
27+
contents: write
28+
pull-requests: write
29+
30+
jobs:
31+
optimize:
32+
runs-on: ubuntu-latest
33+
name: Optimize PNG images
34+
35+
steps:
36+
- name: Harden Runner
37+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
38+
with:
39+
egress-policy: audit
40+
41+
- name: Check out repository
42+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
43+
with:
44+
ref: ${{ github.head_ref || github.ref }}
45+
fetch-depth: 0
46+
47+
- name: Install optimization tools
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get install -y optipng pngquant
51+
52+
- name: Get changed images (PR only)
53+
if: github.event_name == 'pull_request'
54+
id: changed-images
55+
run: |
56+
# Get list of changed PNG files
57+
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- '*.png' '*.PNG' | tr '\n' ' ')
58+
echo "files=$CHANGED" >> $GITHUB_OUTPUT
59+
if [ -z "$CHANGED" ]; then
60+
echo "No PNG files changed"
61+
echo "has_changes=false" >> $GITHUB_OUTPUT
62+
else
63+
echo "Changed files: $CHANGED"
64+
echo "has_changes=true" >> $GITHUB_OUTPUT
65+
fi
66+
67+
- name: Optimize images (PR - changed files only)
68+
if: github.event_name == 'pull_request' && steps.changed-images.outputs.has_changes == 'true'
69+
run: |
70+
for file in ${{ steps.changed-images.outputs.files }}; do
71+
if [ -f "$file" ]; then
72+
echo "Optimizing: $file"
73+
BEFORE=$(stat -c%s "$file")
74+
optipng -o2 -quiet "$file" || true
75+
AFTER=$(stat -c%s "$file")
76+
if [ "$AFTER" -lt "$BEFORE" ]; then
77+
SAVED=$((BEFORE - AFTER))
78+
echo " Saved: $SAVED bytes"
79+
fi
80+
fi
81+
done
82+
83+
- name: Optimize images (Manual trigger)
84+
if: github.event_name == 'workflow_dispatch'
85+
run: |
86+
MODE_FLAG=""
87+
if [ "${{ inputs.mode }}" == "lossy" ]; then
88+
MODE_FLAG="--lossy"
89+
fi
90+
./scripts/optimize_images.sh $MODE_FLAG "${{ inputs.path }}"
91+
92+
- name: Check for changes
93+
id: git-check
94+
run: |
95+
git diff --exit-code || echo "has_changes=true" >> $GITHUB_OUTPUT
96+
97+
- name: Commit optimized images (PR)
98+
if: github.event_name == 'pull_request' && steps.git-check.outputs.has_changes == 'true'
99+
run: |
100+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
101+
git config --local user.name "github-actions[bot]"
102+
git add -A
103+
git commit -m "Optimize PNG images
104+
105+
Automated image optimization using optipng."
106+
git push
107+
108+
- name: Create PR with optimized images (Manual trigger)
109+
if: github.event_name == 'workflow_dispatch' && steps.git-check.outputs.has_changes == 'true'
110+
run: |
111+
BRANCH="optimize-images-$(date +%Y%m%d-%H%M%S)"
112+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
113+
git config --local user.name "github-actions[bot]"
114+
git checkout -b "$BRANCH"
115+
git add -A
116+
git commit -m "Optimize PNG images (${{ inputs.mode }} mode)
117+
118+
Automated image optimization using optipng${{ inputs.mode == 'lossy' && ' and pngquant' || '' }}."
119+
git push -u origin "$BRANCH"
120+
121+
gh pr create \
122+
--title "Optimize PNG images (${{ inputs.mode }} mode)" \
123+
--body "## Summary
124+
125+
Automated image optimization run.
126+
127+
- **Mode**: ${{ inputs.mode }}
128+
- **Path**: ${{ inputs.path }}
129+
130+
This PR contains optimized PNG images to reduce repository size and improve page load times." \
131+
--base ${{ github.ref_name }}
132+
env:
133+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
135+
- name: Summary
136+
run: |
137+
echo "## Image Optimization Complete" >> $GITHUB_STEP_SUMMARY
138+
echo "" >> $GITHUB_STEP_SUMMARY
139+
if [ "${{ steps.git-check.outputs.has_changes }}" == "true" ]; then
140+
echo "Images were optimized and changes committed." >> $GITHUB_STEP_SUMMARY
141+
else
142+
echo "No optimization improvements found." >> $GITHUB_STEP_SUMMARY
143+
fi

0 commit comments

Comments
 (0)