Fix: Main test workflow fails with empty FILES variable in pull requests
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 90/100
调研方向
失败的逻辑位于 .github/workflows/test.yml 的第 73-77 行附近;首先阅读 Main test job 和所引用的 failure run,然后验证 push 和 pull_request 事件如何提供正在比较的提交。更新文件检测步骤,使两种事件类型都产生预期的 data/ 路径,并确认 Main test workflow 不再因 pull request 中 FILES 变量为空而退出。
由索引模型根据 Issue 内容生成。
描述
Problem
The "Main test" job in the test workflow is failing with:
Variable FILES is empty.
This occurs because the git log command used to detect changed files doesn't work correctly for pull requests.
Root Cause
The current file detection logic (line 74 in .github/workflows/test.yml):
FILES=$(git log -1 -p data/ | grep +++ | cut -d '/' -f 2-| sed -e 's|dev/null||g')
For pull requests, git log -1 examines the merge commit created by GitHub, which doesn't contain the actual file changes from the PR. This results in an empty FILES variable, causing the job to exit with code 1.
Solution
Replace the file detection logic to handle both push and pull request events correctly:
# Find out which files in data/ have been changed in the last commit
if [ "${{ github.event_name }}" == "pull_request" ]; then
# For PRs, compare against the base branch
FILES=$(git diff --name-only origin/master...HEAD -- data/ | sed -e 's|^|data/|')
else
# For pushes, use the standard git log approach
FILES=$(git log -1 -p data/ | grep +++ | cut -d '/' -f 2- | sed -e 's|dev/null||g')
fi
echo "Last changed files from the FILES variable:"
echo "$FILES"
if [ -z "$FILES" ]; then
echo "Variable FILES is empty."
exit 1
fi
This approach:
- For PRs: Uses
git diff --name-only origin/master...HEAD -- data/to compare the PR branch against the base branch, correctly identifying changed files - For pushes: Maintains the existing logic
- Ensures files are properly formatted with the
data/prefix
Apply this change to lines 73-77 of .github/workflows/test.yml
Failure Reference
https://github.com/AppImage/appimage.github.io/actions/runs/31879003988/job/94998828969
- 主要语言
- Shell
- 星标
- 421
- 派生
- 822
- 平均合并
- 12 小时 29 分钟
- 30 天内合并 PR
- 401
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AppImage/appimage.github.io 的其他 Issue
-
entry-unavailable
难度 1/5 1 小时以内 新手友好度 72/100
AppImage/appimage.github.io#10099 ·
维护者通常 1 天内回复
-
entry-unavailable
难度 1/5 1 小时以内 新手友好度 78/100
AppImage/appimage.github.io#10097 ·
维护者通常 1 天内回复
-
entry-unavailable
难度 1/5 1 小时以内 新手友好度 75/100
AppImage/appimage.github.io#10096 ·
维护者通常 1 天内回复
-
entry-unavailable
难度 1/5 1 小时以内 新手友好度 65/100
AppImage/appimage.github.io#10095 · 2 条评论 ·
维护者通常 1 天内回复
-
entry-unavailable
难度 1/5 1 小时以内 新手友好度 76/100
AppImage/appimage.github.io#10093 ·
维护者通常 1 天内回复
查看 AppImage/appimage.github.io 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
interledger/rhyza#352 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
beehive-lab/TornadoVM#1248 ·
维护者通常 1 天内回复
-
Dev
难度 2/5 1-3 小时 新手友好度 62/100
ankidroid/Anki-Android#22555 ·
维护者通常 1 天内回复
-
difficulty: easy domain: devops effort: 1-4h enhancement good first issue smart-contracts Stellar Wave
难度 2/5 1-3 小时 新手友好度 72/100
Kaycee276/Chesster#469 · 2 条评论 ·
维护者通常 1 天内回复
-
Add .gitignore可能已有人在做 @ajeanmahoney 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100