diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 0ec0d06..dba2962 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -13,13 +13,13 @@ Despliega la documentación MkDocs a GitHub Pages cuando hay cambios en `main`. --- -### [`validate-shacl.yml`](./validate-shacl.yml) +### [`validate-shacl.yml`](./validate-shacl.yml) / [`comment-shacl-report.yml`](./comment-shacl-report.yml) Valida archivos SHACL y ejemplos RDF/TTL en PRs y pushes a `main`/`develop`. **Trigger**: Cambios en `shacl/**/*.ttl`, `examples/**/*.{rdf,ttl}` o archivos de configuración **Ejecución**: Docker con pyshacl (ver `tests/validate-local.sh`) **Artefactos**: Reportes de validación (30 días) -**Nota**: Comenta resumen en PRs automáticamente +**Nota**: Comenta resumen en PRs automáticamente en único post, evitando ruido en la PR --- @@ -78,4 +78,4 @@ Build alternativo de documentación con Poetry (actualmente manual). **Trigger**: Solo manual **Diferencia con mkdocs.yml**: Usa Poetry para gestión de dependencias, incluye Playwright para rendering -**TODO**: Añadir versionado con [mike](https://github.com/jimporter/mike) \ No newline at end of file +**TODO**: Añadir versionado con [mike](https://github.com/jimporter/mike) diff --git a/.github/workflows/comment-shacl-report.yml b/.github/workflows/comment-shacl-report.yml new file mode 100644 index 0000000..d51354e --- /dev/null +++ b/.github/workflows/comment-shacl-report.yml @@ -0,0 +1,99 @@ +name: Comentar informe SHACL en PR + +on: + workflow_run: + workflows: ["Validación formas SHACL"] + types: [completed] + +permissions: + contents: read + pull-requests: write + issues: write + actions: read + +jobs: + comment: + if: github.event.workflow_run.event == 'pull_request' + runs-on: ubuntu-latest + + steps: + - name: Descargar artefacto de informes + uses: actions/download-artifact@v8 + with: + name: dcat-ap-es-validation-reports + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + path: reports + + - name: Publicar o actualizar comentario en la PR + uses: actions/github-script@v9 + with: + script: | + const fs = require('fs'); + + const marker = ''; + const summaryPath = 'reports/SUMMARY.md'; + const prNumberPath = 'reports/PR_NUMBER.txt'; + + if (!fs.existsSync(summaryPath)) { + core.warning(`No se encontró ${summaryPath}; se omite el comentario.`); + return; + } + + let prNumber; + if (fs.existsSync(prNumberPath)) { + prNumber = Number(fs.readFileSync(prNumberPath, 'utf8').trim()); + } else { + prNumber = context.payload.workflow_run.pull_requests?.[0]?.number; + } + + if (!prNumber) { + core.warning('No se pudo determinar el número de PR.'); + return; + } + + const summary = fs.readFileSync(summaryPath, 'utf8').trim(); + const shortSha = (context.payload.workflow_run.head_sha || '').slice(0, 7); + const updatedAt = context.payload.workflow_run.updated_at || new Date().toISOString(); + + const body = [ + marker, + '## resumen de validación SHACL', + '', + `Estado del workflow: \`${context.payload.workflow_run.conclusion || 'unknown'}\``, + shortSha ? `Commit: \`${shortSha}\`` : null, + `Actualizado: \`${updatedAt}\``, + '', + summary + ].filter(Boolean).join('\n'); + + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + per_page: 100 + }); + + const existingComment = comments.find(comment => + comment.user?.type === 'Bot' && + typeof comment.body === 'string' && + comment.body.includes(marker) + ); + + if (existingComment) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existingComment.id, + body + }); + core.info(`Updated comment ${existingComment.id} on PR #${prNumber}.`); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + body + }); + core.info(`Created comment on PR #${prNumber}.`); + } diff --git a/.github/workflows/mkdocs.yml b/.github/workflows/mkdocs.yml index 927c373..189a21a 100644 --- a/.github/workflows/mkdocs.yml +++ b/.github/workflows/mkdocs.yml @@ -19,11 +19,11 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: '3.10' @@ -59,18 +59,18 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: ref: gh-pages - name: Setup Pages - uses: actions/configure-pages@v5 + uses: actions/configure-pages@v6 - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v5 with: path: '.' - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file + uses: actions/deploy-pages@v5 \ No newline at end of file diff --git a/.github/workflows/validate-shacl.yml b/.github/workflows/validate-shacl.yml index 83492b9..5043cee 100644 --- a/.github/workflows/validate-shacl.yml +++ b/.github/workflows/validate-shacl.yml @@ -1,11 +1,8 @@ name: Validación formas SHACL on: - # Ejecutar en PRs cuando se modifican archivos relevantes pull_request: - branches: - - main - - develop + branches: [main, develop] paths: - 'shacl/**/*.ttl' - 'examples/**/*.rdf' @@ -14,12 +11,8 @@ on: - 'tools/docker-pyshacl/**' - 'tests/test.ini' - '.github/workflows/validate-shacl.yml' - - # Ejecutar en push directo a main/develop (fuera de PR) push: - branches: - - main - - develop + branches: [main, develop] paths: - 'shacl/**/*.ttl' - 'examples/**/*.rdf' @@ -29,16 +22,18 @@ on: - 'tests/test.ini' - '.github/workflows/validate-shacl.yml' +permissions: + contents: read + jobs: validate-dcat-ap-es: name: Validación formas SHACL DCAT-AP-ES (Todas las Fases) runs-on: ubuntu-latest - # Evitar duplicación: no ejecutar en push si hay una PR abierta para esta rama if: github.event_name == 'pull_request' || github.event.pull_request == null - + steps: - name: Comprobar repositorio - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Ejecutar validación de formas SHACL DCAT-AP-ES id: validate @@ -48,29 +43,18 @@ jobs: ./tests/validate-local.sh all echo "exit_code=$?" >> $GITHUB_OUTPUT + - name: Guardar número de PR + if: github.event_name == 'pull_request' + run: echo "${{ github.event.pull_request.number }}" > tests/validation-reports/PR_NUMBER.txt + - name: Subir informes de validación if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: dcat-ap-es-validation-reports path: tests/validation-reports/ retention-days: 30 - - name: Commentar resumen de validación en el PR - if: github.event_name == 'pull_request' && always() - uses: actions/github-script@v8 - with: - script: | - const fs = require('fs'); - const summary = fs.readFileSync('tests/validation-reports/SUMMARY.md', 'utf8'); - - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: summary - }); - - name: Comprobar resultado de la validación run: | EXIT_CODE="${{ steps.validate.outputs.exit_code }}" diff --git a/.gitignore b/.gitignore index 909a364..855e959 100644 --- a/.gitignore +++ b/.gitignore @@ -81,6 +81,7 @@ node_modules **/node_modules/ bower_components .vscode +.vscode/ .idea *.log @@ -136,4 +137,4 @@ tools/.temp refs/github_issue_*.md shacl/dev validation-reports -commit-summary \ No newline at end of file +commit-summary diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 31167a9..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "githubPullRequests.ignoredPullRequestBranches": [ - "main", - "main" - ] -} \ No newline at end of file diff --git a/docs/adoc/conventions.adoc b/docs/adoc/conventions.adoc index 79a5bed..c141624 100644 --- a/docs/adoc/conventions.adoc +++ b/docs/adoc/conventions.adoc @@ -998,7 +998,6 @@ Los prefijos listados son los más comúnmente utilizados, aunque técnicamente | Prefijo | URI | Nombre | Descripción | `adms` | `http://www.w3.org/ns/adms#` | Asset Description | Descripción de activos semánticos -| `cnt` | `http://www.w3.org/2011/content#` | Representing Content in RDF | Representación de contenidos en RDF | `dcat` | `http://www.w3.org/ns/dcat#` | Data Catalog Vocabulary | Vocabulario para describir catálogos de datos | `dcatap` | `http://data.europa.eu/r5r/` | DCAT-AP | Extensiones específicas del perfil DCAT-AP | `dct` | `http://purl.org/dc/terms/` | Dublin Core Terms | Metadatos básicos para describir recursos diff --git a/docs/conventions.en.md b/docs/conventions.en.md index db3c694..3036ef7 100644 --- a/docs/conventions.en.md +++ b/docs/conventions.en.md @@ -746,7 +746,6 @@ The listed prefixes are the most commonly used, although technically other prefi | Prefix | URI | Name | Description | |---------|-----|---------|-------------| | `adms` | `http://www.w3.org/ns/adms#` | Asset Description | Description of semantic assets | -| `cnt` | `http://www.w3.org/2011/content#` | Representing Content in RDF | Representation of content in RDF | | `dcat` | `http://www.w3.org/ns/dcat#` | Data Catalog Vocabulary | Vocabulary for describing data catalogs | | `dcatap` | `http://data.europa.eu/r5r/` | DCAT-AP | Specific extensions of the DCAT-AP profile | | `dct` | `http://purl.org/dc/terms/` | Dublin Core Terms | Basic metadata for describing resources | diff --git a/docs/conventions.md b/docs/conventions.md index 195483d..bdc77ce 100644 --- a/docs/conventions.md +++ b/docs/conventions.md @@ -741,7 +741,6 @@ Los prefijos listados son los más comúnmente utilizados, aunque técnicamente | Prefijo | URI | Nombre | Descripción | |---------|-----|---------|-------------| | `adms` | `http://www.w3.org/ns/adms#` | Asset Description | Descripción de activos semánticos | -| `cnt` | `http://www.w3.org/2011/content#` | Representing Content in RDF | Representación de contenidos en RDF | | `dcat` | `http://www.w3.org/ns/dcat#` | Data Catalog Vocabulary | Vocabulario para describir catálogos de datos | | `dcatap` | `http://data.europa.eu/r5r/` | DCAT-AP | Extensiones específicas del perfil DCAT-AP | | `dct` | `http://purl.org/dc/terms/` | Dublin Core Terms | Metadatos básicos para describir recursos | diff --git a/examples/ttl/Conventions_dataservice-hvd-dataservice.ttl b/examples/ttl/Conventions_dataservice-hvd-dataservice.ttl index 5560eb5..4c9ff64 100644 --- a/examples/ttl/Conventions_dataservice-hvd-dataservice.ttl +++ b/examples/ttl/Conventions_dataservice-hvd-dataservice.ttl @@ -3,7 +3,6 @@ @prefix dcatap: . @prefix foaf: . @prefix vcard: . -@prefix cnt: . @prefix xsd: . a dcat:Distribution ; @@ -14,7 +13,6 @@ dct:license ; dct:modified "2024-12-17"^^xsd:date ; dct:title "Sample CSV" ; - cnt:characterEncoding "UTF-8" ; dcat:accessService [ a dcat:DataService ; dct:title "Example Server" ; dcat:theme ; diff --git a/tests/validate-local.sh b/tests/validate-local.sh index 5b0155f..ad24b1e 100644 --- a/tests/validate-local.sh +++ b/tests/validate-local.sh @@ -136,6 +136,7 @@ main() { # Mount workspace as /workspace and set it as working directory # The Python script inside Docker will handle all output and sections docker run --rm \ + --user "$(id -u):$(id -g)" \ -v "$PWD:/workspace" \ -w /workspace \ "$DOCKER_IMAGE" \