Skip to content

Fix IRI of vp4cat profile in config #415

Fix IRI of vp4cat profile in config

Fix IRI of vp4cat profile in config #415

Workflow file for this run

# This action runs when a pull request to main is created or updated
# (but not when it is merged into main).
name: CI on pull request create or update
on:
# Using "pull_request" is not sufficient to allow commits to PR branches in
# forks. Since the workflow only accesses the xlsx and turtle files, but does
# not run any code, it is safe to use pull_request_target. More info:
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
# zizmor: ignore[dangerous-triggers] OK as per comment above
pull_request_target:
branches:
- main
types: [opened, reopened, synchronize]
workflow_dispatch:
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_PROGRESS_BAR: "off"
LOGLEVEL: "DEBUG"
RUN_URL: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
build_vocab:
name: Merge & build vocabulary
# Run on all pull request types except merge which has its own workflow.
if: ${{ !github.event.pull_request.merged }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write # Give the default GITHUB_TOKEN write permission to commit to the PR branch.
steps:
- name: Checkout PR branch into cwd
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
# Checkout the fork/head-repository to push changes to the fork.
# Without this the base repository will be checked out and committed to.
repository: ${{ github.event.pull_request.head.repo.full_name }}
# Checkout the branch made in the fork.
ref: ${{ github.head_ref }}
# The full history is required for "voc4cat transform --prov-from-git" below.
fetch-depth: 0
# Be specific about keeping credentials (it is the default)
persist-credentials: true
- name: Checkout main branch into directory _main_branch/
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: main
path: _main_branch
# This sparse-checkout includes all toplevel files and everything below vocabularies/
sparse-checkout: |
vocabularies/
fetch-depth: 1
# Be specific about keeping credentials (it is the default)
persist-credentials: true
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: '3.13'
- name: Install dependencies
run: |
python -VV
python -m pip install --upgrade pip setuptools wheel
# Select to install a stable tagged version or main branch (in development)
python -m pip install git+https://github.com/nfdi4cat/voc4cat-tool.git@v1.0.4
# python -m pip install git+https://github.com/nfdi4cat/voc4cat-tool.git@main
# install custom pylode 2.x (adds sorted collections,
# uses URIs as fragment IDs and is git-installable)
python -m pip install git+https://github.com/dalito/pyLODE.git@nfdi4cat-2.x
- name: Set dynamic environment variables.
run: | # zizmor: ignore[github-env] safe without user controllable input
echo "RUN_DATE=$(date +'%Y-%m-%dT%H%M')" >> $GITHUB_ENV
- name: Run voc4cat (pre-convert checks)
run: |
voc4cat --version
# check inbox file names
voc4cat check --config _main_branch/idranges.toml --logfile outbox/voc4cat.log --ci-pre inbox-excel-vocabs/ _main_branch/vocabularies
# check xlsx file(s). If the check fails, write annotated file to outbox.
voc4cat check --config _main_branch/idranges.toml --logfile outbox/voc4cat.log --outdir outbox inbox-excel-vocabs/
- name: Run voc4cat (convert)
run: |
# convert file(s) from xlsx in inbox to turtle in outbox
voc4cat convert --config _main_branch/idranges.toml --logfile outbox/voc4cat.log --outdir outbox inbox-excel-vocabs/
if [ ! -f outbox/*.ttl ]; then
echo "No ttl file in outbox. Building joined vocabulary ttl-file from individual ttl-files in vocabulary."
voc4cat transform --join --config _main_branch/idranges.toml --logfile outbox/voc4cat.log --outdir outbox/ vocabularies/
fi
- name: Run voc4cat (post-convert checks)
run: |
# check all ttl file(s) in outbox
voc4cat check --redundant-hierarchies --config _main_branch/idranges.toml --logfile outbox/voc4cat.log outbox/
# check if vocabulary changes are allowed
voc4cat check --config _main_branch/idranges.toml --logfile outbox/voc4cat.log --ci-post _main_branch/vocabularies outbox/
- name: Run voc4cat (build HTML documentation)
run: |
voc4cat docs --logfile outbox/voc4cat.log --force outbox/
- name: Split vocabulary, merge into vocabulary dir (in PR branch) and update provenance info
run: |
voc4cat transform --split --inplace --config idranges.toml --logfile outbox/voc4cat.log --outdir outbox_new_voc outbox/
voc4cat-merge --logfile outbox/voc4cat.log outbox_new_voc/ vocabularies/
# copy xlsx to outbox so that the xlsx file is part of the artifact
find inbox-excel-vocabs -name '*.xlsx' -exec cp {} -t outbox/ \;
git status
# Add/update dct:created and dct:modified base on git history
voc4cat transform --prov-from-git --diff-base origin/main --inplace --config idranges.toml --logfile outbox/voc4cat.log vocabularies/
- name: Run voc4cat (re-build updated Excel file and joined turtle vocabulary file)
# Passing the config is important to make use of the prefixes therein.
run: |
mkdir -p outbox/updated-xlsx-ttl
voc4cat transform --join --config idranges.toml --logfile outbox/voc4cat.log --outdir outbox/updated-xlsx-ttl vocabularies/
# Using a template is optional and gives just a warning if missing.
voc4cat convert --config idranges.toml --logfile outbox/voc4cat.log --template templates/default_sheets.xlsx outbox/updated-xlsx-ttl
- name: Store artifacts
if: ${{ always() }}
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
with:
name: voc4cat-outbox_${{ env.RUN_DATE }}_run${{ GITHUB.RUN_ID }}
path: outbox/
- name: Add/stage vocabulary changes
# Pinning of action managed by dependabot
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9
with:
# glob pattern of files which should be added to the commit
file_pattern: 'vocabularies/\*.ttl'
- name: Remove Excel vocabulary files from inbox
run: |
git rm inbox-excel-vocabs/\*.xlsx || echo "No xlsx files to remove."
git status
- name: Commit vocabulary changes & xlsx cleanup on behalf of PR-author
# Pinning of action managed by dependabot
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9
with:
commit_user_name: voc4cat-CI-bot
commit_message: 'CI: vocabulary update in ${{ GITHUB.SERVER_URL }}/${{ GITHUB.REPOSITORY }}/actions/runs/${{ GITHUB.RUN_ID }}'