-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjustfile
101 lines (85 loc) · 3.83 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# This file defines task to be run locally with the just command runner.
#
# Just can be installed in various ways and is available for Linux, MacOS and
# Windows, see https://github.com/casey/just?tab=readme-ov-file#installation
#
# It also requires "uv" which makes running python tools like voc4cat simpler.
# To install follow https://docs.astral.sh/uv/getting-started/installation/
#
# This recipe file assumes presence of a "bash" shell even on Windows.
# It is included in git for windows so most likely you have it already.
# Else download it from https://git-scm.com/download/win
export GITHUB_ENV := datetime("%Y-%m-%dT%H%M")
# List all commands as default command. The prefix "_" hides the command.
_default:
@just --list
# Set cross-platform Python shebang line (assumes presence of launcher on Windows)
shebang := if os() == 'windows' {
'py'
} else {
'/usr/bin/env python3'
}
# Directory variables
src := "src"
# Ignore recipe lines beginning with #.
set ignore-comments := true
# Run initial setup (run this first)
[group('environment')]
setup:
# install current voc4cat-tool version
uv tool install voc4cat --with git+https://github.com/dalito/[email protected]
# Upgrades voc4cat-tool installation
[group('environment')]
upgrade:
uv tool install --upgrade voc4cat --with git+https://github.com/dalito/[email protected]
# Check the voc4cat.xlsx file in inbox/ for errors
[group('individual steps')]
check: _fake_actions_env
@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/
# Convert the voc4cat.xlsx file in inbox/ to turtle
[group('individual steps')]
convert: _fake_actions_env
# make a backup of the original file just in case
@cp inbox-excel-vocabs/voc4cat.xlsx inbox-excel-vocabs/voc4cat.xlsx.backup
@voc4cat convert --config _main_branch/idranges.toml --logfile outbox/voc4cat.log --outdir outbox inbox-excel-vocabs/
@if [ -z "$(ls outbox/*.ttl 2>/dev/null)" ]; then \
@echo "No ttl file in outbox. Building joined vocabulary ttl-file from individual ttl-files in vocabulary.\n" && \
@voc4cat transform --join --logfile outbox/voc4cat.log --outdir outbox/ vocabularies/ ;\
fi
#=== post-convert checks ===
# Delete xlsx in outbox that may be present from former runs
@rm -f outbox/voc4cat.xlsx
# check all ttl file(s) in outbox
@voc4cat check --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/
# Run voc4cat (build HTML documentation from ttl files)
[group('individual steps')]
docs:
@voc4cat docs --logfile outbox/voc4cat.log --force outbox/
# Rebuild the xlsx file from the joined ttl file.
[group('individual steps')]
xlsx:
@rm -f outbox/voc4cat.xlsx
@voc4cat convert --logfile outbox/voc4cat.log --template templates/voc4cat_template_043.xlsx outbox/
# Join individual ttl files in vocabularies/ to one turtle file in outbox/
[group('individual steps')]
join:
@voc4cat transform --logfile outbox/voc4cat.log -O outbox --join vocabularies/
# Run all steps as in gh-actions: check xlsx, convert to SKOS, build docs, re-build xlsx
all: check convert docs xlsx
# Create local environment suitable to run the same commands as in gh-actions
_fake_actions_env:
@mkdir -p _main_branch
@mkdir -p _main_branch/vocabularies
@cp idranges.toml _main_branch/idranges.toml
# Remove all generated files/directories
[group('environment')]
clean:
rm -rf outbox
rm -rf outbox_new_voc
rm -rf _main_branch