Commit 684dca8e authored by nanahira's avatar nanahira

Add blocker for sensitive scripts & readme

parent 6f5bcd91
*.cdb merge=sqlite-merge diff=sqlite-diff
/test-release.cdb /test-release.cdb
/bin
...@@ -7,26 +7,19 @@ stages: ...@@ -7,26 +7,19 @@ stages:
variables: variables:
GIT_DEPTH: "1" GIT_DEPTH: "1"
# redtext: fail_if_banned_files:
# stage: pack stage: prepare
# dependencies: [] dependencies: []
# tags: tags:
# - linux - linux
# image: git-registry.moenext.com/nanahira/srvpro:lite script: |
# variables: banned_files=(script/procedure.lua script/utility.lua script/constant.lua)
# DATABASE_FILE: expansions/test-release.cdb for file in "${banned_files[@]}"; do
# script: if [ -f "$file" ]; then
# - apt update && apt -y install sqlite3 echo "Banned file found: $file"
# - mv /ygopro-server/ygopro . exit 1
# - mkdir dist fi
# - cd ygopro done
# - mkdir -p expansions
# - mv ../script expansions/
# - mv ../*.cdb expansions
# - echo "# Result of redtext test of commit $CI_COMMIT_SHA"
# - echo "select id from datas where type != 0x10 and (type & 0x4000) = 0;" | sqlite3 $DATABASE_FILE | xargs -I {} ./ygopro {} 2>&1 | tee ../dist/redtext.txt
# - cd ..
# - exit $(cat dist/redtext.txt | wc -l)
merge_databases: merge_databases:
stage: prepare stage: prepare
...@@ -119,6 +112,26 @@ json2: ...@@ -119,6 +112,26 @@ json2:
paths: paths:
- test-release-v2.json - test-release-v2.json
redtext:
stage: prepare2
dependencies:
- add_script_diff
tags:
- linux
image: git-registry.moenext.com/nanahira/srvpro:lite
script:
- apt update && apt -y install sqlite3
- mv /ygopro-server/ygopro .
- mkdir dist
- cd ygopro
- rm -rf expansions
- ln -s ../ ./expansions
- ls -1 ../*.cdb | xargs -I '{}' sqlite3 '{}' "select id from datas where type != 0x11 and (type & 0x4000) = 0;" | xargs -I {} -P $(nproc) bash -c './ygopro {} 2>&1 | tee ../redtext-{}.txt'
- cd ..
- cat redtext-*.txt > redtext.txt
# if there are any lines in redtext.txt fail the job
- exit $(wc -l < redtext.txt)
neos: neos:
stage: pack stage: pack
dependencies: dependencies:
...@@ -227,6 +240,9 @@ upload_version_json: ...@@ -227,6 +240,9 @@ upload_version_json:
- aws s3 --endpoint=https://minio.moenext.com:9000 cp data/version.txt s3://mycard/ygopro-super-pre/versions/$CI_COMMIT_REF_NAME/version.txt - aws s3 --endpoint=https://minio.moenext.com:9000 cp data/version.txt s3://mycard/ygopro-super-pre/versions/$CI_COMMIT_REF_NAME/version.txt
- aws s3 --endpoint=https://minio.moenext.com:9000 cp data/test-release.json s3://mycard/ygopro-super-pre/versions/$CI_COMMIT_REF_NAME/test-release.json - aws s3 --endpoint=https://minio.moenext.com:9000 cp data/test-release.json s3://mycard/ygopro-super-pre/versions/$CI_COMMIT_REF_NAME/test-release.json
- aws s3 --endpoint=https://minio.moenext.com:9000 cp data/test-release-v2.json s3://mycard/ygopro-super-pre/versions/$CI_COMMIT_REF_NAME/test-release-v2.json - aws s3 --endpoint=https://minio.moenext.com:9000 cp data/test-release-v2.json s3://mycard/ygopro-super-pre/versions/$CI_COMMIT_REF_NAME/test-release-v2.json
only:
- tags
- master
deploy: deploy:
stage: deploy stage: deploy
......
# pre-release-database-cdb
MyCard 超先行卡仓库。
## 资源
### 表格
#### 先行卡认领、进度与 Bug 反馈表格
https://docs.qq.com/sheet/DWndsYXFjc3pkZmtM
#### 更新流程和操作
https://docs.qq.com/doc/DWmlPRmx4YVpyZXdk
### 资源下载
#### YPK
https://cdn02.moecube.com:444/ygopro-super-pre/archive/ygopro-super-pre.ypk
#### 直接下载特定资源
`https://cdn02.moecube.com:444/ygopro-super-pre/data/<filename>`
#### 版本检测文件
https://cdn02.moecube.com:444/ygopro-super-pre/versions/master/version.txt
https://cdn02.moecube.com:444/ygopro-super-pre/versions/master/test-release-v2.json
### 服务器
- 地址 `mygo.superpre.pro` `mygo2.superpre.pro`
- 超先行端口 `888`
- 主程序,内核为 ygopro 正式版本
- 脚本为正式版本 + `ygopro-scripts-888`
- 有先行卡
- 内核测试端口 `8888`
- 主程序,内核,脚本均为各库 `develop` 分支
- 无先行卡
## CDB 合并器
为了方便 cdb 文件的合并,本仓库提供了 `.gitattributes``setup.bat` `setup.sh` 脚本。
只需要运行,即可启用 cdb 的 git 合并和变动的操作的功能。
## 测试类型
### 超先行测试
超先行脚本完成之后,在本仓库开 PR。
超先行提交可以提交轻度修改关联正式卡脚本,但是请不要提交过多的修改。因超先行新卡而提交的正式卡修改,请列入 `test-update.cdb` 内。
提交之后,系统会自动更新在 888 服务器。打 tag 则推送客户端发布。
**不允许提交 constant.lua utility.lua procedure.lua 等核心脚本的修改。** 如果需要测试这些内容,请以「脚本机制测试」的方式进行。
每次 YGOPro 正式更新,需要删除本仓库内已经正式更新的超先行卡以及正式卡修改。
本方法测试的 BUG 进度在表格的「群内先行写卡&自测」标签页追踪。
### 脚本机制测试
对于不影响 ocgcore 或者 ygopro 主程序的脚本机制测试,可以在本项目进行。步骤如下。
- (可选但建议)在 https://github.com/Fluorohydride/ygopro-scripts 提交相关的脚本 PR。
- 把 PR 的分支合并到 https://code.moenext.com/mycard/ygopro-scripts-888 内。
- 在本仓库创建 `script-fix-xxx.cdb` 列出正在测试的卡。
完成上述步骤后,`ygopro-scripts-888` 分支和正式脚本库的差异部分,会自动更新到 888 服务器。
每次 YGOPro 正式更新,需要把 `ygopro-scripts-888` 仓库 reset 到最新的正式脚本版本。
本方法测试的 BUG 进度在表格的「内核更新测试记录」标签页追踪。
### 内核测试
用于测试影响内核变动的内容。步骤如下。
- **(这一步不可省略)在 Fluorohydride 各库提交 PR。**
- 合并 PR 所在分支到下列仓库的 develop 和 server-develop 分支。
- https://github.com/mycard/ygopro-core
- https://github.com/mycard/ygopro-scripts
- https://code.moenext.com/mycard/ygopro
- 通知相关人员进行整合到 8888 服务器。
本方法测试的 BUG 进度在表格的「内核更新测试记录」标签页追踪。
#!/bin/bash
# Input SQLite database path
DB="$1"
# Locate sqlite3 binary
if [ -n "$SQLITE3_BIN" ]; then
SQLITE3="$SQLITE3_BIN"
elif command -v sqlite3 >/dev/null 2>&1; then
SQLITE3="sqlite3"
elif command -v sqlite3.exe >/dev/null 2>&1; then
SQLITE3="sqlite3.exe"
elif [ -x "./bin/sqlite3" ]; then
SQLITE3="./bin/sqlite3"
elif [ -x "./bin/sqlite3.exe" ]; then
SQLITE3="./bin/sqlite3.exe"
else
echo "❌ Error: sqlite3 binary not found."
echo "Please set the SQLITE3_BIN environment variable or install sqlite3."
exit 1
fi
# Run .dump and filter out noise
"$SQLITE3" "$DB" .dump | grep -v '^--' | grep -v '^PRAGMA'
#!/bin/bash
# Locate sqlite3 binary
if [ -n "$SQLITE3_BIN" ]; then
SQLITE3="$SQLITE3_BIN"
elif command -v sqlite3 >/dev/null 2>&1; then
SQLITE3="sqlite3"
elif command -v sqlite3.exe >/dev/null 2>&1; then
SQLITE3="sqlite3.exe"
elif [ -x "./bin/sqlite3" ]; then
SQLITE3="./bin/sqlite3"
elif [ -x "./bin/sqlite3.exe" ]; then
SQLITE3="./bin/sqlite3.exe"
else
echo "❌ Error: sqlite3 binary not found."
echo "Please set the SQLITE3_BIN environment variable or install sqlite3."
exit 1
fi
BASE="$1"
OURS="$2"
THEIRS="$3"
RESULT="$2"
FILE_PATH="$5"
CONFLICT_FILE="$FILE_PATH.sql"
TMPDIR=$(mktemp -d) || exit 1
# 手动清理函数
cleanup() {
rm -rf "$TMPDIR"
}
# 不用 trap,因为 sh 没有 EXIT trap,靠手动调用
"$SQLITE3" "$BASE" .dump > "$TMPDIR/base.sql" || { cleanup; exit 1; }
"$SQLITE3" "$OURS" .dump > "$TMPDIR/ours.sql" || { cleanup; exit 1; }
"$SQLITE3" "$THEIRS" .dump > "$TMPDIR/theirs.sql" || { cleanup; exit 1; }
git merge-file -p "$TMPDIR/ours.sql" "$TMPDIR/base.sql" "$TMPDIR/theirs.sql" > "$TMPDIR/merged.sql"
MERGE_EXIT_CODE=$?
if grep '^<<<<<<<' "$TMPDIR/merged.sql" >/dev/null; then
echo "❌ Merge conflict detected. Please resolve:"
echo " --> $CONFLICT_FILE"
cp "$TMPDIR/merged.sql" "$CONFLICT_FILE"
cleanup
exit 1 # 保留冲突文件,人工处理,故不 cleanup
fi
rm -f "$RESULT"
"$SQLITE3" "$RESULT" < "$TMPDIR/merged.sql" || {
echo "❌ Failed to import merged SQL"
echo " --> $CONFLICT_FILE"
cp "$TMPDIR/merged.sql" "$CONFLICT_FILE"
cleanup
exit 1
}
echo "✅ Merged successfully to $FILE_PATH"
cleanup
exit 0
@echo off
setlocal enabledelayedexpansion
echo [INFO] Checking for sqlite3.exe...
REM 1. Try PATH
where sqlite3.exe >nul 2>nul
if %errorlevel%==0 (
echo [OK] Found sqlite3.exe in PATH
goto :gitconfig
)
REM 2. Try bin/sqlite3.exe
if exist "bin\sqlite3.exe" (
echo [OK] Found bin\sqlite3.exe
set "SQLITE3_BIN=bin\sqlite3.exe"
goto :gitconfig
)
REM 3. Not found — download
echo [INFO] sqlite3 not founddownloading...
set "ZIP_URL=https://sqlite.org/2025/sqlite-tools-win-x64-3490200.zip"
set "ZIP_FILE=bin\sqlite3.zip"
set "UNZIP_DIR=bin"
if not exist bin (
mkdir bin
)
echo [DOWNLOAD] Fetching SQLite...
curl -L -o "%ZIP_FILE%" "%ZIP_URL%"
if errorlevel 1 (
echo [ERROR] Failed to download sqlite3 zip.
exit /b 1
)
echo [UNZIP] Extracting...
unzip -o "%ZIP_FILE%" -d "%UNZIP_DIR%"
if errorlevel 1 (
echo [ERROR] Failed to unzip SQLite tools.
exit /b 1
)
if not exist "bin\sqlite3.exe" (
echo [ERROR] sqlite3.exe not found after extraction.
exit /b 1
)
set "SQLITE3_BIN=bin\sqlite3.exe"
echo [OK] sqlite3 installed to %SQLITE3_BIN%
:gitconfig
echo [CONFIG] Setting up Git merge driver...
git config merge.sqlite-merge.name "SQLite dump merge"
git config merge.sqlite-merge.driver "scripts/sqlite-merge.sh %%O %%A %%B %%L %%P"
echo [CONFIG] Setting up Git diff driver...
git config diff.sqlite-diff.textconv "scripts/sqlite-diff.sh"
git config diff.sqlite-diff.prompt false
echo [DONE] Git merge & diff drivers configured successfully.
exit /b 0
#!/bin/bash
set -e
# Attempt to find sqlite3, including environment override and local bin/
find_sqlite3() {
if [ -n "$SQLITE3_BIN" ] && [ -x "$SQLITE3_BIN" ]; then
echo "$SQLITE3_BIN"
return 0
fi
if command -v sqlite3 >/dev/null 2>&1; then
echo "sqlite3"
return 0
fi
if command -v sqlite3.exe >/dev/null 2>&1; then
echo "sqlite3.exe"
return 0
fi
if [ -x "./bin/sqlite3" ]; then
echo "./bin/sqlite3"
return 0
fi
if [ -x "./bin/sqlite3.exe" ]; then
echo "./bin/sqlite3.exe"
return 0
fi
return 1
}
install_sqlite3_windows() {
echo "🔍 sqlite3 not found — downloading for Windows..."
mkdir -p bin
ZIP_URL="https://sqlite.org/2025/sqlite-tools-win-x64-3490200.zip"
ZIP_FILE="bin/sqlite3.zip"
# Only download if the zip file or binaries aren't already there
if ! [ -f "$ZIP_FILE" ] || ! find bin -iname "sqlite3.exe" | grep -q .; then
echo "⬇️ Downloading SQLite tools..."
curl -sL -o "$ZIP_FILE" "$ZIP_URL" || {
echo "❌ Failed to download SQLite zip from $ZIP_URL"
exit 1
}
echo "📦 Extracting..."
unzip -o "$ZIP_FILE" -d bin || {
echo "❌ Failed to unzip SQLite tools"
exit 1
}
else
echo "✅ sqlite3 already exists in bin/, skipping download"
fi
}
# --- Main logic ---
SQLITE3_PATH=$(find_sqlite3)
if [ -z "$SQLITE3_PATH" ]; then
UNAME=$(uname | tr '[:upper:]' '[:lower:]')
if echo "$UNAME" | grep -qi "mingw\\|msys\\|cygwin"; then
install_sqlite3_windows
SQLITE3_PATH=$(find_sqlite3)
else
echo "❌ sqlite3 not found in PATH or ./bin/"
echo "Please install sqlite3 manually (e.g., via apt, brew, or your package manager)."
exit 1
fi
fi
echo "✅ Using sqlite3: $SQLITE3_PATH"
export SQLITE3_BIN="$SQLITE3_PATH"
# --- Git configuration ---
git config merge.sqlite-merge.name "SQLite dump merge"
git config merge.sqlite-merge.driver "scripts/sqlite-merge.sh %O %A %B %L %P"
git config diff.sqlite-diff.textconv "scripts/sqlite-diff.sh"
git config diff.sqlite-diff.prompt false
echo "✅ Git merge & diff drivers configured successfully."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment