Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #861 from aio-libs/windows-ci
Browse files Browse the repository at this point in the history
Add Windows to GitHub Action CI
  • Loading branch information
seandstewart committed Dec 18, 2020
2 parents 1a0d93a + b471f71 commit 38e60f0
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 52 deletions.
29 changes: 0 additions & 29 deletions .appveyor.yml

This file was deleted.

99 changes: 80 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,41 @@ jobs:
run: |
twine check dist/*
test:
name: Test
test-unix:
name: Test Unix
needs: lint
strategy:
matrix:
os: [ubuntu-latest]
pyver: [3.6, 3.7, 3.8, 3.9, pypy3]
uvloop: ['no-uvloop']
include:
- pyver: 3.6
uvloop: 'uvloop'
- pyver: 3.8
uvloop: 'uvloop'
uvloop: [uvloop, no-uvloop]
exclude:
- pyver: pypy3
uvloop: uvloop
os: ubuntu-latest
fail-fast: false
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
timeout-minutes: 15
env:
OS: ${{ matrix.os }}
INSTALL_DIR: ${{ github.workspace }}/redis
PYTEST_ADDOPTS: --${{ matrix.uvloop }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python ${{ matrix.pyver }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.pyver }}
- name: Cache Redis Server
- name: Cache Redis Server (${{ runner.os }})
uses: actions/cache@v2
with:
key: pip-ci-${{ runner.os }}-${{ hashFiles('**/requirements.txt', 'Makefile') }}
path: ${{ github.workspace }}/redis
restore-keys: |
pip-ci-${{ runner.os }}-
- name: Install Redis Server
- name: Install Redis Server (${{ runner.os }})
if: startsWith(runner.os, 'Linux')
run: |
sudo apt install socat
make ci-prune-old-redis
Expand All @@ -106,23 +109,81 @@ jobs:
- name: Install Self
run: |
pip install -e . -c tests/requirements.txt
- name: Run unittests (no-uvloop)
if: matrix.uvloop == 'no-uvloop'
- name: Run unittests (${{ matrix.uvloop }}, ${{ matrix.os }})
run: |
make ci-test
python -m coverage xml
- name: Run unittests (uvloop)
if: matrix.uvloop == 'uvloop'
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unit
env_vars: OS
fail_ci_if_error: false

test-windows:
name: Test Windows
needs: lint
strategy:
matrix:
os: [windows-latest]
pyver: [3.6, 3.7, 3.8, 3.9, pypy3]
uvloop: [no-uvloop]
fail-fast: false
runs-on: ${{ matrix.os }}
continue-on-error: true
timeout-minutes: 15
env:
OS: ${{ matrix.os }}
INSTALL_DIR: ${{ github.workspace }}/redis
PYTEST_ADDOPTS: --${{ matrix.uvloop }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python ${{ matrix.pyver }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.pyver }}
- name: Cache Redis server
uses: actions/cache@v2
if: ${{ startsWith(runner.os, 'Windows') }}
with:
key: pip-ci-${{ runner.os }}-${{ hashFiles('**/requirements.txt') }}
path: ${{ github.workspace }}\redis
restore-keys: |
pip-ci-${{ runner.os }}-
- name: Install Redis Server
run: |
make ci-test
python -m coverage xml
env:
PYTEST_ADDOPTS: "--uvloop"
choco install redis-64 --version 3.0.503
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)" # - name: Cache
- name: Cache PyPI
uses: actions/cache@v2
with:
key: pip-ci-${{ runner.os }}-${{ matrix.pyver }}-${{ hashFiles('**/requirements.txt') }}
path: ${{ steps.pip-cache.outputs.dir }}
restore-keys: |
pip-ci-${{ runner.os }}-${{ matrix.pyver }}-
- name: Install dependencies
uses: py-actions/py-dependency-install@v2
with:
path: tests/requirements.txt
- name: Install Self (windows)
if: ${{ startsWith(runner.os, 'Windows') }}
run: |
pip install -e . -c tests\requirements.txt
- name: Run unittests
if: ${{ startsWith(runner.os, 'Windows') }}
run: |
python -m pytest -svv --cov --cov-report=xml --junitxml=coverage.xml --redis-server=C:\\ProgramData\\chocolatey\\lib\\redis-64\\redis-server.exe
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unit
env_vars: OS
fail_ci_if_error: false

# deploy:
Expand Down
50 changes: 46 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import argparse
import asyncio
import atexit
import contextlib
import functools
import inspect
import os
import socket
import ssl
Expand All @@ -14,7 +13,6 @@
from urllib.parse import urlencode, urlunparse

import pytest
from async_timeout import timeout as async_timeout

import aioredis
import aioredis.sentinel
Expand Down Expand Up @@ -211,6 +209,50 @@ def make(**kwargs):

# Internal stuff #

# Taken from python3.9
class BooleanOptionalAction(argparse.Action):
def __init__(
self,
option_strings,
dest,
default=None,
type=None,
choices=None,
required=False,
help=None,
metavar=None,
):

_option_strings = []
for option_string in option_strings:
_option_strings.append(option_string)

if option_string.startswith("--"):
option_string = "--no-" + option_string[2:]
_option_strings.append(option_string)

if help is not None and default is not None:
help += f" (default: {default})"

super().__init__(
option_strings=_option_strings,
dest=dest,
nargs=0,
default=default,
type=type,
choices=choices,
required=required,
help=help,
metavar=metavar,
)

def __call__(self, parser, namespace, values, option_string=None):
if option_string in self.option_strings:
setattr(namespace, self.dest, not option_string.startswith("--no-"))

def format_usage(self):
return " | ".join(self.option_strings)


def pytest_addoption(parser):
parser.addoption(
Expand All @@ -233,7 +275,7 @@ def pytest_addoption(parser):
"--ssl-cert", default="tests/ssl/cert.pem", help="Path to testing SSL CERT file"
)
parser.addoption(
"--uvloop", default=False, action="store_true", help="Run tests with uvloop"
"--uvloop", action=BooleanOptionalAction, help="Run tests with uvloop"
)


Expand Down

1 comment on commit 38e60f0

@Andrew-Chen-Wang
Copy link
Collaborator

@Andrew-Chen-Wang Andrew-Chen-Wang commented on 38e60f0 Dec 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a comment in this commit. There was a regression in setup/python job in that pypy was erroring "IS_WINDOWS is not defined." I've re run the jobs so that it reflects the merge from actions/setup-python#171. The release came 15 minutes ago.

Please sign in to comment.