Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Build y despliegue (GitHub Pages)

on:
push:
branches: ['**']
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

env:
# Version fija de Emscripten (la misma con la que se verifico el build web)
EMSDK_VERSION: "6.0.13"

jobs:
# ---------------------------------------------------------------------------
# 1) Pruebas de QA nativas (Modulos 1-3) con AddressSanitizer + UBSan
# ---------------------------------------------------------------------------
nativo:
name: Pruebas nativas (ASan + UBSan)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Instalar dependencias
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends cmake g++ libsdl2-dev

- name: Configurar y compilar
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBGE_SANITIZE=ON
cmake --build build --parallel

- name: Ejecutar pruebas (SDL_VIDEODRIVER=dummy, sin pantalla)
run: ctest --test-dir build --output-on-failure

# ---------------------------------------------------------------------------
# 2) Compilacion cruzada a WebAssembly + prueba de integridad HTTP
# ---------------------------------------------------------------------------
web:
name: Compilar WebAssembly (Emscripten)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Cachear el SDK de Emscripten
uses: actions/cache@v4
with:
path: ~/emsdk
key: emsdk-${{ runner.os }}-${{ env.EMSDK_VERSION }}

- name: Instalar y activar Emscripten
run: |
if [ ! -d "$HOME/emsdk" ]; then
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
fi
cd "$HOME/emsdk"
./emsdk install "$EMSDK_VERSION"
./emsdk activate "$EMSDK_VERSION"

- name: Configurar (emcmake) y compilar
run: |
source "$HOME/emsdk/emsdk_env.sh"
emcc --version | head -1
emcmake cmake -S . -B build-web -DCMAKE_BUILD_TYPE=Release
cmake --build build-web --parallel

- name: Verificar que se generaron index.html, index.js e index.wasm
run: |
for f in index.html index.js index.wasm; do
test -s "build-web/$f" || { echo "::error::falta build-web/$f"; exit 1; }
done
ls -la build-web/index.*

- name: Ensamblar el sitio
run: |
mkdir site
cp build-web/index.html build-web/index.js build-web/index.wasm site/
touch site/.nojekyll

- name: Prueba de integridad (servidor HTTP local)
run: |
python3 -m http.server 8080 --directory site >/dev/null 2>&1 &
SERVER_PID=$!
trap 'kill "$SERVER_PID" 2>/dev/null || true' EXIT

# Esperar a que el servidor responda (en vez de un sleep fijo)
for i in $(seq 1 20); do
curl -sf -o /dev/null http://127.0.0.1:8080/index.html && break
sleep 0.5
done

for f in index.html index.js index.wasm; do
code=$(curl -s -o "/tmp/$f" -w '%{http_code}' "http://127.0.0.1:8080/$f")
echo "$f -> HTTP $code"
test "$code" = "200"
done

# Un .wasm valido empieza por los bytes 00 61 73 6d ("\0asm").
# Se valida con Python: xxd no esta garantizado en todos los runners.
python3 - <<'PY'
with open('/tmp/index.wasm', 'rb') as f:
header = f.read(4)
assert header == b'\x00asm', f'Cabecera WASM invalida: {header!r}'
print('Cabecera WASM verificada')
PY

# emcc minimiza el HTML y elimina las comillas (<canvas id=canvas ...>),
# por eso se busca la etiqueta y no el atributo con comillas.
grep -qi '<canvas' /tmp/index.html
echo "Etiqueta <canvas> encontrada en index.html"

- name: Subir artefacto para GitHub Pages
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: actions/upload-pages-artifact@v3
with:
path: site

- name: Subir artefacto de revision (ramas y PR)
if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
uses: actions/upload-artifact@v4
with:
name: sitio-web
path: site
retention-days: 7

# ---------------------------------------------------------------------------
# 3) Despliegue a GitHub Pages (solo desde la rama por defecto)
# ---------------------------------------------------------------------------
deploy:
name: Desplegar en GitHub Pages
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
needs: [nativo, web]
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.despliegue.outputs.page_url }}
steps:
- name: Desplegar
id: despliegue
uses: actions/deploy-pages@v4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,7 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# CMake / build
build/
build-*/
31 changes: 0 additions & 31 deletions BasicGameEngine/BasicGameEngine.sln

This file was deleted.

150 changes: 0 additions & 150 deletions BasicGameEngine/BasicGameEngine/BasicGameEngine.vcxproj

This file was deleted.

27 changes: 0 additions & 27 deletions BasicGameEngine/BasicGameEngine/BasicGameEngine.vcxproj.filters

This file was deleted.

Loading
Loading