Skip to content

Commit

Permalink
try speeding up ci using caching and rearranging jobs (#3974)
Browse files Browse the repository at this point in the history
* 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 :-(
  • Loading branch information
samuelcolvin committed May 14, 2022
1 parent b246bc6 commit 9baec86
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 40 deletions.
117 changes: 79 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -101,46 +137,28 @@ jobs:
- run: mkdir coverage

- name: test compiled and deps
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
- name: test
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
with:
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 }}
Expand All @@ -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.${{ 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.${{ matrix.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ matrix.os }}-py${{ matrix.python-version }}
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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-previews.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/setup-python@v3
with:
python-version: '3.8'
python-version: '3.9'

- run: pip install smokeshow

Expand Down
2 changes: 1 addition & 1 deletion tests/test_hypothesis_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class EmailsModel(pydantic.BaseModel):


@pytest.mark.parametrize('model', gen_models())
@settings(suppress_health_check={HealthCheck.too_slow})
@settings(suppress_health_check={HealthCheck.too_slow}, deadline=None)
@given(data=st.data())
def test_can_construct_models_with_all_fields(data, model):
# The value of this test is to confirm that Hypothesis knows how to provide
Expand Down

0 comments on commit 9baec86

Please sign in to comment.