Add Windows CI (#3628)

* Add Windows CI

* Update changelog

* fix

* Skip one test on Windows

* Preserve virtualenv path

* Skip another test on Windows

* Make conditional flaky

* Requested changes

* consistent os

* cleanup

* fix test for windows

* remove unnecessary check

* lint

* lint

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
space-nuko 2023-03-27 13:55:59 -05:00 committed by GitHub
parent 108a66bbd1
commit e6ea19dee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 33 deletions

View File

@ -15,12 +15,13 @@ env:
jobs:
test:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.test-type == 'flaky' }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
test-type: ["not flaky", "flaky"]
python-version: ["3.9", "3.7"]
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.test-type == 'flaky' }}
steps:
- uses: actions/checkout@v3
- name: Cache python deps
@ -44,31 +45,43 @@ jobs:
cache-dependency-path: ui/pnpm-lock.yaml
- name: Install pip
run: python -m pip install build requests virtualenv
- name: Install Gradio
- name: venv activate Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
python -m virtualenv venv
. venv/bin/activate
source venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: venv activate Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
python -m virtualenv venv
./venv/Scripts/Activate.ps1
echo "PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install Gradio
shell: bash
run: |
bash scripts/install_gradio.sh
pip install --upgrade pip
- name: Install 3.9 Test Dependencies
shell: bash
if: ${{ matrix.python-version == '3.9' }}
run: |
. venv/bin/activate
pip install -r test/requirements.txt
- name: Install 3.7 Test Dependencies
shell: bash
if: ${{ matrix.python-version == '3.7' }}
run: |
. venv/bin/activate
pip install -r test/requirements-37.txt
- name: Lint
shell: bash
run: |
. venv/bin/activate
bash scripts/lint_backend.sh
- name: Typecheck
shell: bash
run: |
. venv/bin/activate
bash scripts/type_check_backend.sh
- name: Build frontend
shell: bash
run: |
cd ui
pnpm i --frozen-lockfile
@ -79,8 +92,8 @@ jobs:
- name: Create coverage dir
run: mkdir test-reports
- name: Run tests
shell: bash
run: |
. venv/bin/activate
coverage run -m pytest -m "${{ matrix.test-type }}"
coverage xml

View File

@ -26,6 +26,7 @@
## Testing and Infrastructure Changes:
- Removed heavily-mocked tests related to comet_ml, wandb, and mlflow as they added a significant amount of test dependencies that prevented installation of test dependencies on Windows environemnts. By [@abidlabs](https://github.com/abidlabs) in [PR 3608](https://github.com/gradio-app/gradio/pull/3608)
- Added Windows continuous integration, by [@space-nuko](https://github.com/space-nuko) in [PR 3628](https://github.com/gradio-app/gradio/pull/3628)
## Breaking Changes:

View File

@ -1442,7 +1442,7 @@ async def test_queue_when_using_auth():
await ws.recv()
assert e.type == websockets.InvalidStatusCode
async def run_ws(_loop, _time, i):
async def run_ws(i):
async with websockets.connect(
f"{demo.local_url.replace('http', 'ws')}queue/join",
extra_headers={"Cookie": f"access-token={token}"},
@ -1471,15 +1471,9 @@ async def test_queue_when_using_auth():
if msg["msg"] == "process_completed":
assert msg["success"]
assert msg["output"]["data"] == [f"Hello {i}!"]
assert _loop.time() > _time
break
loop = asyncio.get_event_loop()
tm = loop.time()
group = asyncio.gather(
*[run_ws(loop, tm + sleep_time * (i + 1) - 1, i) for i in range(3)]
)
await group
await asyncio.gather(*[run_ws(i) for i in range(3)])
def test_temp_file_sets_get_extended():

View File

@ -105,22 +105,17 @@ class TestHuggingFaceDatasetJSONSaver:
class TestDisableFlagging:
def test_flagging_no_permission_error_with_flagging_disabled(self):
with tempfile.TemporaryDirectory() as tmpdirname:
os.chmod(tmpdirname, 0o444) # Make directory read-only
nonwritable_path = os.path.join(tmpdirname, "flagging_dir")
io = gr.Interface(
lambda x: x,
"text",
"text",
allow_flagging="never",
flagging_dir=nonwritable_path,
)
try:
io.launch(prevent_thread_lock=True)
except PermissionError:
self.fail("launch() raised a PermissionError unexpectedly")
tmpdirname = tempfile.mkdtemp()
os.chmod(tmpdirname, 0o444) # Make directory read-only
nonwritable_path = os.path.join(tmpdirname, "flagging_dir")
io = gr.Interface(
lambda x: x,
"text",
"text",
allow_flagging="never",
flagging_dir=nonwritable_path,
)
io.launch(prevent_thread_lock=True)
io.close()