Skip to content

Commit

Permalink
Use pinned dependencies for repos, infer GH matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed Nov 9, 2023
1 parent 2403c77 commit d648c0c
Show file tree
Hide file tree
Showing 42 changed files with 753 additions and 41 deletions.
38 changes: 17 additions & 21 deletions .github/workflows/regressions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,30 @@ on:
default: 'git+https://github.com/mkdocs/mkdocs.git@master'

jobs:
collect_projects:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.projects.outputs.projects }}
steps:
- uses: actions/checkout@v4
- id: projects
shell: python
run: |
import json, os
projects = [d.replace('--', '/') for d in os.listdir('projects')]
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
print('projects=' + json.dumps(projects), file=f)
regressions:
needs: collect_projects
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repo:
- crystal-lang/crystal-book
- e-maxx-eng/e-maxx-eng
- emacs-lsp/lsp-mode
- gledos/ggame
- ikrima/gamedevguide
- k3d-io/k3d
- librenms/librenms
- mkdocs/mkdocs
- mkdocstrings/mkdocstrings
- nasa-jpl/open-source-rover
- Noovolari/leapp
- ni/systemlink-operations-handbook
- ntno/mkdocs-terminal
- open-amt-cloud-toolkit/docs
- oprypin/mkdocs-gen-files
- Rat-Rig/V-core-3
- seleniumbase/SeleniumBase
- spaceship-prompt/spaceship-prompt
- tfeldmann/organize
repo: ${{ fromJson(needs.collect_projects.outputs.projects) }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
48 changes: 29 additions & 19 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ else
shift
fi

repo="$1"
repo_name="$1"
to_upgrade="${2:-git+https://github.com/mkdocs/mkdocs.git}"

project_dir="repos/${repo/\//--}"
info_dir="projects/${repo_name/\//--}"
repo_dir="repos/${repo_name/\//--}"

[[ "$(cat "$info_dir/url.txt")" =~ ^(https://github.com/[^/]+/[^/]+)/raw/([^/]+)/(.+)$ ]]
repo="${BASH_REMATCH[1]}"
branch="${BASH_REMATCH[2]}"
mkdocs_yml="${BASH_REMATCH[3]}"


group() {
echo "::group::$1"
Expand All @@ -28,50 +35,53 @@ setup() {
}

clone_repo() {
mkdir -p "$project_dir"
if ! [[ -d "$project_dir/repo" ]]; then
echo "Cloning" "https://github.com/$repo"
git clone "https://github.com/$repo" "$project_dir/repo" --depth=1 --recursive &>/dev/null
fi
mkdocs_yml=$(cd "$project_dir/repo" && (2>/dev/null ls *mkdocs.y*ml || ls */mkdocs.y*ml) | head -1)
if ! [[ -d "$project_dir/venv" ]]; then
venv/bin/virtualenv "$project_dir/venv"
mkdir -p "$repo_dir/repo"
(
cd "$repo_dir/repo"
git init -b checkout
git fetch --depth=1 "$repo" "$branch"
git reset --hard FETCH_HEAD
)
if ! [[ -d "$repo_dir/venv" ]]; then
venv/bin/virtualenv "$repo_dir/venv"
fi
}

_build() {
echo "==== Building $1 ===="
"$project_dir/venv/bin/pip" freeze > "$project_dir/freeze-$1.txt"
(set -x; cd "$project_dir/repo"; ../venv/bin/mkdocs build --no-strict -f "$mkdocs_yml" -d "$(pwd)/../site-$1")
find "$project_dir/site-$1" -name "*.html" -print0 | xargs -0 -n16 -P4 venv/bin/python normalize_file.py
"$repo_dir/venv/bin/pip" freeze > "$repo_dir/freeze-$1.txt"
(
cd "$repo_dir/repo"
../venv/bin/mkdocs build --no-strict -f "$mkdocs_yml" -d "$(pwd)/../site-$1"
)
find "$repo_dir/site-$1" -name "*.html" -print0 | xargs -0 -n16 -P4 venv/bin/python normalize_file.py
}

build_current() {
clone_repo
deps=($(venv/bin/mkdocs get-deps -f "$project_dir/repo/$mkdocs_yml" || true))
group "Installing ${deps[*]}" \
"$project_dir/venv/bin/pip" install -U --force-reinstall "${deps[@]}"
group "Installing deps" \
"$repo_dir/venv/bin/pip" install -U --force-reinstall --no-deps -r "$info_dir/requirements.txt"
(export PYTHONPATH=; _build current)
}

build_latest() {
[ -n "$to_upgrade" ] || return
clone_repo
group "Upgrading $to_upgrade" \
"$project_dir/venv/bin/pip" install -U --force-reinstall "$to_upgrade"
"$repo_dir/venv/bin/pip" install -U --force-reinstall "$to_upgrade"
_build latest
}

compare() {
diff=$(diff -U0 "$project_dir/freeze-current.txt" "$project_dir/freeze-latest.txt") ||
diff=$(diff -U0 "$repo_dir/freeze-current.txt" "$repo_dir/freeze-latest.txt") ||
group "Diff of freezes" \
echo "$diff"
echo "==== Comparing ===="
diff \
-X exclude_patterns.txt \
-B --suppress-blank-empty \
--suppress-common-lines \
-U2 -w -r "$project_dir/site-current" "$project_dir/site-latest"
-U2 -w -r "$repo_dir/site-current" "$repo_dir/site-latest"
}

check() {
Expand Down
22 changes: 22 additions & 0 deletions populate_projects.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e -u -o pipefail

cd projects

for d in */; do (
d="${d%/}"
cd "$d"
printf "%s -> " "$d" >&2
if [[ ! -f 'url.txt' ]]; then
repo="https://github.com/${d//--//}"
branch="$(git remote show "$repo" | grep -oP 'HEAD branch: \K.+')"
echo "$repo/raw/$branch/mkdocs.yml" >url.txt
fi
cat url.txt >&2
curl -s -f -L -- $(cat url.txt) | (mkdocs get-deps -f - || true) | grep . >requirements.in
(cat requirements.extra 2>/dev/null || true) >>requirements.in
); done

echo */requirements.in | xargs -t -n1 -P4 pip-compile -q --no-annotate --no-header -U
rm */requirements.in
45 changes: 45 additions & 0 deletions projects/Noovolari--leapp/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
babel==2.13.1
certifi==2023.7.22
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
csscompressor==0.9.5
ghp-import==2.1.0
gitdb==4.0.11
gitpython==3.1.40
htmlmin2==0.1.13
idna==3.4
importlib-metadata==6.8.0
importlib-resources==6.1.1
jinja2==3.1.2
jsmin==3.0.1
lxml==4.9.3
markdown==3.5.1
markupsafe==2.1.3
mergedeep==1.3.4
mike==2.0.0
mkdocs==1.5.3
mkdocs-git-revision-date-plugin==0.3.2
mkdocs-img2fig-plugin==0.9.3
mkdocs-material==9.4.8
mkdocs-material-extensions==1.3
mkdocs-minify-plugin==0.7.1
mkdocs-video==1.5.0
packaging==23.2
paginate==0.5.6
pathspec==0.11.2
platformdirs==3.11.0
pygments==2.16.1
pymdown-extensions==10.3.1
pyparsing==3.1.1
python-dateutil==2.8.2
pyyaml==6.0.1
pyyaml-env-tag==0.1
regex==2023.10.3
requests==2.31.0
six==1.16.0
smmap==5.0.1
urllib3==2.0.7
verspec==0.1.0
watchdog==3.0.0
zipp==3.17.0
1 change: 1 addition & 0 deletions projects/Noovolari--leapp/url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/Noovolari/leapp/raw/master/mkdocs.yml
37 changes: 37 additions & 0 deletions projects/Rat-Rig--V-core-3/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
babel==2.13.1
bracex==2.4
certifi==2023.7.22
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
ghp-import==2.1.0
idna==3.4
jinja2==3.1.2
markdown==3.5.1
markupsafe==2.1.3
mergedeep==1.3.4
mkdocs==1.5.3
mkdocs-awesome-pages-plugin==2.9.2
mkdocs-macros-plugin==1.0.5
mkdocs-material==9.4.8
mkdocs-material-extensions==1.3
mkdocs-monorepo-plugin==1.0.5
natsort==8.4.0
packaging==23.2
paginate==0.5.6
pathspec==0.11.2
platformdirs==3.11.0
pygments==2.16.1
pymdown-extensions==10.3.1
python-dateutil==2.8.2
python-slugify==8.0.1
pyyaml==6.0.1
pyyaml-env-tag==0.1
regex==2023.10.3
requests==2.31.0
six==1.16.0
termcolor==2.3.0
text-unidecode==1.3
urllib3==2.0.7
watchdog==3.0.0
wcmatch==8.5
1 change: 1 addition & 0 deletions projects/Rat-Rig--V-core-3/url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/Rat-Rig/V-core-3/raw/main/mkdocs.yml
34 changes: 34 additions & 0 deletions projects/crystal-lang--crystal-book/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
babel==2.13.1
certifi==2023.7.22
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
ghp-import==2.1.0
idna==3.4
jinja2==3.1.2
markdown==3.5.1
markdown-callouts==0.3.0
markupsafe==2.1.3
mergedeep==1.3.4
mkdocs==1.5.3
mkdocs-code-validator==0.2.0
mkdocs-literate-nav==0.6.1
mkdocs-material==9.4.8
mkdocs-material-extensions==1.3
mkdocs-redirects==1.2.1
mkdocs-section-index==0.3.8
mkdocs-simple-hooks==0.1.5
packaging==23.2
paginate==0.5.6
pathspec==0.11.2
platformdirs==3.11.0
pygments==2.16.1
pymdown-extensions==10.3.1
python-dateutil==2.8.2
pyyaml==6.0.1
pyyaml-env-tag==0.1
regex==2023.10.3
requests==2.31.0
six==1.16.0
urllib3==2.0.7
watchdog==3.0.0
1 change: 1 addition & 0 deletions projects/crystal-lang--crystal-book/url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/crystal-lang/crystal-book/raw/master/mkdocs.yml
40 changes: 40 additions & 0 deletions projects/e-maxx-eng--e-maxx-eng/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
babel==2.13.1
certifi==2023.7.22
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
ghp-import==2.1.0
gitdb==4.0.11
gitpython==3.1.40
idna==3.4
jinja2==3.1.2
markdown==3.5.1
markupsafe==2.1.3
mergedeep==1.3.4
mkdocs==1.5.3
mkdocs-git-authors-plugin==0.7.2
mkdocs-git-committers-plugin-2==2.2.2
mkdocs-git-revision-date-localized-plugin==1.2.1
mkdocs-literate-nav==0.6.1
mkdocs-macros-plugin==1.0.5
mkdocs-material==9.4.8
mkdocs-material-extensions==1.3
mkdocs-rss-plugin==1.8.0
mkdocs-simple-hooks==0.1.5
packaging==23.2
paginate==0.5.6
pathspec==0.11.2
platformdirs==3.11.0
pygments==2.16.1
pymdown-extensions==10.3.1
python-dateutil==2.8.2
pytz==2023.3.post1
pyyaml==6.0.1
pyyaml-env-tag==0.1
regex==2023.10.3
requests==2.31.0
six==1.16.0
smmap==5.0.1
termcolor==2.3.0
urllib3==2.0.7
watchdog==3.0.0
1 change: 1 addition & 0 deletions projects/e-maxx-eng--e-maxx-eng/url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/e-maxx-eng/e-maxx-eng/raw/master/mkdocs.yml
38 changes: 38 additions & 0 deletions projects/emacs-lsp--lsp-mode/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
babel==2.13.1
bracex==2.4
certifi==2023.7.22
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
ghp-import==2.1.0
gitdb==4.0.11
gitpython==3.1.40
idna==3.4
jinja2==3.1.2
markdown==3.5.1
markupsafe==2.1.3
mergedeep==1.3.4
mkdocs==1.5.3
mkdocs-awesome-pages-plugin==2.9.2
mkdocs-git-revision-date-localized-plugin==1.2.1
mkdocs-material==9.4.8
mkdocs-material-extensions==1.3
mkdocs-rss-plugin==1.8.0
natsort==8.4.0
packaging==23.2
paginate==0.5.6
pathspec==0.11.2
platformdirs==3.11.0
pygments==2.16.1
pymdown-extensions==10.3.1
python-dateutil==2.8.2
pytz==2023.3.post1
pyyaml==6.0.1
pyyaml-env-tag==0.1
regex==2023.10.3
requests==2.31.0
six==1.16.0
smmap==5.0.1
urllib3==2.0.7
watchdog==3.0.0
wcmatch==8.5
1 change: 1 addition & 0 deletions projects/emacs-lsp--lsp-mode/url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/emacs-lsp/lsp-mode/raw/master/mkdocs.yml
Loading

0 comments on commit d648c0c

Please sign in to comment.