Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9515e86
fix: resolve nineteen reported issues in data sources, components, ap…
ludomikula Nov 29, 2026
ccc31d7
fix: redraw while a timer runs, and fix five smaller component, edito…
ludomikula Nov 30, 2026
7e66222
fix(node-service): an error answer fails a query of the OpenAPI-based…
ludomikula Dec 1, 2026
2727a41
fix(node-service): keep data values exact in DynamoDB, Turso, S3 and …
ludomikula Dec 1, 2026
687cd67
fix(api-service): a role change cannot remove a workspace's last admin
ludomikula Dec 1, 2026
17ba3f8
fix: warn about a published API key secret, and make the size limits …
ludomikula Dec 1, 2026
9ec0f74
fix(table): a Select column shows a value that matches no option
ludomikula Dec 2, 2026
747b530
docs: top-level await is not allowed in a Run JavaScript event handler
ludomikula Dec 2, 2026
ba25a2a
fix(client): a sign-in follows only a saved page of this site, and an…
ludomikula Dec 2, 2026
a6e5b23
fix(client): a page-load query waits for the modules and queries it d…
ludomikula Dec 2, 2026
a49d4c2
fix(table): Table Lite shows a Select value that matches no option
ludomikula Dec 4, 2026
6ae0ffc
docs: explain why await fails in an event handler and how to return a…
ludomikula Dec 4, 2026
fd09d63
fix(json-form): a submit right after typing keeps the validation errors
ludomikula Dec 4, 2026
4197212
fix(server): listings of many items answer instead of waiting forever
ludomikula Dec 4, 2026
9a1a0bd
fix(plugins): data source plugins keep integers, binaries and errors …
ludomikula Dec 4, 2026
cf2a1db
fix(module): a drawer or modal open in a module's editor stays inside…
ludomikula Dec 4, 2026
17dd7de
fix(server): an older save of an app does not overwrite a newer one
ludomikula Dec 4, 2026
c36de9e
fix(editor): a change made right after opening, or a save that failed…
ludomikula Dec 4, 2026
f681768
test(client): table, file and api tests assert what they claim
ludomikula Dec 4, 2026
79b413f
fix(client): a module whose app changes is loading until the new defi…
ludomikula Dec 4, 2026
da60eb7
fix(server): Chinese texts for the refused-save errors
ludomikula Dec 4, 2026
b86a118
fix(e2e): wait until the super admin can sign in before the tests start
ludomikula Dec 5, 2026
fa922d2
fix(server): a first start on a fresh database no longer aborts on du…
ludomikula Dec 5, 2026
79df92a
docs(e2e): the wait for the super admin no longer names a cause that …
ludomikula Dec 5, 2026
2aee41a
test(mysql): the container may take 15 minutes to start on a slow disk
ludomikula Dec 5, 2026
e43f8c7
fix(sonar): clear the nine new bugs SonarCloud reported on the pull r…
ludomikula Dec 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
213 changes: 213 additions & 0 deletions .github/scripts/check_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
#!/usr/bin/env python3
"""Documentation gates: the OpenAPI paths the docs name, and the self-hosting Compose quickstart.

Subcommands:
openapi-path every /api/docs/... path written after a Lowcoder host in docs/**/*.md is
one the server serves, as configured under `springdoc` in application.yaml.
compose-quickstart in the self-hosting guide, the files a section downloads (by `curl` or by
clicking a link) are enough for `docker compose config`, both branches name
the same files, and no Compose v1 command is left. The Deploy sections of
the all-in-one and separate-images setups must download a Compose file.

Exit 0: no finding. Exit 1: findings, one per line, each with file and line (a section's finding
names the line of its heading; a required heading that is absent altogether is reported at line 1). Exit 2: an input could not be read.

Limits: only the self-hosting guide is checked for the quickstart; other pages with downloads
are not parsed. `docker compose config` resolves files and starts nothing, so a quickstart that
resolves but does not run passes. It runs the local Compose version only, so it does not check
the minimum version the guide names. Downloads are recognised only in the two forms of the
guide: a raw.githubusercontent.com `curl ... -o $PWD/<name>` line, and a link whose text is the
file name pointing to github.com/.../blob/main/. OpenAPI paths after other hosts are ignored.
"""

import argparse
import re
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
from typing import Callable, Dict, List, NamedTuple, Optional, Sequence, Tuple

EXIT_OK = 0
EXIT_FINDINGS = 1
EXIT_ERROR = 2

FIRST_LINE = 1 # where a finding about the file as a whole points

