Skip to content

Refactor build pipeline and add synonyms to some translations #179

Refactor build pipeline and add synonyms to some translations

Refactor build pipeline and add synonyms to some translations #179

Workflow file for this run

name: 'Create OAK diffs on Pull requests'
on:
# Triggers the workflow on pull request events for the master branch
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_branch:
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5
steps:
- uses: actions/checkout@v4
- name: Build ontology
run: |
cd src/ontology; make IMP=FALSE PAT=FALSE MIR=FALSE hp.obo -B
cp hp.obo tmp/hp-branch.obo
- name: Upload tmp/hp-branch.obo
uses: actions/upload-artifact@v4
with:
name: hp-branch.obo
path: src/ontology/tmp/hp-branch.obo
retention-days: 1
build_main:
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5
steps:
- uses: actions/checkout@v3
with:
ref: master
- name: Classify ontology
run: |
cd src/ontology; make IMP=FALSE PAT=FALSE MIR=FALSE hp.obo -B
cp hp.obo tmp/hp-main.obo
- name: Upload tmp/hp-main.obo
uses: actions/upload-artifact@v4
with:
name: hp-main.obo
path: src/ontology/tmp/hp-main.obo
retention-days: 1
diff:
needs:
- build_branch
- build_main
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5
steps:
- uses: actions/checkout@v4
- name: Download main build
uses: actions/download-artifact@v4
with:
name: hp-main.obo
path: src/ontology/tmp/
- name: Download branch build
uses: actions/download-artifact@v4
with:
name: hp-branch.obo
path: src/ontology/tmp/
- name: Diff classification
run: |
pip install -U oaklib
cd src/ontology;
runoak -i simpleobo:tmp/hp-main.obo diff -X simpleobo:tmp/hp-branch.obo -o reports/difference_main-branch_base.md --output-type md
- name: Upload diff
uses: actions/upload-artifact@v4
with:
name: difference_main-branch_base.md
path: src/ontology/reports/difference_main-branch_base.md
post_comment:
needs: diff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download reasoned diff
uses: actions/download-artifact@v4
with:
name: difference_main-branch_base.md
path: src/ontology/reports/
# - name: Prepare reasoned comment
# run: "echo \"<details>\n <summary> Here's a diff of how these changes impact the classified ontology: </summary> \n\" >comment.md; cat src/ontology/reports/difference_main-branch_base.md >>comment.md"
# - name: Post reasoned comment
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# uses: NejcZdovc/[email protected]
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# file: "../../comment.md"
# identifier: "REASONED"
# Post or update comment on pull request if difference_md.md exists
- name: Post or update comment on pull request
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = 'src/ontology/reports/difference_main-branch_base.md';
if (fs.existsSync(path)) {
let content = fs.readFileSync(path, 'utf8');
if (content) {
// GitHub's max issue body size is approximately 65536 characters
const maxBodySize = 65536;
const truncateMsg = '\n</details>\n\n ### WARNING: This diff is too large and has been truncated. For full diff see [here](https://github.com/${{ github.repository }}/blob/${{ github.head_ref }}/src/ontology/reports/difference_main-branch_base.md).';
if (content.length > maxBodySize) {
// Truncate the content to fit within the GitHub comment size limit
content = content.substring(0, maxBodySize - truncateMsg.length) + truncateMsg;
}
const { owner, repo } = context.repo;
const { number } = context.issue;
const existingComments = await github.rest.issues.listComments({
owner,
repo,
issue_number: number
});
const existingComment = existingComments.data.find(comment => comment.user.login === 'github-actions[bot]');
if (existingComment) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existingComment.id,
body: content
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number: number,
body: content
});
}
} else {
console.log("The markdown file is empty."); // Debug print if the file is empty
}
} else {
console.log("The markdown file does not exist."); // Debug print if the file does not exist
}