AppImage / AppImage/appimage.github.io

Fix: Main test workflow fails with empty FILES variable in pull requests

Open
#3,857 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
374
Forks
769
Avg merge
4d 10h
Merged PRs (30d)
8

Description

## 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`):
```bash
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:

```bash
# 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.