CHECK_OPENAPI_PATH = "openapi-path"
CHECK_COMPOSE_QUICKSTART = "compose-quickstart"

APPLICATION_YAML = Path("server/api-service/lowcoder-server/src/main/resources/application.yaml")
DOCS_DIR = Path("docs")
GUIDE = Path("docs/setup-and-run/self-hosting/README.md")

LOWCODER_HOSTS = r"(?:localhost:3000|<yourdomain>|<Lowcoder-Location>|lowcoder\.cloud)"
DOC_PATH_RE = re.compile(LOWCODER_HOSTS + r"(/api/docs/[A-Za-z0-9._/-]*[A-Za-z0-9_/-])")
SPRINGDOC_PATH_RES = {
name: re.compile(r"^ " + name + r":\s*\n path:\s*(\S+)", re.M)
for name in ("api-docs", "swagger-ui")
}
SWAGGER_UI_WEBJAR_PAGE = "/api/docs/webjars/swagger-ui/index.html"

RAW_PREFIX = "https://raw.githubusercontent.com/lowcoder-org/lowcoder/main/"
BLOB_PREFIX = "https://github.com/lowcoder-org/lowcoder/blob/main/"
FILE_NAME = r"[A-Za-z0-9_-][A-Za-z0-9._-]*"
CURL_RE = re.compile(r"curl\s+(?:-\S+\s+)*" + re.escape(RAW_PREFIX) + r"([^\s<]+)\s+-o\s+\$PWD/(" + FILE_NAME + r")")
LINK_RE = re.compile(r"\[([A-Za-z0-9_-]*\.?[A-Za-z0-9._-]*\.(?:ya?ml|env))\]\(" + re.escape(BLOB_PREFIX) + r"([^)\s]+)\)")
HEADING_RE = re.compile(r"^(#{2,4}) ")
DEPLOY_HEADING = "#### Deploy"
REQUIRED_SECTION_ANCHORS = ("all-in-one", "multi")
COMPOSE_PATH_RE = re.compile(r"^deploy/docker/docker-compose[A-Za-z0-9-]*\.ya?ml$")
LEGACY_COMPOSE_RE = re.compile(
r"(?<![\w/.-])docker-compose\s+(?:-f|up|down|pull|rm|logs|ps|start|stop|restart|exec|run|build|config|create)\b")

BRANCH_CURL = "curl"
BRANCH_CLICK = "click"

RunConfig = Callable[[Path], Tuple[int, str]]
Downloads = Dict[str, str] # repository path -> file name in the quickstart directory


def openapi_path(root: Path) -> List[str]:
"""Return one finding per documented /api/docs path that the server does not serve."""
yaml = (root / APPLICATION_YAML).read_text(encoding="utf-8")
allowed = {SWAGGER_UI_WEBJAR_PAGE}
for name, pattern in SPRINGDOC_PATH_RES.items():
match = pattern.search(yaml)
if not match:
raise ValueError(f"{APPLICATION_YAML}: no springdoc {name} path")
allowed.add(match.group(1))
if not (root / DOCS_DIR).is_dir():
raise FileNotFoundError(f"{DOCS_DIR} is not a directory")
findings = []
for doc in sorted((root / DOCS_DIR).rglob("*.md")):
for number, line in enumerate(doc.read_text(encoding="utf-8").splitlines(), 1):
for match in DOC_PATH_RE.finditer(line):
if match.group(1) not in allowed:
findings.append(f"{doc.relative_to(root)}:{number}: {match.group(0)} is not served "
f"(allowed: {', '.join(sorted(allowed))})")
return findings


class Section(NamedTuple):
title: str
number: int # line of the heading, 1-based
lines: List[str]


def sections(text: str) -> List[Section]:
"""Split the guide at its ##, ### and #### headings."""
result = [Section("(top)", FIRST_LINE, [])]
for number, line in enumerate(text.splitlines(), 1):
if HEADING_RE.match(line):
result.append(Section(line.strip(), number, []))
else:
result[-1].lines.append(line)
return result


def anchor_of(title: str) -> Optional[str]:
return next((a for a in REQUIRED_SECTION_ANCHORS if f'id="{a}"' in title), None)


def required_deploy_sections(parts: Sequence[Section]) -> Dict[str, int]:
"""Map each required anchor to the index of the first Deploy section below its ### heading."""
found: Dict[str, int] = {}
anchor = None
for index, (title, _, _) in enumerate(parts):
level = HEADING_RE.match(title)
if level and len(level.group(1)) < 4:
anchor = anchor_of(title)
elif anchor and title == DEPLOY_HEADING and anchor not in found:
found[anchor] = index
return found


