mirror of
https://github.com/luongnv89/claude-howto.git
synced 2026-12-03 02:03:31 +01:00
Type: chore ## Summary Follow-up to #208 (Persian translation). It wires `fa/` into the repo tooling the same way #228 did for Korean, and syncs the translation from v2.1.310 to v2.1.316. ## Changes **Tooling** (`feat(i18n)`) - `build_epub.py`: `--lang fa` builds `claude-howto-guide-fa.epub`. - `build_website.py`: `--lang fa`; `fa` is in `EXCLUDE_DIRS`, so Persian pages stay out of the English site. - CI: the EPUB matrix in `test.yml` now includes `fa`. The markdown-rendering docstring and test now list `fa`. - Pre-commit: new `persian-markdown-lint`, `persian-cross-references`, `persian-mermaid` and `persian-link-check` hooks. `persian-mermaid` is added to the offline `SKIP=` lists in `.pre-commit-config.yaml`, `CONTRIBUTING.md` and `CLAUDE.md`. - `scripts/README.md`: usage text updated. - Language switchers: `فارسی` added to `vi/`, `zh/`, `uk/`, `ja/` and `ko/` READMEs and to the landing-page footer. **Translation** (`docs(fa)`) - Applies the English changes from #230 (v2.1.316) to the 15 affected `fa/` files: 192 lines added, 104 removed. - Moves the misplaced `دسترسپذیری (v2.1.310)` Monitor callout in `fa/09-advanced-features/README.md` to the position it has in English. ## Verification | Check | Result | |---|---| | `fa/` line counts, URLs and code-fence positions vs English `main` | identical in all files | | `pre-commit run --all-files`, including the new Persian hooks | pass | | `pytest scripts/tests/` | 198 passed | | ruff, mypy, bandit | clean | | `build_epub.py --lang fa` + `check_epub_diagrams.py` | 61 diagrams, 0 placeholders | | `build_website.py --lang fa` | builds; English site has no `fa/` pages | ## Known limitations (not in this PR) - The EPUB and website templates hard-code `lang="en"` and have no `dir="rtl"`, so Persian pages render left-to-right. Fixing that means passing the language into the HTML templates for every locale. - `fa/.github/` has no `TESTING.md`, `SECURITY_REPORTING.md` or `pull_request_template.md`; the other locales have all three.
254 lines
7.3 KiB
YAML
254 lines
7.3 KiB
YAML
name: Automated Testing
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
paths:
|
|
- 'scripts/**'
|
|
- '.github/workflows/test.yml'
|
|
- 'pyproject.toml'
|
|
- 'requirements*.txt'
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- 'scripts/**'
|
|
- '.github/workflows/test.yml'
|
|
- 'pyproject.toml'
|
|
- 'requirements*.txt'
|
|
|
|
# Cancel in-progress runs for the same branch
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
pytest:
|
|
name: Unit Tests (Python ${{ matrix.python-version }})
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
python-version: ['3.10', '3.11', '3.12']
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
run: uv python install ${{ matrix.python-version }}
|
|
|
|
# The Pele helper tests run the real Node.js protocol; under CI they
|
|
# fail instead of skipping when Node.js is missing.
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Create venv and install dependencies
|
|
run: |
|
|
uv venv
|
|
uv pip install -r scripts/requirements-dev.txt
|
|
|
|
- name: Run pytest
|
|
run: uv run pytest scripts/tests/ -v --tb=short --cov=scripts --cov-report=xml --cov-report=html
|
|
continue-on-error: false
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
files: ./coverage.xml
|
|
flags: unittests
|
|
name: codecov-python-${{ matrix.python-version }}
|
|
fail_ci_if_error: false
|
|
verbose: true
|
|
|
|
- name: Archive test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: pytest-results-${{ matrix.python-version }}
|
|
path: |
|
|
coverage.xml
|
|
htmlcov/
|
|
retention-days: 7
|
|
|
|
lint:
|
|
name: Code Quality (Lint & Format)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
|
|
- name: Set up Python
|
|
run: uv python install 3.11
|
|
|
|
- name: Create venv and install Ruff
|
|
run: |
|
|
uv venv
|
|
uv pip install ruff
|
|
|
|
- name: Ruff Format Check
|
|
run: uv run ruff format --check scripts/
|
|
|
|
- name: Ruff Lint Check
|
|
run: uv run ruff check scripts/
|
|
|
|
security:
|
|
name: Security Scan
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
|
|
- name: Set up Python
|
|
run: uv python install 3.11
|
|
|
|
- name: Create venv and install Bandit
|
|
run: |
|
|
uv venv
|
|
uv pip install "bandit[toml]"
|
|
|
|
- name: Run Bandit Security Scan
|
|
run: uv run bandit -c scripts/pyproject.toml -r scripts/ --exclude scripts/tests/ -f json -o bandit-report.json
|
|
|
|
- name: Upload security report
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: bandit-security-report
|
|
path: bandit-report.json
|
|
retention-days: 7
|
|
|
|
type-check:
|
|
name: Type Checking
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
|
|
- name: Set up Python
|
|
run: uv python install 3.11
|
|
|
|
- name: Create venv and install mypy
|
|
run: |
|
|
uv venv
|
|
uv pip install -r scripts/requirements-dev.txt mypy
|
|
|
|
- name: Run mypy
|
|
run: uv run mypy scripts/ --config-file scripts/pyproject.toml
|
|
|
|
build-epub:
|
|
name: Build EPUB Artifact (${{ matrix.lang }})
|
|
runs-on: ubuntu-latest
|
|
needs: [pytest, lint, security, type-check]
|
|
if: ${{ !failure() && !cancelled() }}
|
|
|
|
# This job is the only gate on the full EPUB build, which stays out of
|
|
# pre-commit because it is slow (the pre-commit mermaid hooks already
|
|
# render every diagram with the same pinned Pele bundle). The matrix
|
|
# covers every language build_epub.py accepts, so a broken diagram in any
|
|
# tree fails here rather than at release time, and check_epub_diagrams.py
|
|
# proves the diagrams are embedded as real SVGs, not placeholders.
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
lang: [en, vi, zh, ja, ko, fa]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
|
|
- name: Set up Python
|
|
run: uv python install 3.11
|
|
|
|
- name: Create venv and install dependencies
|
|
run: |
|
|
uv venv
|
|
uv pip install -r scripts/requirements-dev.txt
|
|
|
|
# Pele renders the diagrams and needs Node.js >= 20.
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Build EPUB
|
|
run: uv run scripts/build_epub.py --lang ${{ matrix.lang }}
|
|
|
|
- name: Verify EPUB Created
|
|
run: |
|
|
shopt -s nullglob
|
|
built=(claude-howto-guide*.epub)
|
|
if [ ${#built[@]} -gt 0 ]; then
|
|
echo "✅ EPUB built successfully"
|
|
ls -lh "${built[@]}"
|
|
else
|
|
echo "❌ EPUB file not found!"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Verify EPUB diagrams
|
|
run: python3 scripts/check_epub_diagrams.py claude-howto-guide*.epub
|
|
|
|
- name: Upload EPUB Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: claude-howto-guide-epub-${{ matrix.lang }}
|
|
path: claude-howto-guide*.epub
|
|
if-no-files-found: error
|
|
retention-days: 7
|
|
compression-level: 0
|
|
|
|
summary:
|
|
name: Test Summary
|
|
needs: [pytest, lint, security, type-check, build-epub]
|
|
runs-on: ubuntu-latest
|
|
if: always()
|
|
|
|
steps:
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
|
|
- name: Generate Summary
|
|
run: |
|
|
echo "# Test Summary" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "## Results" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **Unit Tests**: ${{ needs.pytest.result }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **Code Quality**: ${{ needs.lint.result }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **Security Scan**: ${{ needs.security.result }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **Type Checking**: ${{ needs.type-check.result }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **EPUB Build**: ${{ needs.build-epub.result }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "## Artifacts" >> $GITHUB_STEP_SUMMARY
|
|
echo "- pytest-results-* (coverage and test results)" >> $GITHUB_STEP_SUMMARY
|
|
echo "- bandit-security-report (security scan JSON)" >> $GITHUB_STEP_SUMMARY
|
|
echo "- claude-howto-guide-epub-* (built EPUB file, one per language)" >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Check if all tests passed
|
|
if: |
|
|
needs.pytest.result != 'success' ||
|
|
needs.build-epub.result != 'success'
|
|
run: |
|
|
echo "❌ Critical tests failed"
|
|
exit 1
|
|
|
|
- name: All tests passed
|
|
if: success()
|
|
run: echo "✅ All tests passed successfully!"
|