forked from docs/doc-exports
Compare commits
1 Commits
Precheck
...
remove_swi
| Author | SHA1 | Date | |
|---|---|---|---|
| ece5386512 |
@ -1,81 +0,0 @@
|
|||||||
# .gitea/workflows/class-txt-check.yml
|
|
||||||
name: Docs Precheck - CLASS.TXT.json Check
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [opened, reopened, synchronize, edited]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
class-txt-check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.12'
|
|
||||||
|
|
||||||
- name: Get changed CLASS.TXT.json files
|
|
||||||
id: changed-files
|
|
||||||
run: |
|
|
||||||
BASE_SHA="${{ gitea.event.pull_request.base.sha }}"
|
|
||||||
changed=$(git diff --name-only ${BASE_SHA}...HEAD | grep -E 'CLASS\.TXT\.json$' | tr '\n' ' ' || true)
|
|
||||||
echo "files=$changed" >> $GITHUB_OUTPUT
|
|
||||||
echo "CHANGED_FILES=$changed" >> $GITHUB_ENV
|
|
||||||
echo "Changed CLASS.TXT.json files: $changed"
|
|
||||||
|
|
||||||
- name: Run duplicate title check
|
|
||||||
id: class-check
|
|
||||||
run: |
|
|
||||||
python3 .gitea/workflows/helpers/class-txt-check.py
|
|
||||||
|
|
||||||
- name: Comment on PR with violations
|
|
||||||
if: failure() && steps.class-check.outcome == 'failure'
|
|
||||||
env:
|
|
||||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
||||||
REPO: ${{ gitea.repository }}
|
|
||||||
PR_NUMBER: ${{ gitea.event.pull_request.number }}
|
|
||||||
TOKEN: ${{ gitea.token }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Ensure URL starts with http
|
|
||||||
if [[ ! "${GITEA_SERVER_URL}" =~ ^https?:// ]]; then
|
|
||||||
GITEA_SERVER_URL="http://${GITEA_SERVER_URL}"
|
|
||||||
echo "Added http:// prefix to URL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate comment message
|
|
||||||
MSG=$(python3 .gitea/workflows/helpers/class-comment.py)
|
|
||||||
echo "$MSG"
|
|
||||||
|
|
||||||
# Extract body from JSON
|
|
||||||
BODY=$(echo "$MSG" | python3 -c "import sys, json; print(json.load(sys.stdin)['body'])")
|
|
||||||
|
|
||||||
# Build the full URL
|
|
||||||
FULL_URL="${GITEA_SERVER_URL}/api/v1/repos/${REPO}/issues/${PR_NUMBER}/comments"
|
|
||||||
echo "Posting comment to: ${FULL_URL}"
|
|
||||||
|
|
||||||
# Comment on PR
|
|
||||||
curl -sS -X POST \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${FULL_URL}" \
|
|
||||||
-d "$(echo "$BODY" | python3 -c "import sys, json; print(json.dumps({'body': sys.stdin.read()}))")"
|
|
||||||
|
|
||||||
- name: Final status
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
if [ -f violations.json ]; then
|
|
||||||
echo "::error::CLASS.TXT.json check failed. See previous step for details."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@ -1,84 +0,0 @@
|
|||||||
# .gitea/workflows/docs-precheck.yml
|
|
||||||
name: Docs Precheck - Underscore Check
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [opened, reopened, synchronize, edited]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docs-precheck:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.12'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pip install beautifulsoup4 lxml
|
|
||||||
|
|
||||||
- name: Get changed HTML files
|
|
||||||
id: changed-files
|
|
||||||
run: |
|
|
||||||
BASE_SHA="${{ gitea.event.pull_request.base.sha }}"
|
|
||||||
changed=$(git diff --name-only ${BASE_SHA}...HEAD | grep -E '\.(html|htm)$' | tr '\n' ' ' || true)
|
|
||||||
echo "files=$changed" >> $GITHUB_OUTPUT
|
|
||||||
echo "CHANGED_FILES=$changed" >> $GITHUB_ENV
|
|
||||||
echo "Changed HTML files: $changed"
|
|
||||||
|
|
||||||
- name: Run underscore check
|
|
||||||
id: underscore-check
|
|
||||||
run: |
|
|
||||||
python3 .gitea/workflows/helpers/underscore-check.py
|
|
||||||
|
|
||||||
- name: Comment on PR with violations
|
|
||||||
if: failure() && steps.underscore-check.outcome == 'failure'
|
|
||||||
env:
|
|
||||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
||||||
REPO: ${{ gitea.repository }}
|
|
||||||
PR_NUMBER: ${{ gitea.event.pull_request.number }}
|
|
||||||
TOKEN: ${{ gitea.token }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Ensure URL starts with http
|
|
||||||
if [[ ! "${GITEA_SERVER_URL}" =~ ^https?:// ]]; then
|
|
||||||
GITEA_SERVER_URL="http://${GITEA_SERVER_URL}"
|
|
||||||
echo "Added http:// prefix to URL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate comment message
|
|
||||||
MSG=$(python3 .gitea/workflows/helpers/underscore-comment.py)
|
|
||||||
echo "$MSG"
|
|
||||||
|
|
||||||
# Extract body from JSON
|
|
||||||
BODY=$(echo "$MSG" | python3 -c "import sys, json; print(json.load(sys.stdin)['body'])")
|
|
||||||
|
|
||||||
# Build the full URL
|
|
||||||
FULL_URL="${GITEA_SERVER_URL}/api/v1/repos/${REPO}/issues/${PR_NUMBER}/comments"
|
|
||||||
echo "Posting comment to: ${FULL_URL}"
|
|
||||||
|
|
||||||
# Comment on PR
|
|
||||||
curl -sS -X POST \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${FULL_URL}" \
|
|
||||||
-d "$(echo "$BODY" | python3 -c "import sys, json; print(json.dumps({'body': sys.stdin.read()}))")"
|
|
||||||
|
|
||||||
- name: Final status
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
if [ -f violations.json ]; then
|
|
||||||
echo "::error::Underscore check failed. See previous step for details."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@ -1,71 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
Generate PR comment for CLASS.TXT.json duplicate title violations.
|
|
||||||
|
|
||||||
This script reads violations.json (created by class-txt-check.py) and generates
|
|
||||||
a formatted markdown comment to be posted on the PR. The comment includes:
|
|
||||||
- File path where violations were found
|
|
||||||
- Parent document title and code
|
|
||||||
- The duplicate title
|
|
||||||
- Document codes that share the duplicate title
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
Run after class-txt-check.py fails. Reads violations.json and outputs JSON
|
|
||||||
with 'body' field containing the markdown comment text.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import json
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
try:
|
|
||||||
with open("violations.json", "r") as f:
|
|
||||||
violations = json.load(f)
|
|
||||||
except Exception:
|
|
||||||
violations = []
|
|
||||||
|
|
||||||
if not violations:
|
|
||||||
print(json.dumps({"body": "No violations to report"}))
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
# Group violations by file
|
|
||||||
by_file = {}
|
|
||||||
for v in violations:
|
|
||||||
key = v["file"]
|
|
||||||
if key not in by_file:
|
|
||||||
by_file[key] = []
|
|
||||||
by_file[key].append(v)
|
|
||||||
|
|
||||||
# Build message
|
|
||||||
lines = [
|
|
||||||
"❌ **Duplicate title detected in CLASS.TXT.json**",
|
|
||||||
"",
|
|
||||||
"Found child documents with duplicate titles under the same parent:",
|
|
||||||
"",
|
|
||||||
]
|
|
||||||
|
|
||||||
for filepath, file_violations in by_file.items():
|
|
||||||
lines.append(f"**{filepath}:**")
|
|
||||||
for v in file_violations:
|
|
||||||
parent_code = v["parent_code"]
|
|
||||||
parent_title = v["parent_title"]
|
|
||||||
duplicate_title = v["duplicate_title"]
|
|
||||||
codes = v["codes"]
|
|
||||||
|
|
||||||
lines.append(f" - Parent: `{parent_title}` (code: `{parent_code}`)")
|
|
||||||
lines.append(f" Duplicate title: `{duplicate_title}`")
|
|
||||||
for code in codes:
|
|
||||||
lines.append(f" - Document code: `{code}`")
|
|
||||||
lines.append("")
|
|
||||||
|
|
||||||
lines.append(
|
|
||||||
"**Please ensure all child documents under the same parent have unique titles.**"
|
|
||||||
)
|
|
||||||
|
|
||||||
message = "\n".join(lines)
|
|
||||||
print(json.dumps({"body": message}))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,63 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
Generate PR comment for metadata registration check violations.
|
|
||||||
|
|
||||||
This script reads violations.json (created by metadata-check.py) and generates
|
|
||||||
a formatted markdown comment to be posted on the PR. The comment includes:
|
|
||||||
- HTML file path that was added but not registered
|
|
||||||
- Which metadata files it's missing from (CLASS.TXT.json, ALL_META.TXT.json)
|
|
||||||
- Whether the metadata files don't exist or the file is simply missing from them
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
Run after metadata-check.py fails. Reads violations.json and outputs JSON
|
|
||||||
with 'body' field containing the markdown comment text.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import json
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
try:
|
|
||||||
with open("violations.json", "r") as f:
|
|
||||||
violations = json.load(f)
|
|
||||||
except Exception:
|
|
||||||
violations = []
|
|
||||||
|
|
||||||
if not violations:
|
|
||||||
print(json.dumps({"body": "No violations to report"}))
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
# Build message
|
|
||||||
lines = [
|
|
||||||
"❌ **HTML file not registered in metadata**",
|
|
||||||
"",
|
|
||||||
"The following HTML files were added but are not properly registered in the metadata files:",
|
|
||||||
"",
|
|
||||||
]
|
|
||||||
|
|
||||||
for v in violations:
|
|
||||||
html_file = v["file"]
|
|
||||||
missing_from = v["missing_from"]
|
|
||||||
|
|
||||||
lines.append(f"**{html_file}**")
|
|
||||||
for missing in missing_from:
|
|
||||||
# Check if it's a "file not found" case
|
|
||||||
if "(file not found)" in missing:
|
|
||||||
lines.append(
|
|
||||||
f" ❌ Missing from: `{missing.split(' (')[0]}` (metadata file does not exist)"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
lines.append(f" ❌ Missing from: `{missing}`")
|
|
||||||
lines.append("")
|
|
||||||
|
|
||||||
lines.append(
|
|
||||||
"**Please add the new HTML files to both `CLASS.TXT.json` and `ALL_META.TXT.json` in the same directory.**"
|
|
||||||
)
|
|
||||||
|
|
||||||
message = "\n".join(lines)
|
|
||||||
print(json.dumps({"body": message}))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,68 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
Generate PR comment for underscore check violations.
|
|
||||||
|
|
||||||
This script reads violations.json (created by underscore-check.py) and generates
|
|
||||||
a formatted markdown comment to be posted on the PR. The comment includes:
|
|
||||||
- File path where violations were found
|
|
||||||
- Line number of each violation
|
|
||||||
- The offending word (ending with underscore)
|
|
||||||
- Context showing where the violation appears in the HTML
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
Run after underscore-check.py fails. Reads violations.json and outputs JSON
|
|
||||||
with 'body' field containing the markdown comment text.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import json
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
try:
|
|
||||||
with open("violations.json", "r") as f:
|
|
||||||
violations = json.load(f)
|
|
||||||
except Exception:
|
|
||||||
violations = []
|
|
||||||
|
|
||||||
if not violations:
|
|
||||||
print(json.dumps({"body": "No violations to report"}))
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
# Group violations by file
|
|
||||||
by_file = {}
|
|
||||||
for v in violations:
|
|
||||||
key = v["file"]
|
|
||||||
if key not in by_file:
|
|
||||||
by_file[key] = []
|
|
||||||
by_file[key].append(v)
|
|
||||||
|
|
||||||
# Build message
|
|
||||||
lines = [
|
|
||||||
"❌ **Underscore check failed**",
|
|
||||||
"",
|
|
||||||
"Found words ending with underscore (not followed by alphanumeric characters):",
|
|
||||||
"",
|
|
||||||
]
|
|
||||||
|
|
||||||
for filepath, file_violations in by_file.items():
|
|
||||||
lines.append(f"**{filepath}:**")
|
|
||||||
for v in file_violations:
|
|
||||||
word = v["word"]
|
|
||||||
line_num = v["line"]
|
|
||||||
context = v["context"]
|
|
||||||
# Escape markdown special chars in context
|
|
||||||
context = context.replace("`", "\\`")
|
|
||||||
lines.append(f" - Line {line_num}: `{word}` in context: `{context}`")
|
|
||||||
lines.append("")
|
|
||||||
|
|
||||||
lines.append(
|
|
||||||
"**Please fix these issues as soon as possible.** Words should not end with an underscore unless followed by alphanumeric characters (A-Za-z0-9)."
|
|
||||||
)
|
|
||||||
|
|
||||||
message = "\n".join(lines)
|
|
||||||
print(json.dumps({"body": message}))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@ -1,81 +0,0 @@
|
|||||||
# .gitea/workflows/metadata-check.yml
|
|
||||||
name: Docs Precheck - Metadata Registration Check
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [opened, reopened, synchronize, edited]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
metadata-check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.12'
|
|
||||||
|
|
||||||
- name: Get added HTML files
|
|
||||||
id: added-files
|
|
||||||
run: |
|
|
||||||
BASE_SHA="${{ gitea.event.pull_request.base.sha }}"
|
|
||||||
added=$(git diff --name-status ${BASE_SHA}...HEAD | grep "^A" | awk '{print $2}' | grep -E '\.html$' | tr '\n' ' ' || true)
|
|
||||||
echo "files=$added" >> $GITHUB_OUTPUT
|
|
||||||
echo "ADDED_FILES=$added" >> $GITHUB_ENV
|
|
||||||
echo "Added HTML files: $added"
|
|
||||||
|
|
||||||
- name: Run metadata registration check
|
|
||||||
id: metadata-check
|
|
||||||
run: |
|
|
||||||
python3 .gitea/workflows/helpers/metadata-check.py
|
|
||||||
|
|
||||||
- name: Comment on PR with violations
|
|
||||||
if: failure() && steps.metadata-check.outcome == 'failure'
|
|
||||||
env:
|
|
||||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
||||||
REPO: ${{ gitea.repository }}
|
|
||||||
PR_NUMBER: ${{ gitea.event.pull_request.number }}
|
|
||||||
TOKEN: ${{ gitea.token }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Ensure URL starts with http
|
|
||||||
if [[ ! "${GITEA_SERVER_URL}" =~ ^https?:// ]]; then
|
|
||||||
GITEA_SERVER_URL="http://${GITEA_SERVER_URL}"
|
|
||||||
echo "Added http:// prefix to URL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate comment message
|
|
||||||
MSG=$(python3 .gitea/workflows/helpers/metadata-comment.py)
|
|
||||||
echo "$MSG"
|
|
||||||
|
|
||||||
# Extract body from JSON
|
|
||||||
BODY=$(echo "$MSG" | python3 -c "import sys, json; print(json.load(sys.stdin)['body'])")
|
|
||||||
|
|
||||||
# Build the full URL
|
|
||||||
FULL_URL="${GITEA_SERVER_URL}/api/v1/repos/${REPO}/issues/${PR_NUMBER}/comments"
|
|
||||||
echo "Posting comment to: ${FULL_URL}"
|
|
||||||
|
|
||||||
# Comment on PR
|
|
||||||
curl -sS -X POST \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${FULL_URL}" \
|
|
||||||
-d "$(echo "$BODY" | python3 -c "import sys, json; print(json.dumps({'body': sys.stdin.read()}))")"
|
|
||||||
|
|
||||||
- name: Final status
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
if [ -f violations.json ]; then
|
|
||||||
echo "::error::Metadata registration check failed. See previous step for details."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,11 +0,0 @@
|
|||||||
rules:
|
|
||||||
path-starts-with-slash-no-spaces:
|
|
||||||
description: Path must start with / and contain no spaces
|
|
||||||
message: "Path '{{property}}' must start with '/' and must not contain spaces"
|
|
||||||
severity: error
|
|
||||||
given: $.paths
|
|
||||||
then:
|
|
||||||
field: "@key"
|
|
||||||
function: pattern
|
|
||||||
functionOptions:
|
|
||||||
match: "^\\/[^\\s]*$"
|
|
||||||
17
.yamllint
17
.yamllint
@ -1,17 +0,0 @@
|
|||||||
# .yamllint
|
|
||||||
extends: default
|
|
||||||
|
|
||||||
yaml-files:
|
|
||||||
- '*.yaml'
|
|
||||||
- '*.yml'
|
|
||||||
|
|
||||||
rules:
|
|
||||||
line-length:
|
|
||||||
max: 120
|
|
||||||
level: warning
|
|
||||||
indentation:
|
|
||||||
spaces: 2 # number of spaces per indent level
|
|
||||||
indent-sequences: consistent # or true/false/whatever
|
|
||||||
level: error
|
|
||||||
document-start:
|
|
||||||
level: warning
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user