Turtle File Quality Control #14
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: Turtle File Quality Control | |
on: | |
push: | |
paths: | |
- 'data/**' | |
workflow_dispatch: | |
jobs: | |
quality-control: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# Step 2: Set up Python (if needed for the tools) | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
# Step 3: Install RDFLib | |
- name: Install RDFLib | |
run: | | |
pip install rdflib | |
# Step 4: Create Validation Script | |
- name: Create Validation Script | |
run: | | |
echo " | |
import sys | |
from rdflib import Graph | |
def validate_turtle(file_path): | |
try: | |
g = Graph() | |
g.parse(file_path, format='turtle') | |
print(f'File {file_path} is valid.') | |
except Exception as e: | |
print(f'Error in {file_path}: {e}', file=sys.stderr) | |
sys.exit(1) | |
if __name__ == '__main__': | |
for file in sys.argv[1:]: | |
validate_turtle(file) | |
" > validate_ttl.py | |
# Step 5: Syntax Check for Turtle Files using the Script | |
- name: Syntax Check for Turtle Files | |
run: | | |
python validate_ttl.py data/AOPWikiRDF.ttl data/AOPWikiRDF-Genes.ttl data/AOPWikiRDF-Void.ttl | |
# Optional: Upload Report (only if the workflow failed) | |
- name: Upload QC Report | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: qc-report | |
path: data/qc-report.txt | |
- name: Upload QC Status | |
if: success() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: qc-status | |
path: . | |
retention-days: 7 |