From c3ea1fabe51cb8f7e02662864f1fe992e6c2fb17 Mon Sep 17 00:00:00 2001 From: Harshad Hegde Date: Thu, 21 Mar 2024 10:40:10 -0500 Subject: [PATCH] copy-pasted jinja and edited as per Nico --- .github/workflows/ontology_diff.yml | 4 +- .github/workflows/ontology_diff_2.yml | 128 ++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ontology_diff_2.yml diff --git a/.github/workflows/ontology_diff.yml b/.github/workflows/ontology_diff.yml index e03f32bea..52b169050 100644 --- a/.github/workflows/ontology_diff.yml +++ b/.github/workflows/ontology_diff.yml @@ -2,8 +2,8 @@ name: Post Markdown Comment on Pull Request on: workflow_dispatch: - pull_request: - types: [opened, synchronize] + # pull_request: + # types: [opened, synchronize] jobs: post-comment: diff --git a/.github/workflows/ontology_diff_2.yml b/.github/workflows/ontology_diff_2.yml new file mode 100644 index 000000000..38debc2f9 --- /dev/null +++ b/.github/workflows/ontology_diff_2.yml @@ -0,0 +1,128 @@ +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: + edit_file: + runs-on: ubuntu-latest + container: obolibrary/odkfull:v1.5 + steps: + # Checks-out main branch under "main" directory + - uses: actions/checkout@v4 + with: + ref: master + path: master + + # - name: Install oaklib + # run: pip install oaklib + + # - name: Diff classification + # run: | + # export ROBOT_JAVA_ARGS=-Xmx6G + # runoak -i simpleobo:tmp/hp-edit-master.obo diff -X simpleobo:tmp/hp-edit-pr.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 + classify_branch: + runs-on: ubuntu-latest + container: obolibrary/odkfull:v1.5 + steps: + - uses: actions/checkout@v4 + - name: Classify ontology + run: | + cd src/ontology; make IMP=FALSE PAT=FALSE MIR=FALSE hp-edit.owl && make tmp/hp-edit.obo + + - name: Upload PR hp-edit.obo + uses: actions/upload-artifact@v4 + with: + name: hp-edit-pr.obo + path: src/ontology/tmp/hp-edit.obo + retention-days: 1 + classify_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-edit.owl && make tmp/hp-edit.obo + - name: Upload master hp-edit.obo + uses: actions/upload-artifact@v4 + with: + name: hp-edit-master.obo + path: src/ontology/tmp/hp-edit.obo + retention-days: 1 + diff_classification: + needs: + - classify_branch + - classify_main + runs-on: ubuntu-latest + container: obolibrary/odkfull:v1.5 + steps: + - uses: actions/checkout@v4 + - name: Download master classification + uses: actions/download-artifact@v4 + with: + name: hp-edit-master.obo + path: src/ontology/tmp/hp-edit-master.obo + - name: Download PR classification + uses: actions/download-artifact@v4 + with: + name: hp-edit-pr.obo + path: src/ontology/tmp/hp-edit-pr.obo + - name: Diff classification + run: | + export ROBOT_JAVA_ARGS=-Xmx6G; cd src/ontology; + runoak -i simpleobo:tmp/hp-edit-master.obo diff -X simpleobo:tmp/hp-edit-pr.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_classification, edit_file] + 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/difference_main-branch_base.md + - name: Prepare reasoned comment + run: "echo \"
\n Here's a diff of how these changes impact the classified ontology: \n\" >comment.md; cat difference_main-branch_base.md/difference_main-branch_base.md >>comment.md" + - name: Post reasoned comment + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: NejcZdovc/comment-pr@v1.1.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + file: "../../comment.md" + identifier: "REASONED" + - uses: actions/checkout@v4 + - name: Download edit diff + uses: actions/download-artifact@v4 + with: + name: edit-diff.md + path: edit-diff.md + - name: Prepare edit file comment + run: "echo \"
\n Here's a diff of your edit file (unreasoned) \n\" >edit-comment.md; cat edit-diff.md/edit-diff.md >>edit-comment.md" + - name: Post comment + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: NejcZdovc/comment-pr@v1.1.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + file: "../../edit-comment.md" + identifier: "UNREASONED" \ No newline at end of file