2024-02-01 08:46:55 +08:00
|
|
|
name: "test / visual"
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_run:
|
|
|
|
workflows: ["trigger"]
|
|
|
|
types:
|
|
|
|
- requested
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
statuses: write
|
|
|
|
|
|
|
|
concurrency:
|
2024-02-01 09:39:27 +08:00
|
|
|
|
2024-02-01 18:24:15 +08:00
|
|
|
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
|
2024-02-01 08:46:55 +08:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
changes:
|
|
|
|
name: "changes"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
should_run: ${{ steps.changes.outputs.should_run }}
|
|
|
|
sha: ${{ steps.changes.outputs.sha }}
|
|
|
|
pr_number: ${{ steps.changes.outputs.pr_number }}
|
|
|
|
source_branch: ${{ steps.changes.outputs.source_branch }}
|
|
|
|
source_repo: ${{ steps.changes.outputs.source_repo }}
|
|
|
|
labels: ${{ steps.changes.outputs.labels }}
|
2024-02-01 21:27:54 +08:00
|
|
|
mergeable: ${{ steps.changes.outputs.mergeable }}
|
2024-02-01 08:46:55 +08:00
|
|
|
steps:
|
2024-02-02 02:14:41 +08:00
|
|
|
- uses: actions/checkout@v4
|
2024-02-01 18:34:22 +08:00
|
|
|
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
2024-02-01 08:46:55 +08:00
|
|
|
id: changes
|
|
|
|
with:
|
|
|
|
type: "visual"
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2024-02-02 03:39:12 +08:00
|
|
|
name: "UI Tests"
|
2024-02-01 08:46:55 +08:00
|
|
|
comment-chromatic-start:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
|
|
|
needs: changes
|
|
|
|
if: ${{ needs.changes.outputs.should_run == 'true' }}
|
|
|
|
secrets:
|
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
with:
|
|
|
|
pr_number: ${{ needs.changes.outputs.pr_number }}
|
|
|
|
message: |
|
|
|
|
storybook~pending~null
|
|
|
|
test-visual:
|
2024-02-02 03:39:12 +08:00
|
|
|
name: "test-visual"
|
2024-02-01 08:46:55 +08:00
|
|
|
needs: changes
|
|
|
|
if: ${{ needs.changes.outputs.should_run == 'true' && github.repository == 'gradio-app/gradio' && !contains(needs.changes.outputs.labels, 'no-visual-update') }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
changes: ${{ steps.publish-chromatic.outputs.changeCount }}
|
|
|
|
errors: ${{ steps.publish-chromatic.outputs.errorCount }}
|
|
|
|
storybook_url: ${{ steps.publish-chromatic.outputs.storybookUrl }}
|
|
|
|
build_url: ${{ steps.publish-chromatic.outputs.buildUrl }}
|
|
|
|
steps:
|
2024-02-02 02:14:41 +08:00
|
|
|
- uses: actions/checkout@v4
|
2024-02-01 08:46:55 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
ref: ${{ needs.changes.outputs.sha }}
|
2024-02-01 21:15:15 +08:00
|
|
|
repository: ${{ needs.changes.outputs.mergeable == 'true' && github.repository || needs.changes.outputs.source_repo }}
|
2024-02-01 08:46:55 +08:00
|
|
|
- name: install dependencies
|
2024-02-01 18:34:22 +08:00
|
|
|
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
2024-02-01 08:46:55 +08:00
|
|
|
with:
|
|
|
|
always_install_pnpm: true
|
|
|
|
skip_build: 'true'
|
|
|
|
- name: build client
|
|
|
|
run: pnpm --filter @gradio/client build
|
|
|
|
- name: generate theme.css
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
python scripts/generate_theme.py --outfile js/storybook/theme.css
|
|
|
|
- name: build storybook
|
|
|
|
run: pnpm build-storybook --quiet
|
|
|
|
- name: publish to chromatic
|
|
|
|
id: publish-chromatic
|
|
|
|
uses: chromaui/action@v10
|
|
|
|
with:
|
|
|
|
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
onlyChanged: true
|
|
|
|
exitOnceUploaded: true
|
|
|
|
|
|
|
|
comment-chromatic-end:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
|
|
|
needs: [test-visual, changes]
|
|
|
|
secrets:
|
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
with:
|
|
|
|
pr_number: ${{ needs.changes.outputs.pr_number }}
|
|
|
|
message: |
|
|
|
|
storybook~success~${{ needs.test-visual.outputs.storybook_url }}
|
|
|
|
|
|
|
|
comment-chromatic-fail:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
|
|
|
needs: [test-visual, changes]
|
|
|
|
if: always() && needs.test-visual.result == 'failure'
|
|
|
|
secrets:
|
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
with:
|
|
|
|
pr_number: ${{ needs.changes.outputs.pr_number }}
|
|
|
|
message: |
|
|
|
|
storybook~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# visual~success~${{ needs.chromatic-deployment.outputs.changes }}~${{ needs.chromatic-deployment.outputs.errors }}~${{ needs.chromatic-deployment.outputs.build_url }}
|
|
|
|
|
2024-02-02 02:14:41 +08:00
|
|
|
# visual~failure~0~0~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|