Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
pngwn committed Jan 31, 2024
1 parent c16b6d3 commit d523288
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 216 deletions.
152 changes: 152 additions & 0 deletions .github/actions/changes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: "prepare"
description: "Prepare workflow"

inputs:
type:
description: "Type of workflow"
default: "one of: `gradio`, `python-client`, `js`, `js-client`, `functional`"
token:
description: "Github token"
required: true
outputs:
should_run:
description: "Whether to run the workflow"
value: ${{ steps.should_run.outputs.should_run }}
pr_number:
description: "PR number"
value: ${{ steps.pr.outputs.pr_number }}
sha:
description: "SHA of the HEAD commit of the PR"
value: ${{ steps.pr.outputs.sha }}
source_repo:
description: "Source repo"
value: ${{ steps.pr.outputs.source_repo }}
source_branch:
description: "Source branch"
value: ${{ steps.pr.outputs.source_branch }}
merge_sha:
description: "SHA of the merged result preview branch"
value: ${{ steps.merge.outputs.merge_sha }}
mergeable:
description: "Whether the PR is mergeable"
value: ${{ steps.merge.outputs.mergeable }}

runs:
using: "composite"
steps:
- name: "Get PR number"
id: pr
uses: "gradio-app/github/actions/find-pr@main"
with:
github_token: ${{ inputs.token }}
- uses: actions/checkout@v3
with:
repository: ${{ steps.pr.outputs.source_repo }}
ref: ${{ steps.pr.outputs.source_branch }}
fetch-depth: 0
token: ${{ inputs.token }}
- run: echo "FOUND_PR? ${{ steps.pr.outputs.found_pr }}"
shell: bash
- run: echo "SOURCE_BRANCH? ${{ steps.pr.outputs.source_branch }}"
shell: bash
- run: echo "HEAD_SHA? ${{ steps.pr.outputs.sha }}"
shell: bash
- run: echo "PR_NUMBER? ${{ steps.pr.outputs.pr_number }}"
shell: bash
- run: echo "$SOURCE_REPO? {{ steps.pr.outputs.source_repo }}"
shell: bash
- run: echo "MERGE_SHA? ${{ steps.pr.outputs.merge_sha }}"
shell: bash
- run: echo "MERGEABLE? ${{ steps.pr.outputs.mergeable }}"
shell: bash