def compose_config(compose_file: Path) -> Tuple[int, str]:
"""Run `docker compose config` on the file; return the exit code and the first error line."""
done = subprocess.run(["docker", "compose", "-f", str(compose_file), "config", "--quiet"],
cwd=compose_file.parent, capture_output=True, text=True, check=False)
return done.returncode, (done.stderr.strip().splitlines() or [""])[0]


def check_downloads(root: Path, where: str, downloads: Downloads, run_config: RunConfig) -> List[str]:
"""Put exactly the downloaded files into an empty directory and resolve each Compose file."""
findings = []
with tempfile.TemporaryDirectory(prefix="check-docs-") as work:
workdir = Path(work)
for repo_path, name in downloads.items():
source = (root / repo_path).resolve()
if not source.is_relative_to(root.resolve()) or not source.is_file():
findings.append(f"{where}: downloads {repo_path}, which is not in the repository")
continue
shutil.copyfile(source, workdir / name)
for repo_path, name in downloads.items():
if not COMPOSE_PATH_RE.match(repo_path) or not (workdir / name).is_file():
continue
code, message = run_config(workdir / name)
if code != 0:
findings.append(f"{where}: with only {', '.join(downloads.values())}, "
f"'docker compose -f {name} config' fails: {message.replace(work, '<dir>')}")
return findings


def compose_quickstart(root: Path, run_config: RunConfig = compose_config) -> List[str]:
"""Return the findings of the self-hosting guide's Compose quickstart."""
text = (root / GUIDE).read_text(encoding="utf-8")
findings = [f"{GUIDE}:{number}: runs the Compose v1 command 'docker-compose'"
for number, line in enumerate(text.splitlines(), 1) if LEGACY_COMPOSE_RE.search(line)]
parts = sections(text)
required = required_deploy_sections(parts)
for anchor in REQUIRED_SECTION_ANCHORS:
if anchor not in required:
where = next((f"{GUIDE}:{p.number}" for p in parts if anchor_of(p.title) == anchor), f"{GUIDE}:{FIRST_LINE}")
findings.append(f"{where}: no '{DEPLOY_HEADING}' section below the heading with id \"{anchor}\"")
required_names = {index: anchor for anchor, index in required.items()}
for index, (heading, number, lines) in enumerate(parts):
body = "\n".join(lines)
branches: Dict[str, Downloads] = {
BRANCH_CURL: {path: name for path, name in CURL_RE.findall(body)},
BRANCH_CLICK: {path: name for name, path in LINK_RE.findall(body)},
}
title = f"{heading} of {required_names[index]}" if index in required_names else heading
where = f"{GUIDE}:{number} [{title}]"
if index in required_names:
for branch, downloads in branches.items():
if not any(COMPOSE_PATH_RE.match(path) for path in downloads):
findings.append(f"{where}: no Compose file in the Deploy section's {branch} branch")
if not any(branches.values()):
continue
for branch, other in ((BRANCH_CLICK, BRANCH_CURL), (BRANCH_CURL, BRANCH_CLICK)):
missing = sorted(set(branches[other]) - set(branches[branch]))
if missing:
findings.append(f"{where}: the {branch} branch does not name {', '.join(missing)}")
checked: List[Downloads] = []
for downloads in branches.values():
if downloads and downloads not in checked:
checked.append(downloads)
findings.extend(f for f in check_downloads(root, where, downloads, run_config) if f not in findings)
return findings


def main(argv: Sequence[str], run_config: RunConfig = compose_config) -> int:
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("check", choices=[CHECK_OPENAPI_PATH, CHECK_COMPOSE_QUICKSTART])
parser.add_argument("--root", type=Path, default=Path("."))
args = parser.parse_args(argv)
try:
if args.check == CHECK_OPENAPI_PATH:
findings = openapi_path(args.root)
else:
findings = compose_quickstart(args.root, run_config)
except (OSError, ValueError) as error:
print(f"check_docs {args.check}: {error}", file=sys.stderr)
return EXIT_ERROR
for finding in findings:
print(finding)
print(f"check_docs {args.check}: {len(findings)} finding(s)")
return EXIT_FINDINGS if findings else EXIT_OK


if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
183 changes: 183 additions & 0 deletions .github/scripts/tests/test_check_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
import contextlib
import io
import sys
import tempfile
import unittest
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))

import check_docs as cd # noqa: E402

