diff --git a/.github/workflows/ansr_generate_other_formats.yaml b/.github/workflows/ansr_generate_other_formats.yaml new file mode 100644 index 000000000..b5dde98eb --- /dev/null +++ b/.github/workflows/ansr_generate_other_formats.yaml @@ -0,0 +1,17 @@ +name: generating other formats for anatomical_structure + +on: + pull_request_target: + types: [opened, synchronize] + paths: + - 'linkml-schema/anatomical_structure.yaml' + + +permissions: + contents: write + +jobs: + generate_from_reusable: + uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main + with: + model_name: anatomical_structure \ No newline at end of file diff --git a/.github/workflows/assertion_generate_other_formats.yaml b/.github/workflows/assertion_generate_other_formats.yaml new file mode 100644 index 000000000..cf6b129d1 --- /dev/null +++ b/.github/workflows/assertion_generate_other_formats.yaml @@ -0,0 +1,17 @@ +name: generating other formats for assertion_evidence + +on: + pull_request_target: + types: [opened, synchronize] + paths: + - 'linkml-schema/assertion_evidence.yaml' + + +permissions: + contents: write + +jobs: + generate_from_reusable: + uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main + with: + model_name: assertion_evidence \ No newline at end of file diff --git a/.github/workflows/generate_other_formats.yaml b/.github/workflows/generate_other_formats.yaml deleted file mode 100644 index d66b6952a..000000000 --- a/.github/workflows/generate_other_formats.yaml +++ /dev/null @@ -1,74 +0,0 @@ -name: generating other formats - -on: - push: - branches: - - main - paths: - - 'linkml-schema/**' - workflow_run: - workflows: [ generating yaml file ] - types: - - completed - - -permissions: - contents: write - - -jobs: - generate: - runs-on: ubuntu-latest - steps: - - name: Checkout this repository - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - - name: Install the required python packages - run: python -m pip install .[test] - - - name: Other installations - run: | - sudo apt-get update - sudo apt-get install -y build-essential git wget curl - - - name: Generate other model representations - run: | - cd linkml-schema - for file in *.yaml; do - if [[ "$file" != *bican* && "$file" != *core* ]]; then - name=`basename ${file} .yaml`; - echo "Processing $name file.."; - gen-json-schema ${file} > ../json-schema-autogen/${name}.json; - # generating jsonld context and removing generation_date field to avoid constant updates - gen-jsonld-context ${file} > ../jsonld-context-autogen/${name}.context.jsonld; - sed -i "/generation_date/d" ../jsonld-context-autogen/${name}.context.jsonld; - gen-pydantic ${file} > ../models_py-autogen/${name}.py; - if [ ${name} = "library_generation" ] || [ ${name} = "genome_annotation" ]; then - echo "Creating and Fixing diagrams for $name"; - python ../utils/fix_and_create_erdiagram.py - else - gen-erdiagram ${file} > ../erdiagram-autogen/${name}.md; - fi - fi - done - cd .. - - - name: Adding other model representations to git - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - if ! git diff --quiet; then - git add json-schema-autogen/*.json - git add jsonld-context-autogen/*.context.jsonld - git add models_py-autogen/*.py - git add erdiagram-autogen/*.md - git commit -m "generate another formats" - git push - else - echo "No changes to commit" - fi \ No newline at end of file diff --git a/.github/workflows/genome_generate_other_formats.yaml b/.github/workflows/genome_generate_other_formats.yaml new file mode 100644 index 000000000..ad122eced --- /dev/null +++ b/.github/workflows/genome_generate_other_formats.yaml @@ -0,0 +1,17 @@ +name: generating other formats for genome_annotation + +on: + pull_request_target: + types: [opened, synchronize] + paths: + - 'linkml-schema/genome_annotation.yaml' + + +permissions: + contents: write + +jobs: + generate_from_reusable: + uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main + with: + model_name: genome_annotation \ No newline at end of file diff --git a/.github/workflows/library_generate_other_formats.yaml b/.github/workflows/library_generate_other_formats.yaml new file mode 100644 index 000000000..4a7daa22f --- /dev/null +++ b/.github/workflows/library_generate_other_formats.yaml @@ -0,0 +1,17 @@ +name: generating other formats for library_generation + +on: + pull_request_target: + types: [opened, synchronize] + paths: + - 'linkml-schema/library_generation.yaml' + + +permissions: + contents: write + +jobs: + generate_from_reusable: + uses: brain-bican/models/.github/workflows/reusable-generate_other_formats.yaml@main + with: + model_name: library_generation \ No newline at end of file diff --git a/.github/workflows/reusable-generate_other_formats.yaml b/.github/workflows/reusable-generate_other_formats.yaml new file mode 100644 index 000000000..db158a12c --- /dev/null +++ b/.github/workflows/reusable-generate_other_formats.yaml @@ -0,0 +1,73 @@ +name: Reusable workflow for generating other formats + +on: + workflow_call: + inputs: + model_name: + description: 'A name of the model, without the .yaml extension' + required: true + type: string + +permissions: + contents: write + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - name: Checkout this repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + + - name: Install the required python packages + run: python -m pip install .[test] + + - name: Other installations + run: | + sudo apt-get update + sudo apt-get install -y build-essential git wget curl + + - name: Generate other model representations + run: | + cd linkml-schema + name=${{ inputs.model_name }}; + echo "Processing $name model..."; + gen-json-schema ${name}.yaml > ../json-schema-autogen/${name}.json; + # generating jsonld context and removing generation_date field to avoid constant updates + gen-jsonld-context ${name}.yaml > ../jsonld-context-autogen/${name}.context.jsonld; + sed -i "/generation_date/d" ../jsonld-context-autogen/${name}.context.jsonld; + gen-pydantic ${name}.yaml > ../models_py-autogen/${name}.py; + if [ ${name} = "library_generation" ] || [ ${name} = "genome_annotation" ]; then + echo "Fixing erdiagrams for $name"; + python ../utils/fix_and_create_erdiagram.py; + else + gen-erdiagram ${name}.yaml > ../erdiagram-autogen/${name}.md; + fi + cd .. + + - name: Adding other model representations to git + run: | + name=${{ inputs.model_name }}; + git config --global user.name "action@github.com" + git config --global user.email "Github Actions" + git branch + git diff + git add json-schema-autogen/${name}.json + git add jsonld-context-autogen/${name}.context.jsonld + git add models_py-autogen/${name}.py + git add erdiagram-autogen/${name}.md + if ! git diff --quiet HEAD; then + git commit -m "generate another formats for ${name} model" + git pull --rebase # to avoid conflicts with different wf runs + git push + else + echo "No changes to commit" + fi \ No newline at end of file