try speeding up ci using caching and rearranging jobs (#3974)

* try speeding up ci using caching and rearranging jobs

* fix job references

* cache lint and docs install

* tweak caching

* tweak caching to avoid conflicts

* correct use of runner.os

* bump

* stop skipping steps depending on cache

* prevent hypothesis flakeyness

* try skipping install steps again

* remove skipping install :-(
This commit is contained in:
Samuel Colvin
2022-05-14 15:32:53 +01:00
committed by GitHub
parent b246bc6859
commit 9baec86270
3 changed files with 81 additions and 40 deletions
+79 -38
View File
@@ -20,7 +20,20 @@ jobs:
with:
python-version: 3.9
- uses: actions/cache@v3
id: cache
with:
path: |
${{ env.pythonLocation }}
.mypy_cache
key: >
lint
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('tests/requirements-linting.txt') }}
- name: install
if: steps.cache.outputs.cache-hit != 'true'
run: |
make install-linting
pip freeze
@@ -54,9 +67,22 @@ jobs:
- name: set up python
uses: actions/setup-python@v3
with:
python-version: 3.8
python-version: 3.9
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
docs-build
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('docs/requirements.txt') }}
- name: install
if: steps.cache.outputs.cache-hit != 'true'
run: make install-docs
- name: build site
@@ -68,8 +94,8 @@ jobs:
name: docs
path: site
test-linux:
name: test py${{ matrix.python-version }} on linux
test-linux-compiled:
name: test py${{ matrix.python-version }} on linux compiled
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -87,10 +113,20 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
test-linux-compiled
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('tests/requirements-testing.txt') }}
- name: install
run: |
make install-testing
pip freeze
run: make install-testing
- name: compile
run: |
@@ -101,32 +137,11 @@ jobs:
- run: mkdir coverage
- name: test compiled and deps
- name: test
run: make test
env:
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-cY-dY
CONTEXT: linux-py${{ matrix.python-version }}-compiled-yes-deps-yes
- name: uninstall deps
run: pip uninstall -y cython email-validator devtools python-dotenv
- name: test compiled without deps
run: make test
env:
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-cY-dN
CONTEXT: linux-py${{ matrix.python-version }}-compiled-yes-deps-no
- name: remove compiled binaries
run: |
rm -r pydantic/*.so pydantic/*.c pydantic/__pycache__
ls -alh
ls -alh pydantic/
- name: test uncompiled without deps
run: make test
env:
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-cN-dN
CONTEXT: linux-py${{ matrix.python-version }}-compiled-no-deps-no
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-compiled
CONTEXT: linux-py${{ matrix.python-version }}-compiled
- name: store coverage files
uses: actions/upload-artifact@v3
@@ -134,13 +149,16 @@ jobs:
name: coverage
path: coverage
test-windows-mac:
test-not-compiled:
name: test py${{ matrix.python-version }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos, windows]
os: [ubuntu, macos, windows]
python-version: ['3.7', '3.8', '3.9', '3.10']
include:
- os: ubuntu
env:
PYTHON: ${{ matrix.python-version }}
OS: ${{ matrix.os }}
@@ -156,16 +174,39 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
test-not-compiled
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('tests/requirements-testing.txt') }}
- name: install
run: make install-testing
- run: pip freeze
- run: mkdir coverage
- name: test
- name: test with deps
run: make test
env:
COVERAGE_FILE: coverage/.coverage.${{ matrix.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ matrix.os }}-py${{ matrix.python-version }}
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-with-deps
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-with-deps
- name: uninstall deps
run: pip uninstall -y cython email-validator devtools python-dotenv
- name: test without deps
run: make test
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-without-deps
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-without-deps
- name: store coverage files
uses: actions/upload-artifact@v3
@@ -215,7 +256,7 @@ jobs:
path: coverage
coverage-combine:
needs: [test-linux, test-windows-mac, test-old-mypy]
needs: [test-linux-compiled, test-not-compiled, test-old-mypy]
runs-on: ubuntu-latest
steps:
@@ -233,7 +274,7 @@ jobs:
- run: pip install coverage
- run: ls -la
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --show-contexts
@@ -263,7 +304,7 @@ jobs:
build:
name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
needs: [lint, test-linux, test-windows-mac, test-old-mypy, test-fastapi]
needs: [lint, test-linux-compiled, test-not-compiled, test-old-mypy, test-fastapi]
if: "success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master')"
strategy:
fail-fast: false
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/setup-python@v3
with:
python-version: '3.8'
python-version: '3.9'
- run: pip install smokeshow