NEEDS = "# needs: "
COMPOSE = "deploy/docker/docker-compose.yaml"
COMPOSE_MULTI = "deploy/docker/docker-compose-multi.yaml"
ENV = "deploy/docker/default.env"
ENV_MULTI = "deploy/docker/default-multi.env"
AIO_FILES = {COMPOSE: "docker-compose.yml", ENV: "default.env"}
MULTI_FILES = {COMPOSE_MULTI: "docker-compose-multi.yml", ENV: "default.env", ENV_MULTI: "default-multi.env"}
YAML = ("springdoc:\n api-docs:\n path: /api/docs/openapi.json\n"
" swagger-ui:\n path: /api/docs/swagger-ui\n")


def fake_config(compose_file):
"""Stands in for `docker compose config`: the files named in `# needs:` lines must be there."""
for line in compose_file.read_text(encoding="utf-8").splitlines():
if line.startswith(NEEDS) and not (compose_file.parent / line[len(NEEDS):]).is_file():
return 1, f"env file {compose_file.parent / line[len(NEEDS):]} not found"
return 0, ""


def curls(files):
return "".join(f"curl {cd.RAW_PREFIX}{path} -o $PWD/{name}\n" for path, name in files.items())


def links(files):
return " ".join(f"[{name}]({cd.BLOB_PREFIX}{path})" for path, name in files.items()) + "\n"


def guide(aio_curl=AIO_FILES, aio_click=AIO_FILES, multi=MULTI_FILES, extra="", with_multi=True):
text = (f"# Self-hosting\n[Docker Compose]({cd.BLOB_PREFIX}{COMPOSE_MULTI})\n"
'### All-in-one image <a id="all-in-one"></a>\n#### Prerequisites\n#### Deploy\n'
f"{links(aio_click)}{curls(aio_curl)}docker compose up -d\n{extra}")
if with_multi:
text += ('### Separate images <a id="multi"></a>\n#### Deploy\n'
f"{links(multi)}{curls(multi)}")
return text


class TreeTest(unittest.TestCase):
def setUp(self):
temporary = tempfile.TemporaryDirectory()
self.addCleanup(temporary.cleanup)
self.root = Path(temporary.name)
self.write(str(cd.APPLICATION_YAML), YAML)
self.write(COMPOSE, NEEDS + "default.env\n")
self.write(COMPOSE_MULTI, NEEDS + "default.env\n" + NEEDS + "default-multi.env\n")
self.write(ENV, "A=1\n")
self.write(ENV_MULTI, "B=1\n")
self.write(str(cd.GUIDE), guide())

def write(self, relative, content):
path = self.root / relative
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(content, encoding="utf-8")

def quickstart(self):
findings = cd.compose_quickstart(self.root, fake_config)
print("\n".join(findings))
return findings

def run_main(self, check):
with contextlib.redirect_stdout(io.StringIO()) as out, contextlib.redirect_stderr(io.StringIO()) as err:
code = cd.main([check, "--root", str(self.root)], fake_config)
print(out.getvalue() + err.getvalue())
return code


class OpenApiPathTest(TreeTest):
def test_served_paths_pass(self):
self.write("docs/api.md", "<Lowcoder-Location>/api/docs/openapi.json.\n"
"localhost:3000/api/docs/webjars/swagger-ui/index.html\n")
self.assertEqual([], cd.openapi_path(self.root))

def test_a_path_the_server_does_not_serve_is_a_finding_with_file_and_line(self):
self.write("docs/api.md", "text\nhttps://<yourdomain>/api/docs/api-docs\n")
findings = cd.openapi_path(self.root)
self.assertEqual(1, len(findings), findings)
self.assertIn("docs/api.md:2: <yourdomain>/api/docs/api-docs is not served", findings[0])

def test_an_external_host_is_ignored(self):
self.write("docs/api.md", "https://example.org/api/docs/api-docs\n")
self.assertEqual([], cd.openapi_path(self.root))

def test_a_missing_springdoc_path_is_an_error(self):
self.write(str(cd.APPLICATION_YAML), "springdoc:\n api-docs:\n path: /api/docs/openapi.json\n")
self.assertEqual(cd.EXIT_ERROR, self.run_main(cd.CHECK_OPENAPI_PATH))


class ComposeQuickstartTest(TreeTest):
def assert_finding(self, findings, *parts):
self.assertTrue(any(all(part in f for part in parts) for f in findings), (parts, findings))

def test_a_complete_guide_passes(self):
self.assertEqual([], self.quickstart())

