AppImage / AppImage/appimage.github.io

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

Abierto
#3,857 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Shell
Estrellas
374
Forks
769
Merge medio
4 d 10 h
PR fusionados (30 d)
8

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.