Skip to content

Commit 514a269

Browse files
authored
Merge pull request #116 from djarecka/ci/new_generate_ga
new workflows to generate other formats
2 parents 192eb2e + 36baa8e commit 514a269

6 files changed

+141
-74
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: generating other formats for anatomical_structure
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'linkml-schema/anatomical_structure.yaml'
8+
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
generate_from_reusable:
15+
uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main
16+
with:
17+
model_name: anatomical_structure
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: generating other formats for assertion_evidence
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'linkml-schema/assertion_evidence.yaml'
8+
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
generate_from_reusable:
15+
uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main
16+
with:
17+
model_name: assertion_evidence

.github/workflows/generate_other_formats.yaml

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: generating other formats for genome_annotation
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'linkml-schema/genome_annotation.yaml'
8+
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
generate_from_reusable:
15+
uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main
16+
with:
17+
model_name: genome_annotation
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: generating other formats for library_generation
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'linkml-schema/library_generation.yaml'
8+
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
generate_from_reusable:
15+
uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main
16+
with:
17+
model_name: library_generation
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Reusable workflow for generating other formats
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
model_name:
7+
description: 'A name of the model, without the .yaml extension'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
generate:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout this repository
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
repository: ${{ github.event.pull_request.head.repo.full_name }}
23+
ref: ${{ github.event.pull_request.head.ref }}
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: 3.9
29+
30+
- name: Install the required python packages
31+
run: python -m pip install .[test]
32+
33+
- name: Other installations
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y build-essential git wget curl
37+
38+
- name: Generate other model representations
39+
run: |
40+
cd linkml-schema
41+
name=${{ inputs.model_name }};
42+
echo "Processing $name model...";
43+
gen-json-schema ${name}.yaml > ../json-schema-autogen/${name}.json;
44+
# generating jsonld context and removing generation_date field to avoid constant updates
45+
gen-jsonld-context ${name}.yaml > ../jsonld-context-autogen/${name}.context.jsonld;
46+
sed -i "/generation_date/d" ../jsonld-context-autogen/${name}.context.jsonld;
47+
gen-pydantic ${name}.yaml > ../models_py-autogen/${name}.py;
48+
if [ ${name} = "library_generation" ] || [ ${name} = "genome_annotation" ]; then
49+
echo "Fixing erdiagrams for $name";
50+
python ../utils/fix_and_create_erdiagram.py;
51+
else
52+
gen-erdiagram ${name}.yaml > ../erdiagram-autogen/${name}.md;
53+
fi
54+
cd ..
55+
56+
- name: Adding other model representations to git
57+
run: |
58+
name=${{ inputs.model_name }};
59+
git config --global user.name "[email protected]"
60+
git config --global user.email "Github Actions"
61+
git branch
62+
git diff
63+
git add json-schema-autogen/${name}.json
64+
git add jsonld-context-autogen/${name}.context.jsonld
65+
git add models_py-autogen/${name}.py
66+
git add erdiagram-autogen/${name}.md
67+
if ! git diff --quiet HEAD; then
68+
git commit -m "generate another formats for ${name} model"
69+
git pull --rebase # to avoid conflicts with different wf runs
70+
git push
71+
else
72+
echo "No changes to commit"
73+
fi

0 commit comments

Comments
 (0)