def test_a_section_missing_a_needed_file_fails_and_passes_once_it_is_downloaded(self):
short = {COMPOSE: "docker-compose.yml"}
self.write(str(cd.GUIDE), guide(aio_curl=short, aio_click=short))
self.assert_finding(self.quickstart(), "all-in-one", "env file <dir>/default.env not found")
self.write(str(cd.GUIDE), guide())
self.assertEqual([], self.quickstart())

def test_the_v1_command_is_a_finding(self):
self.write(str(cd.GUIDE), guide(extra="docker-compose -f docker-compose.yml up -d\n"))
findings = self.quickstart()
self.assertEqual(1, len(findings), findings)
self.assert_finding(findings, "Compose v1 command")

def test_a_download_of_a_missing_path_is_a_finding(self):
files = dict(AIO_FILES, **{"deploy/docker/gone.env": "gone.env"})
self.write(str(cd.GUIDE), guide(aio_curl=files, aio_click=files))
self.assert_finding(self.quickstart(), "deploy/docker/gone.env, which is not in the repository")

def test_a_path_outside_the_repository_is_not_copied(self):
files = dict(AIO_FILES, **{"../outside.env": "outside.env"})
self.write(str(cd.GUIDE), guide(aio_curl=files, aio_click=files))
self.assert_finding(self.quickstart(), "../outside.env, which is not in the repository")

def test_a_click_branch_with_fewer_files_names_the_missing_path(self):
self.write(str(cd.GUIDE), guide(aio_click={COMPOSE: "docker-compose.yml"}))
self.assert_finding(self.quickstart(), f"the click branch does not name {ENV}")

def test_a_guide_without_the_multi_image_deploy_section_is_a_finding(self):
self.write(str(cd.GUIDE), guide(with_multi=False))
self.assert_finding(self.quickstart(), f"{cd.GUIDE}:{cd.FIRST_LINE}: ", 'id "multi"')

def test_a_deploy_section_without_a_compose_file_is_a_finding(self):
self.write(str(cd.GUIDE), guide(aio_curl={}, aio_click={}))
findings = self.quickstart()
for branch in (cd.BRANCH_CURL, cd.BRANCH_CLICK):
self.assert_finding(findings, f"no Compose file in the Deploy section's {branch} branch")

def test_downloads_under_prerequisites_do_not_count_for_the_deploy_section(self):
text = guide(aio_curl={}, aio_click={}).replace(
"#### Prerequisites\n", "#### Prerequisites\n" + links(AIO_FILES) + curls(AIO_FILES))
self.write(str(cd.GUIDE), text)
self.assert_finding(self.quickstart(), "no Compose file in the Deploy section")


class LineNumberTest(TreeTest):
def line_of(self, text, start):
return next(n for n, line in enumerate(text.splitlines(), 1) if line.startswith(start))

def test_every_section_finding_names_the_line_of_its_heading(self):
files = dict(AIO_FILES, **{"deploy/docker/gone.env": "gone.env"})
short = {COMPOSE: "docker-compose.yml"}
text = guide(aio_curl=files, aio_click=short)
self.write(str(cd.GUIDE), text)
findings = self.quickstart()
expected = f"{cd.GUIDE}:{self.line_of(text, '#### Deploy')} [#### Deploy of all-in-one]: "
self.assertGreaterEqual(len(findings), 3, findings) # missing path, failed config, branch mismatch
for finding in findings:
self.assertTrue(finding.startswith(expected), (expected, finding))

def test_a_missing_deploy_section_names_the_line_of_its_setup_heading(self):
text = guide(with_multi=False) + '### Separate images <a id="multi"></a>\n'
self.write(str(cd.GUIDE), text)
expected = f"{cd.GUIDE}:{self.line_of(text, '### Separate')}: no '#### Deploy' section"
self.assertTrue(any(f.startswith(expected) for f in self.quickstart()), expected)


class MainTest(TreeTest):
def test_exit_codes(self):
self.assertEqual(cd.EXIT_OK, self.run_main(cd.CHECK_COMPOSE_QUICKSTART))
self.assertEqual(cd.EXIT_OK, self.run_main(cd.CHECK_OPENAPI_PATH))
self.write(str(cd.GUIDE), guide(with_multi=False))
self.assertEqual(cd.EXIT_FINDINGS, self.run_main(cd.CHECK_COMPOSE_QUICKSTART))
(self.root / cd.GUIDE).unlink()
self.assertEqual(cd.EXIT_ERROR, self.run_main(cd.CHECK_COMPOSE_QUICKSTART))


if __name__ == "__main__":
unittest.main()
Loading
Loading