This repository has been archived by the owner on Sep 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Reorganize GitHub Actions workflows (#151)
Backported-From: master Backported-To: 20.03
- Loading branch information
Showing
6 changed files
with
145 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/* |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
6 changes: 2 additions & 4 deletions
6
.github/workflows/lint-towncrier.yml → .github/workflows/timeline-check.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Reorganize and update GitHub Actions workflow for better CI/CD |