Files

89 lines
2.8 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
# Windows runner 的管道默认编码是 cp1252,脚本输出 ✓ 等字符会直接 UnicodeEncodeError。
# 全局强制 UTF-8:ubuntu 上无感,windows 上是生死线。
env:
PYTHONUTF8: "1"
# 每个分支只关心最新一次运行;被取代的自动取消。
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
checks:
name: ${{ matrix.os }} / py${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Windows + Git Bash 是主要开发平台,所以和 Linux 一起测,
# 而不是被当成事后补的。
os: [ubuntu-latest, windows-latest]
python: ["3.9", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- uses: actions/setup-node@v4
with:
node-version: "22"
# --- 仓库自洽性:版本号漂移、风格目录漂移、残留外链 ---
- name: Repository integrity check
run: python scripts/check_integrity.py
# --- Python 脚本至少在支持的最低版本上要能编译 ---
- name: Compile Python scripts
run: python -m compileall -q scripts
# --- 画面体检工具要能被导入,且命令行要能响应 ---
- name: Lint tool smoke test
run: python scripts/lint_frames.py --help
- name: Integrity checker smoke test
run: python scripts/check_integrity.py --root .
# --- Shell 入口语法 ---
- name: Check setup_env.sh syntax
shell: bash
run: bash -n setup_env.sh
# --- 渲染器 / 封面器 / 单帧速览工具的语法 ---
- name: Check Node module syntax
shell: bash
run: |
set -e
for f in scripts/*.mjs; do
echo "checking $f"
node --check "$f"
done
- name: Check templates are self-contained
shell: bash
run: |
set -e
# 画面帧绝不允许引 CDN 或网络字体:离线渲染不会报错,只会静默劣化。
# 只扫 HTML —— markdown 文档里*提到*这些 URL 是合理的
# (比如正是指南在教你要把它们删掉),而 GSAP 自带的 README 也会介绍它的 CDN 用法。
hits=$(grep -rInE --include='*.html' \
'https?://[^"'"'"' ]*(fonts\.googleapis|fonts\.gstatic|cdn\.)' . \
|| true)
if [ -n "$hits" ]; then
echo "$hits"
echo "::error::external font or CDN reference found in an HTML template"
exit 1
fi
echo "no external font or CDN references in HTML templates"