Skip to content

Commit d30432e

Browse files
pngwngradio-pr-bot
andauthored
harden CI (#8965)
* test pr * conditional * conditional * conditional * conditional * conditional * changes * changes * add changeset * changes --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent d4c503a commit d30432e

31 files changed

+724
-663
lines changed

.changeset/dark-dancers-hide.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@gradio/client": minor
3+
"gradio": minor
4+
"website": minor
5+
---
6+
7+
feat:harden CI

.config/.prettierignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
**/*.md
12
**/js/app/public/**
23
**/pnpm-workspace.yaml
34
**/js/app/dist/**
@@ -12,7 +13,7 @@
1213
**/gradio/**
1314
**/.pnpm-store/**
1415
**/.venv/**
15-
**/.github/**
16+
1617
/guides/**
1718
**/.mypy_cache/**
1819
!test-strategy.md
@@ -25,7 +26,6 @@
2526
sweep.yaml
2627
**/.vercel/**
2728
**/build/**
28-
**/*.md
2929
**/src/lib/json/**/*
3030
**/playwright/.cache/**/*
3131
**/theme/src/pollen.css

.github/actions/changes/action.yml

Lines changed: 44 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@ name: "prepare"
22
description: "Prepare workflow"
33

44
inputs:
5-
type:
6-
description: "Type of workflow"
7-
default: "one of: `gradio`, `python-client`, `js`, `js-client`, `functional`"
85
token:
9-
description: "Github token"
10-
required: true
11-
name:
12-
description: "Check name"
13-
default: "false"
14-
commit_status:
15-
description: "Whether to create a commit status"
16-
default: "true"
6+
description: "GitHub token"
7+
filter:
8+
description: "Which filter to use"
9+
1710
outputs:
1811
should_run:
1912
description: "Whether to run the workflow"
@@ -30,122 +23,55 @@ outputs:
3023
source_branch:
3124
description: "Source branch"
3225
value: ${{ steps.pr.outputs.source_branch }}
33-
merge_sha:
34-
description: "SHA of the merged result preview branch"
35-
value: ${{ steps.pr.outputs.merge_sha }}
36-
mergeable:
37-
description: "Whether the PR is mergeable"
38-
value: ${{ steps.pr.outputs.mergeable }}
3926
labels:
4027
description: "Labels on the PR"
4128
value: ${{ steps.pr.outputs.labels }}
42-
found_pr:
43-
description: "Whether a PR was found"
44-
value: ${{ steps.pr.outputs.found_pr }}
29+
run_id:
30+
description: "Run ID"
31+
value: ${{ steps.pr.outputs.run_id }}
32+
gradio_version:
33+
description: "Gradio version"
34+
value: ${{ steps.pr.outputs.gradio_version }}
4535

4636
runs:
4737
using: "composite"
4838
steps:
49-
- name: "Get PR number"
50-
id: pr
51-
uses: "gradio-app/github/actions/find-pr@main"
52-
with:
53-
github_token: ${{ inputs.token }}
5439
- uses: actions/checkout@v4
55-
with:
56-
repository: ${{ github.repository }}
57-
ref: ${{ steps.pr.outputs.sha }}
58-
fetch-depth: 0
59-
token: ${{ inputs.token }}
60-
- uses: dorny/paths-filter@v3
40+
- uses: gradio-app/github/actions/filter-paths@main
6141
id: changes
6242
with:
63-
base: main
64-
ref: ${{ steps.pr.outputs.sha == github.sha && 'main' || steps.pr.outputs.sha }}
65-
filters: |
66-
gradio:
67-
- 'client/python/**'
68-
- 'gradio/**'
69-
- 'requirements.txt'
70-
- '.github/**'
71-
- 'scripts/**'
72-
- 'test/**'
73-
js:
74-
- 'js/**'
75-
- 'client/js/**'
76-
- '.github/**'
77-
- 'package.json'
78-
- 'pnpm-lock.yaml'
79-
- 'tsconfig.json'
80-
- '.config/**'
81-
functional:
82-
- '.github/**'
83-
- 'client/**'
84-
- 'demo/**'
85-
- 'gradio/**'
86-
- 'js/**'
87-
- 'scripts/**'
88-
- 'globals.d.ts'
89-
- 'package.json'
90-
- 'pnpm-lock.yaml'
91-
- 'pyproject.toml'
92-
- 'requirements.txt'
93-
- '.config/**'
94-
visual:
95-
- '.github/workflows/deploy-chromatic.yml'
96-
- 'js!(/_website)/**'
97-
- 'package.json'
98-
website:
99-
- 'js/_website/**'
100-
- 'package.json'
101-
- 'pnpm-lock.yaml'
102-
- 'guides/**'
103-
- 'README.md'
104-
- 'CHANGELOG.md'
105-
- 'gradio/**'
106-
- 'client/**'
107-
- 'demo/**'
108-
- '.github/deplooy-website.yml'
109-
110-
- name: set env (gradio)
111-
if: ${{ inputs.type == 'gradio' }}
112-
shell: bash
113-
run: echo "SHOULD_RUN=${{ steps.changes.outputs.gradio == 'true' }}" >> $GITHUB_ENV
114-
- name: set env (js)
115-
if: ${{ inputs.type == 'js' }}
116-
shell: bash
117-
run: echo "SHOULD_RUN=${{ steps.changes.outputs.js == 'true' }}" >> $GITHUB_ENV
118-
- name: set env (functional)
119-
if: ${{ inputs.type == 'functional' }}
120-
shell: bash
121-
run: echo "SHOULD_RUN=${{ steps.changes.outputs.functional == 'true' }}" >> $GITHUB_ENV
122-
- name: set env (visual)
123-
if: ${{ inputs.type == 'visual' }}
124-
shell: bash
125-
run: echo "SHOULD_RUN=${{ steps.changes.outputs.visual == 'true' }}" >> $GITHUB_ENV
126-
- name: set end (all)
127-
if: ${{ inputs.type == 'all' }}
128-
shell: bash
129-
run: echo "SHOULD_RUN=true" >> $GITHUB_ENV
130-
- name: set env (website)
131-
if: ${{ inputs.type == 'website' }}
132-
shell: bash
133-
run: echo "SHOULD_RUN=${{ steps.changes.outputs.website == 'true' }}" >> $GITHUB_ENV
134-
- if: ${{ steps.pr.outputs.mergeable == 'false' && steps.pr.outputs.source_branch != 'main' }}
135-
run: echo "SHOULD_RUN=false" >> $GITHUB_ENV
136-
shell: bash
137-
- name: set output
138-
id: should_run
43+
token: ${{ inputs.token }}
44+
filter: ${{ inputs.filter }}
45+
- name: get gradio version
46+
id: gradio_version
47+
run: |
48+
GRADIO_VERSION=$(curl -s https://pypi.org/pypi/gradio/json | grep -o '"version":"[^"]*"' | cut -d'"' -f4 | head -n 1)"
49+
echo $GRADIO_VERSION >> $GITHUB_OUTPUT
50+
- name: convert to JSON
51+
uses: gradio-app/github/actions/input-to-json@main
52+
with:
53+
path: output.json
54+
sha: ${{ github.event.pull_request?.head.sha || github.sha }}
55+
source_repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
56+
source_branch: ${{ github.event.pull_request.head.ref || github.ref }}
57+
pr_number: ${{ github.event.pull_request?.number || 'false'}}
58+
should_run: ${{ steps.changes.outputs.should_run }}
59+
labels: ${{ github.event.pull_request.labels }}
60+
run_id: ${{ github.run_id }}
61+
gradio_version: ${{ steps.gradio_version.outputs.gradio_version }}
62+
- name: cat json #remove
63+
run: cat output.json
13964
shell: bash
140-
run: echo "should_run=${{ env.SHOULD_RUN }}" >> $GITHUB_OUTPUT
141-
- uses: "gradio-app/github/actions/commit-status@main"
65+
- name: upload JSON
66+
uses: actions/upload-artifact@v4
14267
with:
143-
token: ${{ inputs.token }}
144-
pr: ${{ steps.pr.outputs.pr_number }}
145-
sha: ${{ steps.pr.outputs.sha }}
146-
name: ${{ inputs.name }}
147-
changes: ${{ steps.changes.outputs.changes }}
148-
type: ${{ inputs.type }}
149-
init: true
150-
mergeable: ${{ steps.pr.outputs.source_branch == 'main' || steps.pr.outputs.mergeable }}
151-
commit_status: ${{ inputs.type == 'visual' && steps.should_run.outputs.should_run == 'false' || inputs.commit_status }}
68+
name: output.json
69+
path: output.json
70+
- name: set outputs
71+
id: pr
72+
uses: gradio-app/github/actions/json_to_outputs@main
73+
with:
74+
json: output.json
75+
- name: echo outputs #remove
76+
run: echo ${{ toJson(steps.pr.outputs) }}
77+
shell: bash

.github/actions/install-all-deps/action.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
name: 'install all deps'
2-
description: 'Install all deps'
1+
name: "install all deps"
2+
description: "Install all deps"
33

44
inputs:
55
always_install_pnpm:
6-
description: 'Dictates whether or not we should install pnpm & dependencies, regardless of the cache'
7-
default: 'false'
6+
description: "Dictates whether or not we should install pnpm & dependencies, regardless of the cache"
7+
default: "false"
88
skip_build:
9-
description: 'Skip build'
10-
default: 'false'
9+
description: "Skip build"
10+
default: "false"
1111
build_lite:
12-
description: 'Build lite'
13-
default: 'false'
12+
description: "Build lite"
13+
default: "false"
1414
test:
15-
description: 'Test'
16-
default: 'false'
15+
description: "Test"
16+
default: "false"
1717
python_version:
18-
description: 'Python version'
19-
default: '3.8'
18+
description: "Python version"
19+
default: "3.8"
2020
os:
21-
description: 'OS'
22-
default: 'ubuntu-latest'
21+
description: "OS"
22+
default: "ubuntu-latest"
2323
outputs:
2424
venv_activate:
25-
description: 'Venv activate'
25+
description: "Venv activate"
2626
value: ${{ steps.venv.outputs.venv_activate }}
2727

2828
runs:

.github/actions/install-frontend-deps/action.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
name: 'install frontend'
2-
description: 'Install frontend deps'
1+
name: "install frontend"
2+
description: "Install frontend deps"
33

44
inputs:
55
always_install_pnpm:
6-
description: 'Dictates whether or not we should install pnpm & dependencies, regardless of the cache'
7-
default: 'false'
6+
description: "Dictates whether or not we should install pnpm & dependencies, regardless of the cache"
7+
default: "false"
88
skip_build:
9-
description: 'Skip build'
10-
default: 'false'
9+
description: "Skip build"
10+
default: "false"
1111
build_lite:
12-
description: 'Build lite'
13-
default: 'false'
12+
description: "Build lite"
13+
default: "false"
1414

1515
runs:
1616
using: "composite"

.github/filters.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"gradio": [
3+
"client/python/**",
4+
"gradio/**",
5+
"requirements.txt",
6+
".github/**",
7+
"scripts/**",
8+
"test/**"
9+
],
10+
"js": [
11+
"js/**",
12+
"client/js/**",
13+
".github/**",
14+
"package.json",
15+
"pnpm-lock.yaml",
16+
"tsconfig.json",
17+
".config/**"
18+
],
19+
"functional": [
20+
".github/**",
21+
"client/**",
22+
"demo/**",
23+
"gradio/**",
24+
"js/**",
25+
"scripts/**",
26+
27+
"globals.d.ts",
28+
"package.json",
29+
"pnpm-lock.yaml",
30+
"pyproject.toml",
31+
"requirements.txt",
32+
".config/**"
33+
],
34+
"visual": [
35+
".github/workflows/deploy-chromatic.yml",
36+
"js!(/_website)/**",
37+
"package.json"
38+
],
39+
"website": [
40+
"js/_website/**",
41+
"package.json",
42+
"pnpm-lock.yaml",
43+
"guides/**",
44+
"README.md",
45+
"CHANGELOG.md",
46+
"gradio/**",
47+
"client/**",
48+
"demo/**",
49+
".github/deploy-website.yml"
50+
]
51+
}

.github/workflows/comment-queue.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ on:
2222

2323
jobs:
2424
comment:
25+
environment: comment_pr
2526
concurrency:
2627
group: ${{inputs.pr_number || inputs.tag}}
2728
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)