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
6 changes: 3 additions & 3 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

---

Expand Down Expand Up @@ -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)
**TODO**: Añadir versionado con [mike](https://github.com/jimporter/mike)
99 changes: 99 additions & 0 deletions .github/workflows/comment-shacl-report.yml
Original file line number Diff line number Diff line change
@@ -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 = '<!-- dcat-ap-es-shacl-report -->';
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}.`);
}
12 changes: 6 additions & 6 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
uses: actions/deploy-pages@v5
40 changes: 12 additions & 28 deletions .github/workflows/validate-shacl.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'
Expand All @@ -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
Expand All @@ -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 }}"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ node_modules
**/node_modules/
bower_components
.vscode
.vscode/
.idea
*.log

Expand Down Expand Up @@ -136,4 +137,4 @@ tools/.temp
refs/github_issue_*.md
shacl/dev
validation-reports
commit-summary
commit-summary
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

1 change: 0 additions & 1 deletion docs/adoc/conventions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion docs/conventions.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
1 change: 0 additions & 1 deletion docs/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 0 additions & 2 deletions examples/ttl/Conventions_dataservice-hvd-dataservice.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
@prefix dcatap: <http://data.europa.eu/r5r/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix cnt: <http://www.w3.org/2011/content#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://example.org/catalogo/dataset/43bc8990-f9f1-5527-8134-459b1a1cce92/resource/37cfdf38-91cd-4107-a63c-72c739dd41cd> a dcat:Distribution ;
Expand All @@ -14,7 +13,6 @@
dct:license <https://publications.europa.eu/resource/authority/licence/CC_BY_4_0> ;
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 <http://datos.gob.es/kos/sector-publico/sector/medio-ambiente> ;
Expand Down
1 change: 1 addition & 0 deletions tests/validate-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down