mirror of
https://github.com/luongnv89/claude-howto.git
synced 2026-12-03 02:03:31 +01:00
The v2.1.322 release run failed: https://github.com/luongnv89/claude-howto/actions/runs/43214385899 ## Cause `ubuntu-latest` moved to Ubuntu 26.04, whose system Python is 3.14. `.github/workflows/release.yml` ran `uv venv` without pinning a version and with no uv-managed Python installed, so uv took the first Python it found on the runner's `PATH`: `/usr/bin/python` (CPython 3.14.4). `pillow==11.1.0` (`scripts/requirements.txt`) has no 3.14 wheel. uv tried to build it from source, and the build failed because the libjpeg headers were missing. All three EPUB jobs failed at "Install Python dependencies". The "Publish GitHub Release" job then failed at "List built artifacts" (`ls: cannot access 'dist/'`), before it reached the publish step. ## Fix - **`release.yml`, `build` job:** add a `Set up Python` step (`uv python install 3.11`) before "Install Python dependencies". This is the step the `build-epub` job in `test.yml` already uses. - **Both `release.yml` `build` and `test.yml` `build-epub`:** set a job-level `UV_PYTHON: '3.11'`. This pins every uv command in those jobs to 3.11: `uv venv`, and also the PEP 723 environment that `uv run scripts/build_epub.py` creates. Without it, the install step works only because 3.11 is the sole managed interpreter and uv's default preference is `managed`. A runner image that ships a newer uv-managed Python, or a change to that default, would silently switch versions. The `uv python install 3.11` steps stay as the explicit download. The two jobs now pin Python the same way, so release builds run on the interpreter CI already tests. Editing `test.yml` also makes it run on this PR, so its `build-epub` job exercises the same pin. Nothing else changes, and the release language matrix (en/vi/zh) stays as it is. The other workflows don't need this. `docs-check.yml` pins 3.11 through `actions/setup-python`. `pages.yml` runs `uv run scripts/build_website.py`, whose inline dependencies are pure Python (markdown, beautifulsoup4, jinja2). It doesn't install Pillow or `scripts/requirements*.txt`. ## Publishing v2.1.322 Re-running the failed run won't fix it: a tag-triggered run uses the workflow file at the tagged commit (`b5548c6`), which doesn't have this fix. After merge, v2.1.322 is released only if the tag is moved to a commit that contains this fix, or a new tag is cut. That's the maintainer's decision. ## Verification - Both workflow files parse. The `build` step order is checkout → uv → Node.js → **Set up Python** → install deps → build. - `pre-commit run --files .github/workflows/release.yml .github/workflows/test.yml` passes: check-yaml, end-of-file, trailing-whitespace, large-files and merge-conflict. The mermaid hooks were skipped (`SKIP=…`) because their Node.js environment couldn't install locally, and they have nothing to check on these files anyway. - `release.yml` has no `workflow_dispatch`, so only the next tag push proves it end to end. ## Follow-up (not in this PR) `uv run scripts/build_epub.py` builds in its own PEP 723 environment and doesn't use `.venv` or `scripts/requirements-dev.txt`. The `uv venv` + `uv pip install -r scripts/requirements-dev.txt` step in both EPUB jobs installs tools the build never uses. It also means the EPUB is built with the latest Pillow, not the `pillow==11.1.0` pin. Dropping that step, or pinning the script's inline dependencies, is a separate change. Closes #249
257 lines
7.4 KiB
YAML
257 lines
7.4 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() }}
|
|
env:
|
|
# Pin every uv command (uv venv and the PEP 723 env of `uv run`) to 3.11.
|
|
UV_PYTHON: '3.11'
|
|
|
|
# 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!"
|