mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 04:06:44 +08:00
改为在 linux runner 中手动 fetch 当前提交,避免自托管 runner 准备阶段通过 gh-proxy 克隆 actions/checkout 和 dtolnay/rust-toolchain 时被 403 拦截,并同步开发文档与缺口说明。
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
# Gitea Actions workflow for the Rust workspace.
|
# Gitea Actions workflow for the Rust workspace.
|
||||||
# This workflow is linux-runner friendly and does not touch real resource
|
# This workflow is linux-runner friendly and does not touch real resource
|
||||||
# directories.
|
# directories. It intentionally avoids external GitHub Actions so self-hosted
|
||||||
|
# runners do not need to clone action repositories through a network proxy.
|
||||||
|
|
||||||
name: bat-rust
|
name: bat-rust
|
||||||
|
|
||||||
@@ -21,21 +22,35 @@ jobs:
|
|||||||
BAT_SKIP_ENV_FILE: "1"
|
BAT_SKIP_ENV_FILE: "1"
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
: "${GITHUB_SERVER_URL:?GITHUB_SERVER_URL is required}"
|
||||||
|
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}"
|
||||||
|
: "${GITHUB_SHA:?GITHUB_SHA is required}"
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
repo_url="${GITHUB_SERVER_URL%/}/${GITHUB_REPOSITORY}.git"
|
||||||
uses: dtolnay/rust-toolchain@stable
|
if [ -d .git ]; then
|
||||||
with:
|
git remote set-url origin "${repo_url}" 2>/dev/null || git remote add origin "${repo_url}"
|
||||||
components: rustfmt,clippy
|
else
|
||||||
|
git init .
|
||||||
|
git remote add origin "${repo_url}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ref="${GITHUB_REF:-${GITHUB_SHA}}"
|
||||||
|
git fetch --no-tags --depth=1 origin "${ref}" || git fetch --no-tags --depth=1 origin "${GITHUB_SHA}"
|
||||||
|
git checkout --force --detach FETCH_HEAD
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
- name: Show tool versions
|
- name: Show tool versions
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
command -v git
|
||||||
rustc --version
|
rustc --version
|
||||||
cargo --version
|
cargo --version
|
||||||
command -v curl
|
rustfmt --version
|
||||||
command -v unzip
|
cargo clippy --version
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -23,6 +23,20 @@ rustc --version # 验证安装
|
|||||||
cargo --version
|
cargo --version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### 自托管 Gitea runner
|
||||||
|
|
||||||
|
`.gitea/workflows/bat.yml` 使用 `runs-on: linux`,并且不依赖 `actions/checkout`、`dtolnay/rust-toolchain` 等外部 GitHub Action。runner 需要在执行环境中预装以下命令:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git --version
|
||||||
|
rustc --version
|
||||||
|
cargo --version
|
||||||
|
rustfmt --version
|
||||||
|
cargo clippy --version
|
||||||
|
```
|
||||||
|
|
||||||
|
该 workflow 会用 `GITHUB_SERVER_URL`、`GITHUB_REPOSITORY`、`GITHUB_REF` 和 `GITHUB_SHA` 手动 `git fetch` 当前提交,再执行 Rust workspace 的格式化、检查、构建、clippy 和测试。这样可以避免自托管 runner 在准备阶段通过代理克隆第三方 action 仓库。
|
||||||
|
|
||||||
#### Docker
|
#### Docker
|
||||||
```bash
|
```bash
|
||||||
# 安装 Docker 和 Docker Compose
|
# 安装 Docker 和 Docker Compose
|
||||||
|
|||||||
@@ -403,6 +403,7 @@
|
|||||||
|
|
||||||
- 明确决策:本项目不加入 GitHub Workflows,也不引入其他托管 CI。
|
- 明确决策:本项目不加入 GitHub Workflows,也不引入其他托管 CI。
|
||||||
- 目前补充了自托管 Gitea linux-runner workflow(`.gitea/workflows/bat.yml`),仅用于 Rust workspace 的构建和测试,不改变“不引入托管 CI”的决策。
|
- 目前补充了自托管 Gitea linux-runner workflow(`.gitea/workflows/bat.yml`),仅用于 Rust workspace 的构建和测试,不改变“不引入托管 CI”的决策。
|
||||||
|
- workflow 不使用外部 GitHub Action;它通过 runner 环境变量手动 `git fetch` 当前提交,并要求 runner 预装 `git`、Rust stable、rustfmt 和 clippy,避免准备阶段因第三方 action 仓库代理或网络限制失败。
|
||||||
- 质量门禁由本地默认验证命令和自托管 workflow 共同承担:提交前执行 `cargo fmt` / `cargo clippy --workspace --all-targets -- -D warnings` / `cargo test --workspace`(见 `docs/guides/development.md` 与 `docs/guides/baseline.md`)。
|
- 质量门禁由本地默认验证命令和自托管 workflow 共同承担:提交前执行 `cargo fmt` / `cargo clippy --workspace --all-targets -- -D warnings` / `cargo test --workspace`(见 `docs/guides/development.md` 与 `docs/guides/baseline.md`)。
|
||||||
- 发布类检查(build、smoke)由 `Makefile` 与 `scripts/` 下的可重复脚本承担(如 `make official-smoke`)。
|
- 发布类检查(build、smoke)由 `Makefile` 与 `scripts/` 下的可重复脚本承担(如 `make official-smoke`)。
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user