- uses: dorny/paths-filter@v2
id: changes
with:
ref: ${{ steps.pr.outputs.source_branch }}
filters: |
gradio:
- 'client/python/**'
- 'gradio/**'
- 'requirements.txt'
- '.github/**'
- 'scripts/**'
- 'test/**'
js:
- 'js/**'
- 'client/js/**'
- '.github/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'tsconfig.json'
- '.config/**'
functional:
- '.github/**'
- 'client/**'
- 'demo/**'
- 'gradio/**'
- 'js/**'
- 'scripts/**'
- 'globals.d.ts'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pyproject.toml'
- 'requirements.txt'
- '.config/**'
visual:
- '.github/workflows/deploy-chromatic.yml'
- 'js!(/_website)/**'
- 'package.json'
website:
- 'js/_website/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'guides/**'
- 'README.md'
- 'CHANGELOG.md'
- 'gradio/**'
- 'client/**'
- 'demo/**'
- '.github/deplooy-website.yml'
- name: set env (gradio)
if: ${{ inputs.type == 'gradio' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.gradio == 'true' }}" >> $GITHUB_ENV
- name: set env (js)
if: ${{ inputs.type == 'js' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.js == 'true' }}" >> $GITHUB_ENV
- name: set env (functional)
if: ${{ inputs.type == 'functional' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.functional == 'true' }}" >> $GITHUB_ENV
- name: set env (visual)
if: ${{ inputs.type == 'visual' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.visual == 'true' }}" >> $GITHUB_ENV
- name: set end (all)
if: ${{ inputs.type == 'all' }}
shell: bash
run: echo "SHOULD_RUN=true" >> $GITHUB_ENV
- name: set env (website)
if: ${{ inputs.type == 'website' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.website == 'true' }}" >> $GITHUB_ENV
- if: ${{ steps.pr.outputs.mergeable == 'false' }}
run: echo "SHOULD_RUN=false" >> $GITHUB_ENV
shell: bash
- name: set output
id: should_run
shell: bash
run: echo "should_run=${{ env.SHOULD_RUN }}" >> $GITHUB_OUTPUT
- uses: "./.github/actions/do-check"
with:
token: ${{ inputs.token }}
pr: ${{ steps.pr.outputs.pr_number }}
sha: ${{ steps.pr.outputs.sha }}
name: ${{ inputs.name }}
changes: ${{ steps.changes.outputs.changes }}
type: ${{ inputs.type }}
init: true
mergeable: ${{ steps.pr.outputs.source_branch == 'main' || steps.pr.outputs.mergeable }}
43 changes: 36 additions & 7 deletions .github/actions/install-all-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'install all deps'
description: 'Install all deps'

inputs:
always-install-pnpm:
always_install_pnpm:
description: 'Dictates whether or not we should install pnpm & dependencies, regardless of the cache'
default: 'false'
node_auth_token:
Expand All @@ -14,20 +14,41 @@ inputs:
skip_build:
description: 'Skip build'
default: 'false'
test:
description: 'Test'
default: 'false'
python_version:
description: 'Python version'
default: '3.10'
os:
description: 'OS'
default: 'ubuntu-latest'
outputs:
venv_activate:
description: 'Venv activate'
value: ${{ env.VENV_ACTIVATE }}

runs:
using: "composite"
steps:
- name: Set venv binary path (linux)
if: ${{ inputs.os == 'ubuntu-latest' }}
shell: bash
run: |
echo "VENV_ACTIVATE=venv/bin/activate" >> $GITHUB_ENV
- name: Set venv binary path (windows)
if: ${{ inputs.os == 'windows-latest' }}
shell: bash
run: |
echo "VENV_ACTIVATE=venv\Scripts\activate" >> $GITHUB_ENV
- name: log venv binary path
shell: bash
run: |
echo $VENV_ACTIVATE
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: ${{ inputs.python_version }}
cache: pip
cache-dependency-path: |
client/python/requirements.txt
Expand All @@ -43,24 +64,32 @@ runs:
with:
path: |
venv/*
client/python/venv
key: gradio-lib-ubuntu-latest-pip-${{ hashFiles('client/python/requirements.txt') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('test/requirements.txt') }}-${{ hashFiles('client/python/test/requirements.txt') }}
- name: Install Gradio and Client Libraries Locally (Linux)
shell: bash
run: |
. venv/bin/activate
python -m pip install -e client/python
python -m pip install -e .
. ${{ env.VENV_ACTIVATE }}
python -m pip install client/python
python -m pip install ".[oauth]"
- name: Install ffmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
- name: Install test dependencies
if: inputs.test == 'true'
shell: bash
run: |
. ${{ env.VENV_ACTIVATE }}
python -m pip install -r test/requirements.txt
python -m pip install -r client/python/test/requirements.txt
- name: install-frontend
uses: "./.github/actions/install-frontend-deps"
with:
always-install-pnpm: ${{ inputs.always-install-pnpm }}
always_install_pnpm: ${{ inputs.always_install_pnpm }}
node_auth_token: ${{ inputs.node_auth_token }}
npm_token: ${{ inputs.npm_token }}
skip_build: ${{ inputs.skip_build }}
- name: generate json
shell: bash
run: |
. venv/bin/activate
. ${{ env.VENV_ACTIVATE }}
python js/_website/generate_jsons/generate.py
14 changes: 7 additions & 7 deletions .github/actions/install-frontend-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'install frontend'
description: 'Install frontend deps'

inputs:
always-install-pnpm:
always_install_pnpm:
description: 'Dictates whether or not we should install pnpm & dependencies, regardless of the cache'
default: 'false'
node_auth_token:
Expand All @@ -14,6 +14,9 @@ inputs:
skip_build:
description: 'Skip build'
default: 'false'
os:
description: 'OS'
default: 'ubuntu-latest'

runs:
using: "composite"
Expand All @@ -25,7 +28,7 @@ runs:
gradio/templates/*
key: gradio-lib-front-end-${{ hashFiles('js/**', 'client/js/**')}}
- name: Install pnpm
if: steps.frontend-cache.outputs.cache-hit != 'true' || inputs.always-install-pnpm == 'true'
if: steps.frontend-cache.outputs.cache-hit != 'true' || inputs.always_install_pnpm == 'true'
uses: pnpm/action-setup@v2
with:
version: 8.9
Expand All @@ -34,15 +37,12 @@ runs:
node-version: 18
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
env:
NODE_AUTH_TOKEN: ${{ inputs.always-install-pnpm }}
NPM_TOKEN: ${{ inputs.always-install-pnpm }}
- name: Install deps
if: steps.frontend-cache.outputs.cache-hit != 'true' || inputs.always-install-pnpm == 'true'
if: steps.frontend-cache.outputs.cache-hit != 'true' || inputs.always_install_pnpm == 'true'
shell: bash
run: pnpm i --frozen-lockfile --ignore-scripts
- name: Build Css
if: inputs.always-install-pnpm == 'true'
if: inputs.always_install_pnpm == 'true'
shell: bash
run: pnpm css
- name: Build frontend
Expand Down
Loading

0 comments on commit d523288

Please sign in to comment.