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

Commit b761d1d

Browse files
authored
ci: Reorganize GitHub Actions workflows (#151)
1 parent d481b19 commit b761d1d

File tree

6 files changed

+145
-127
lines changed

6 files changed

+145
-127
lines changed

.github/workflows/default.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: default
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
7+
lint:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: [3.7, 3.8]
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
- name: Cache pip packages
19+
uses: actions/cache@v2
20+
with:
21+
path: ~/.cache/pip
22+
key: lint-flake8-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
23+
restore-keys: |
24+
lint-flake8-${{ runner.os }}-pip-${{ matrix.python-version }}
25+
lint-flake8-${{ runner.os }}-pip-
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install -U pip setuptools
29+
python -m pip install -U -r requirements/lint.txt
30+
- name: Lint with flake8
31+
run: |
32+
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
33+
echo "(skipping matchers for pull request from local branches)"
34+
else
35+
echo "::add-matcher::.github/workflows/flake8-matcher.json"
36+
fi
37+
python -m flake8 src/ai/backend tests
38+
39+
typecheck:
40+
runs-on: ubuntu-latest
41+
strategy:
42+
matrix:
43+
python-version: [3.8]
44+
steps:
45+
- uses: actions/checkout@v2
46+
- name: Set up Python ${{ matrix.python-version }}
47+
uses: actions/setup-python@v2
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
- name: Cache pip packages
51+
uses: actions/cache@v2
52+
with:
53+
path: ~/.cache/pip
54+
key: typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
55+
restore-keys: |
56+
typecheck-mypy-${{ runner.os }}-pip-${{ matrix.python-version }}
57+
typecheck-mypy-${{ runner.os }}-pip-
58+
- name: Install dependencies
59+
run: |
60+
python -m pip install -U pip setuptools
61+
python -m pip install -U -r requirements/typecheck.txt
62+
- name: Type check with mypy
63+
run: |
64+
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
65+
echo "(skipping matchers for pull request from local branches)"
66+
else
67+
echo "::add-matcher::.github/workflows/mypy-matcher.json"
68+
fi
69+
python -m mypy --no-color-output src/ai/backend
70+
71+
test:
72+
runs-on: ${{ matrix.os }}
73+
strategy:
74+
matrix:
75+
os: [ubuntu-latest, macos-latest, windows-latest]
76+
python-version: [3.7, 3.8]
77+
steps:
78+
- uses: actions/checkout@v2
79+
- name: Set up Python ${{ matrix.python-version }}
80+
uses: actions/setup-python@v2
81+
with:
82+
python-version: ${{ matrix.python-version }}
83+
- name: Cache pip packages
84+
uses: actions/cache@v2
85+
with:
86+
path: ~/.cache/pip
87+
key: test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
88+
restore-keys: |
89+
test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}
90+
test-pytest-${{ runner.os }}-pip-
91+
- name: Install dependencies
92+
run: |
93+
python -m pip install -U pip setuptools
94+
python -m pip install -U -r requirements/test.txt
95+
python <<EOF
96+
# temporary patch until pnuckowski/aioresponses#174 is released or aiohttp is patched.
97+
from pathlib import Path
98+
import aioresponses
99+
p = (Path(aioresponses.__file__).parent / "compat.py")
100+
print(">>> Patching aioresponses #174 manually")
101+
t = p.read_text()
102+
t = t.replace("return StreamReader(protocol, loop=loop)", "return StreamReader(protocol, limit=2 ** 16, loop=loop)")
103+
p.write_text(t)
104+
EOF
105+
shell: bash
106+
- name: Test with pytest
107+
run: |
108+
python -m pytest -v --cov=src -m 'not integration' tests
109+
- name: Send code coverage report
110+
uses: codecov/codecov-action@v1
111+
112+
deploy-to-pypi:
113+
needs: [lint, typecheck, test]
114+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
115+
runs-on: ubuntu-latest
116+
steps:
117+
- uses: actions/checkout@v2
118+
- name: Set up Python 3.8
119+
uses: actions/setup-python@v2
120+
with:
121+
python-version: 3.8
122+
- name: Cache pip packages
123+
uses: actions/cache@v2
124+
with:
125+
path: ~/.cache/pip
126+
key: test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
127+
restore-keys: |
128+
test-pytest-${{ runner.os }}-pip-${{ matrix.python-version }}
129+
test-pytest-${{ runner.os }}-pip-
130+
- name: Install dependencies
131+
env:
132+
REQUIREMENTS_FILE: build
133+
run: |
134+
python -m pip install -U pip setuptools
135+
python -m pip install -U -r requirements/build.txt
136+
- name: Build and publish
137+
env:
138+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
139+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
140+
run: |
141+
python setup.py sdist bdist_wheel
142+
twine upload dist/*

.github/workflows/lint-flake8.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/test-pytest.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/lint-towncrier.yml renamed to .github/workflows/timeline-check.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
name: Check existence of news fragment
1+
name: timeline-check
22

33
on: [pull_request]
44

55
jobs:
6-
lint-towncrier:
7-
6+
towncrier:
87
runs-on: ubuntu-latest
9-
108
steps:
119
- uses: actions/checkout@v2
1210
with:

.github/workflows/typecheck-mypy.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

changes/151.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reorganize and update GitHub Actions workflow for better CI/CD

0 commit comments

Comments
 (0)