. #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pruebas | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- '**.hpp' | |
- '**.cpp' | |
pull_request: | |
branches: [ main ] | |
paths: | |
- '**.hpp' | |
- '**.cpp' | |
jobs: | |
construir-y-probar: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'true' | |
- name: Instalar Ninja | |
run: | | |
choco install ninja | |
- name: Configurar Clang y CMake | |
run: | | |
choco install llvm | |
echo "CMake version: $(cmake --version)" | |
echo "Clang version: $(clang --version)" | |
cmake -S . -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_STANDARD=20 -G "Ninja" | |
- name: Compilar | |
run: | | |
cmake --build build | |
- name: Ejecutar Pruebas | |
id: ejecutar_pruebas | |
run: | | |
build\correr_pruebas.exe -s | |
- name: Publicar Resultados de Pruebas (en caso de fallos) | |
if: failure() | |
run: | | |
echo "Resultados de las pruebas:" | |
type build\Testing\Temporary\LastTest.log | |
- name: Actualizar Descripción de PR o Commit | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
// Obtener el estado del paso 'Ejecutar Pruebas' | |
const testStep = jobs['construir-y-probar'].steps.find(step => step.id === 'ejecutar_pruebas'); | |
const testOutcome = testStep?.conclusion === 'success' ? | |
'✔ Todas las pruebas pasaron correctamente.' : | |
'❌ Las pruebas fallaron.'; | |
const comment = `Resultado de las pruebas:\n\n${testOutcome}`; | |
// Actualizar la descripción del pull request si es un PR | |
if (context.payload.pull_request) { | |
await github.rest.pulls.update({ | |
...context.repo, | |
pull_number: context.payload.pull_request.number, | |
body: (context.payload.pull_request.body || '') + `\n\n${comment}`, | |
}); | |
} else { | |
// Agregar un mensaje de estado para commits directos | |
await github.rest.repos.createCommitStatus({ | |
...context.repo, | |
sha: context.sha, | |
state: testOutcome.includes('✔') ? 'success' : 'failure', | |
description: testOutcome, | |
context: 'Resultados de las pruebas', | |
}); | |
} |