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

Commit

Permalink
ci: Reorganize GitHub Actions workflows (#151)
Browse files Browse the repository at this point in the history
Backported-From: master
Backported-To: 20.03
  • Loading branch information
achimnol committed Dec 17, 2020
1 parent 6ef20e2 commit 4cb5487
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 127 deletions.
142 changes: 142 additions & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: default

on: [push, pull_request]

jobs:

lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: lint-flake8-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
restore-keys: |
lint-flake8-${{ runner.os }}-pip-${{ matrix.python-version }}
lint-flake8-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install -U -r requirements/lint.txt
- name: Lint with flake8
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/flake8-matcher.json"
fi
python -m flake8 src/ai/backend tests
typecheck:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
restore-keys: |
typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }}
typecheck-mypy-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install -U -r requirements/typecheck.txt
- name: Type check with mypy
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/mypy-matcher.json"
fi
python -m mypy --no-color-output src/ai/backend
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
restore-keys: |
test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}
test-pytest-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install -U -r requirements/test.txt
python <<EOF
# temporary patch until pnuckowski/aioresponses#174 is released or aiohttp is patched.
from pathlib import Path
import aioresponses
p = (Path(aioresponses.__file__).parent / "compat.py")
print(">>> Patching aioresponses #174 manually")
t = p.read_text()
t = t.replace("return StreamReader(protocol, loop=loop)", "return StreamReader(protocol, limit=2 ** 16, loop=loop)")
p.write_text(t)
EOF
shell: bash
- name: Test with pytest
run: |
python -m pytest -v --cov=src -m 'not integration' tests
- name: Send code coverage report
uses: codecov/codecov-action@v1

deploy-to-pypi:
needs: [lint, typecheck, test]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
restore-keys: |
test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}
test-pytest-${{ runner.os }}-pip-
- name: Install dependencies
env:
REQUIREMENTS_FILE: build
run: |
python -m pip install -U pip setuptools
python -m pip install -U -r requirements/build.txt
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
38 changes: 0 additions & 38 deletions .github/workflows/lint-flake8.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/test-pytest.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: Check existence of news fragment
name: timeline-check

on: [pull_request]

jobs:
lint-towncrier:

towncrier:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/typecheck-mypy.yml

This file was deleted.

1 change: 1 addition & 0 deletions changes/151.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reorganize and update GitHub Actions workflow for better CI/CD

0 comments on commit 4cb5487

Please sign in to comment.