Files
Genarrative/scripts/gitea-ci-job-image.sh
T
suzmii a35cdcc68c
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Failing after 17s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Failing after 11s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Failing after 14s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Failing after 12s
Project CI / AI game creator shell Rust smoke (pull_request) Failing after 11s
Project CI / AI game creator shell Rust crates (pull_request) Failing after 10s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Native shell tests (pull_request) Failing after 10s
Project CI / Frontend tests (pull_request) Failing after 5s
Project CI / Repository checks (pull_request) Failing after 11s
Project CI / AI game creator shell web tests (pull_request) Failing after 11s
同步 CI 镜像 tag 与文档口径,并补上工具链一致性护栏
- 将 CI job 镜像默认 tag 从 genarrative/gitea-project-ci:20260807.1 升为 20260920.1
- 将 Dockerfile 两处 org.opencontainers.image.version 统一为 2026.09.20.1(原先一处 2026.07.23.1、一处 2026.08.07.1,后写的覆盖先写的)
- 同步 deploy/container/README.md 与开发运维文档中的镜像归档示例名
- 订正 pitfalls.md 中 CI 镜像的 Rust 版本,并记录 number_of_links 在 1.98.1 上实测仍未稳定
- 在 decision-log.md 追加本次 Rust 工具链升级到 1.98.1 的决策条目
- 在 scripts/project-ci-workflow.test.ts 新增一致性用例:镜像版本段、digest 与 tag 必须与 rust-toolchain.toml 及两份运维文档一致
2026-09-20 17:06:49 +08:00

