mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-30 11:00:11 +08:00
Use gradio-pr-bot to make notebook check comments on PRs (#2925)
* Add new workflow files * Fix spacing * Indent * Single quotes * indent * Single quotes * Reorder steps * Only comment once * Comment if true * Use v2
This commit is contained in:
parent
f0727b9192
commit
53fa517480
25
.github/workflows/check-demo-notebooks.yml
vendored
25
.github/workflows/check-demo-notebooks.yml
vendored
@ -3,7 +3,7 @@
|
||||
name: Check Demos Match Notebooks
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
paths:
|
||||
- 'demo/**'
|
||||
@ -26,13 +26,18 @@ jobs:
|
||||
- name: Assert Notebooks Match
|
||||
id: assertNotebooksMatch
|
||||
run: git status | grep "nothing to commit, working tree clean"
|
||||
- name: Comment On PR
|
||||
uses: thollander/actions-comment-pull-request@v1
|
||||
if: always() && (steps.assertNotebooksMatch.outcome == 'failure')
|
||||
- name: Get PR Number
|
||||
if: always()
|
||||
run: |
|
||||
python -c "import os;print(os.environ['GITHUB_REF'].split('/')[2])" > pr_number.txt
|
||||
echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_ENV
|
||||
- name: Upload PR Number
|
||||
if: always()
|
||||
run: |
|
||||
python -c "import json; json.dump({'pr_number': ${{ env.PR_NUMBER }}}, open('metadata.json', 'w'))"
|
||||
- name: Upload metadata
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
message: |
|
||||
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:
|
||||
```bash
|
||||
pip install nbformat && cd demo && python generate_notebooks.py
|
||||
```
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: metadata.json
|
||||
path: metadata.json
|
44
.github/workflows/comment-pr.yml
vendored
Normal file
44
.github/workflows/comment-pr.yml
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [Check Demos Match Notebooks]
|
||||
types: [completed]
|
||||
|
||||
jobs:
|
||||
comment-on-failure:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: '3.9'
|
||||
- name: Install pip
|
||||
run: python -m pip install requests
|
||||
- name: Download metadata
|
||||
run: python scripts/download_artifacts.py ${{github.event.workflow_run.id }} metadata.json ${{ secrets.COMMENT_TOKEN }} --owner ${{ github.repository_owner }}
|
||||
- run: unzip metadata.json.zip
|
||||
- name: Pipe metadata to env
|
||||
run: echo "pr_number=$(python -c 'import json; print(json.load(open("metadata.json"))["pr_number"])')" >> $GITHUB_ENV
|
||||
- name: Comment On Notebook check fail
|
||||
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.name == 'Check Demos Match Notebooks'}}
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
with:
|
||||
message: |
|
||||
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:
|
||||
```bash
|
||||
pip install nbformat && cd demo && python generate_notebooks.py
|
||||
```
|
||||
comment_includes: The demo notebooks don't match the run.py files
|
||||
GITHUB_TOKEN: ${{ secrets.COMMENT_TOKEN }}
|
||||
pr_number: ${{ env.pr_number }}
|
||||
comment_tag: notebook-check
|
||||
- name: Comment On Notebook check fail
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.name == 'Check Demos Match Notebooks'}}
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
with:
|
||||
message: |
|
||||
🎉 The demo notebooks match the run.py files! 🎉
|
||||
comment_includes: The demo notebooks match the run.py files!
|
||||
GITHUB_TOKEN: ${{ secrets.COMMENT_TOKEN }}
|
||||
pr_number: ${{ env.pr_number }}
|
||||
comment_tag: notebook-check
|
Loading…
Reference in New Issue
Block a user