170 lines
6.3 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
dockerfile_context_path="deploy/container/gitea-ci-job.Dockerfile"
image_tag="${GENARRATIVE_GITEA_CI_IMAGE_TAG:-genarrative/gitea-project-ci:20260920.1}"
runner_container="${GENARRATIVE_GITEA_RUNNER_CONTAINER:-gitea-runner}"
write_build_context_file_list() {
printf '%s\0' \
deploy/container/gitea-ci-job.Dockerfile \
deploy/container/gitea-ci-job.Dockerfile.dockerignore \
deploy/container/gitea-ci-checkout.sh \
package.json \
package-lock.json \
apps/admin-web/package.json \
apps/ai-game-creator-shell/package.json \
apps/desktop-shell/package.json \
apps/mobile-shell/package.json \
apps/preview-deployer-web/package.json \
packages/image-canvas-core/package.json \
packages/image-canvas-react/package.json \
packages/shared/package.json \
tools/spine-json-export-validator/package.json \
apps/ai-game-creator-shell/src-tauri/Cargo.toml \
apps/ai-game-creator-shell/src-tauri/Cargo.lock \
server-rs/Cargo.toml \
server-rs/Cargo.lock \
apps/desktop-shell/src-tauri/Cargo.toml \
apps/desktop-shell/src-tauri/Cargo.lock
find server-rs/crates -name Cargo.toml -print0 | sort -z
}
usage() {
cat <<'EOF'
用法:
bash scripts/gitea-ci-job-image.sh build
bash scripts/gitea-ci-job-image.sh verify [镜像引用]
bash scripts/gitea-ci-job-image.sh load-runner [镜像引用]
bash scripts/gitea-ci-job-image.sh export <归档路径> [镜像引用]
环境变量:
GENARRATIVE_GITEA_CI_IMAGE_TAG 覆盖本地构建 tag
GENARRATIVE_GITEA_RUNNER_CONTAINER 覆盖 Runner 容器名
EOF
}
image_id() {
docker image inspect --format '{{.Id}}' "$1"
}
verify_image() {
local image_ref="$1"
docker run --rm \
--mount "type=bind,src=${repo_root}/scripts,dst=/usr/local/scripts,readonly" \
--mount "type=bind,src=${repo_root}/scripts/check-gitea-ci-job-image.sh,dst=/usr/local/bin/check-gitea-ci-job-image.sh,readonly" \
--mount "type=bind,src=${repo_root}/rust-toolchain.toml,dst=/usr/local/rust-toolchain.toml,readonly" \
"${image_ref}" \
bash /usr/local/bin/check-gitea-ci-job-image.sh
}
command_name="${1:-}"
case "${command_name}" in
build)
image_revision="$(
cd "${repo_root}"
{
sha256sum \
deploy/container/gitea-ci-job.Dockerfile \
deploy/container/gitea-ci-job.Dockerfile.dockerignore \
deploy/container/gitea-ci-checkout.sh \
package.json \
package-lock.json \
apps/admin-web/package.json \
apps/ai-game-creator-shell/package.json \
apps/desktop-shell/package.json \
apps/mobile-shell/package.json \
apps/preview-deployer-web/package.json \
packages/image-canvas-core/package.json \
packages/image-canvas-react/package.json \
packages/shared/package.json \
tools/spine-json-export-validator/package.json \
apps/ai-game-creator-shell/src-tauri/Cargo.toml \
apps/ai-game-creator-shell/src-tauri/Cargo.lock \
server-rs/Cargo.toml \
server-rs/Cargo.lock \
apps/desktop-shell/src-tauri/Cargo.toml \
apps/desktop-shell/src-tauri/Cargo.lock
find server-rs/crates -name Cargo.toml -print0 \
| sort -z \
| xargs -0 -r sha256sum
} \
| sha256sum \
| awk '{ print $1 }'
)"
npm_lock_sha256="$(sha256sum "${repo_root}/package-lock.json")"
npm_lock_sha256="${npm_lock_sha256%% *}"
server_rust_lock_sha256="$(sha256sum "${repo_root}/server-rs/Cargo.lock")"
server_rust_lock_sha256="${server_rust_lock_sha256%% *}"
desktop_rust_lock_sha256="$(sha256sum "${repo_root}/apps/desktop-shell/src-tauri/Cargo.lock")"
desktop_rust_lock_sha256="${desktop_rust_lock_sha256%% *}"
agc_rust_lock_sha256="$(sha256sum "${repo_root}/apps/ai-game-creator-shell/src-tauri/Cargo.lock")"
agc_rust_lock_sha256="${agc_rust_lock_sha256%% *}"
(
cd "${repo_root}"
write_build_context_file_list \
| tar --null --create --file - --files-from=- \
| docker build \
--pull=false \
--build-arg "IMAGE_REVISION=${image_revision}" \
--build-arg "NPM_LOCK_SHA256=${npm_lock_sha256}" \
--build-arg "SERVER_RUST_LOCK_SHA256=${server_rust_lock_sha256}" \
--build-arg "DESKTOP_RUST_LOCK_SHA256=${desktop_rust_lock_sha256}" \
--build-arg "AGC_RUST_LOCK_SHA256=${agc_rust_lock_sha256}" \
--file "${dockerfile_context_path}" \
--tag "${image_tag}" \
-
)
verify_image "${image_tag}"
printf 'image_tag=%s\n' "${image_tag}"
printf 'image_id=%s\n' "$(image_id "${image_tag}")"
;;
verify)
image_ref="${2:-${image_tag}}"
verify_image "${image_ref}"
printf 'image_ref=%s\n' "${image_ref}"
printf 'image_id=%s\n' "$(image_id "${image_ref}")"
;;
load-runner)
image_ref="${2:-${image_tag}}"
verify_image "${image_ref}"
expected_image_id="$(image_id "${image_ref}")"
docker save "${image_ref}" | docker exec -i "${runner_container}" docker load
loaded_image_id="$(
docker exec "${runner_container}" \
docker image inspect --format '{{.Id}}' "${image_ref}"
)"
test "${loaded_image_id}" = "${expected_image_id}"
docker exec -i "${runner_container}" \
docker run --rm --interactive \
--security-opt seccomp=unconfined \
--security-opt systempaths=unconfined \
"${loaded_image_id}" bash -s \
< "${repo_root}/scripts/check-gitea-ci-job-runtime.sh"
printf 'runner_image_tag=%s\n' "${image_ref}"
printf 'runner_image_id=%s\n' "${loaded_image_id}"
printf 'runner_label_image=docker://%s\n' "${loaded_image_id}"
;;
export)
archive_path="${2:-}"
image_ref="${3:-${image_tag}}"
test -n "${archive_path}"
verify_image "${image_ref}"
docker save "${image_ref}" | zstd --threads=0 --ultra -10 -o "${archive_path}"
archive_dir="$(cd "$(dirname "${archive_path}")" && pwd -P)"
archive_name="$(basename "${archive_path}")"
(
cd "${archive_dir}"
sha256sum "${archive_name}" > "${archive_name}.sha256"
)
printf 'archive=%s\n' "${archive_path}"
printf 'image_id=%s\n' "$(image_id "${image_ref}")"
;;
*)
usage >&2
exit 2
;;
esac