Skip to content

Commit

Permalink
chore(tests): cache network requests (#2551)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-alisafaee committed Jan 12, 2022
1 parent 7e8199f commit 1e33c65
Show file tree
Hide file tree
Showing 9 changed files with 456 additions and 48 deletions.
98 changes: 59 additions & 39 deletions .github/workflows/test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
tags:
- "v*.*.*"
env:
CACHE_PREFIX: "v2"
DEPENDENCY_CACHE_PREFIX: "v2"
NETWORK_CACHE_PREFIX: "v1"
jobs:
set-matrix:
runs-on: ubuntu-latest
Expand All @@ -26,6 +27,7 @@ jobs:
else
echo "::set-output name=matrix::{\"python-version\": [\"3.7\"]}"
fi
cleanup-runs:
runs-on: ubuntu-latest
steps:
Expand All @@ -34,6 +36,14 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "!startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, github.event.repository.default_branch)"

year-week:
runs-on: ubuntu-latest
outputs:
date: ${{ steps.year-week.outputs.date }}
steps:
- id: year-week
run: echo "::set-output name=date::$(date '+%Y-%V')"

style-check:
runs-on: ubuntu-latest
steps:
Expand All @@ -44,21 +54,21 @@ jobs:
with:
python-version: "3.8"
- uses: actions/cache@master
id: cache
id: dependency-cache
with:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{env.CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
python -m pip install coveralls poetry wheel twine
make download-templates
python -m pip install .[all]
- name: Install renku into cache
if: steps.cache.outputs.cache-hit == 'true'
if: steps.dependency-cache.outputs.cache-hit == 'true'
run: python -m pip install --no-deps .
- name: Set Git config
run: |
Expand All @@ -83,21 +93,21 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@master
id: cache
id: dependency-cache
with:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{env.CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
python -m pip install coveralls poetry wheel twine
make download-templates
python -m pip install .[all]
- name: Install renku into cache
if: steps.cache.outputs.cache-hit == 'true'
if: steps.dependency-cache.outputs.cache-hit == 'true'
run: python -m pip install --no-deps .
- name: Set Git config
run: |
Expand Down Expand Up @@ -183,21 +193,21 @@ jobs:
with:
python-version: "3.7"
- uses: actions/cache@master
id: cache
id: dependency-cache
with:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{env.CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
python -m pip install coveralls poetry wheel twine
make download-templates
pip install .[all]
- name: Install renku into cache
if: steps.cache.outputs.cache-hit == 'true'
if: steps.dependency-cache.outputs.cache-hit == 'true'
run: python -m pip install --no-deps .
- name: Build Package
env:
Expand Down Expand Up @@ -226,21 +236,21 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y libyaml-0-2 libyaml-dev
- uses: actions/cache@master
id: cache
id: dependency-cache
with:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{env.CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
python -m pip install coveralls poetry wheel twine
make download-templates
python -m pip install .[all]
- name: Install renku into cache
if: steps.cache.outputs.cache-hit == 'true'
if: steps.dependency-cache.outputs.cache-hit == 'true'
run: python -m pip install --no-deps .
- name: Set Git config
run: |
Expand Down Expand Up @@ -281,21 +291,21 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y libyaml-0-2 libyaml-dev
- uses: actions/cache@master
id: cache
id: dependency-cache
with:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{env.CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
python -m pip install coveralls poetry wheel twine
make download-templates
python -m pip install .[all]
- name: Install renku into cache
if: steps.cache.outputs.cache-hit == 'true'
if: steps.dependency-cache.outputs.cache-hit == 'true'
run: python -m pip install --no-deps .
- name: Set Git config
run: |
Expand Down Expand Up @@ -342,21 +352,21 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y libyaml-0-2 libyaml-dev
- uses: actions/cache@master
id: cache
id: dependency-cache
with:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{env.CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
python -m pip install coveralls poetry wheel twine
make download-templates
python -m pip install .[all]
- name: Install renku into cache
if: steps.cache.outputs.cache-hit == 'true'
if: steps.dependency-cache.outputs.cache-hit == 'true'
run: python -m pip install --no-deps .
- name: Set Git config
run: |
Expand Down Expand Up @@ -403,21 +413,21 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y libyaml-0-2 libyaml-dev
- uses: actions/cache@master
id: cache
id: dependency-cache
with:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{env.CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
python -m pip install coveralls poetry wheel twine
make download-templates
python -m pip install .[all]
- name: Install renku into cache
if: steps.cache.outputs.cache-hit == 'true'
if: steps.dependency-cache.outputs.cache-hit == 'true'
run: python -m pip install --no-deps .
- name: Set Git config
run: |
Expand Down Expand Up @@ -593,7 +603,7 @@ jobs:

test-linux-integration:
runs-on: ubuntu-latest
needs: [set-matrix]
needs: [set-matrix, year-week]
strategy:
max-parallel: 3
matrix: ${{fromJson(needs.set-matrix.outputs.matrix)}}
Expand All @@ -611,26 +621,31 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y libyaml-0-2 libyaml-dev
- uses: actions/cache@master
id: cache
id: dependency-cache
with:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{env.CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
python -m pip install coveralls poetry wheel twine
make download-templates
python -m pip install .[all]
- name: Install renku into cache
if: steps.cache.outputs.cache-hit == 'true'
if: steps.dependency-cache.outputs.cache-hit == 'true'
run: python -m pip install --no-deps .
- name: Set Git config
run: |
git config --global --add user.name "Renku @ SDSC"
git config --global --add user.email "renku@datascience.ch"
- uses: actions/cache@master
id: network-cache
with:
path: cassettes
key: ${{ env.NETWORK_CACHE_PREFIX }}-${{ needs.year-week.outputs.date }}-${{ hashFiles('tests') }}-${{ github.job }}
- name: Test with pytest
env:
POETRY_VIRTUALENVS_CREATE: false
Expand Down Expand Up @@ -664,7 +679,7 @@ jobs:

test-linux-integration-service:
runs-on: ubuntu-latest
needs: [set-matrix]
needs: [set-matrix, year-week]
strategy:
max-parallel: 3
matrix: ${{fromJson(needs.set-matrix.outputs.matrix)}}
Expand All @@ -682,26 +697,31 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y libyaml-0-2 libyaml-dev
- uses: actions/cache@master
id: cache
id: dependency-cache
with:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{env.CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
python -m pip install coveralls poetry wheel twine
make download-templates
python -m pip install .[all]
- name: Install renku into cache
if: steps.cache.outputs.cache-hit == 'true'
if: steps.dependency-cache.outputs.cache-hit == 'true'
run: python -m pip install --no-deps .
- name: Set Git config
run: |
git config --global --add user.name "Renku @ SDSC"
git config --global --add user.email "renku@datascience.ch"
- uses: actions/cache@master
id: network-cache
with:
path: cassettes
key: ${{ env.NETWORK_CACHE_PREFIX }}-${{ needs.year-week.outputs.date }}-${{ hashFiles('tests') }}-${{ github.job }}
- name: Test with pytest
env:
POETRY_VIRTUALENVS_CREATE: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- renku/core/commands/providers/*.py

jobs:
test-linux-integration:
test-linux-integration-publish:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
OLOS_ACCESS_TOKEN: ${{ secrets.OLOS_ACCESS_TOKEN }}
run: pytest -m publish -v

test-macos-integration:
test-macos-integration-publish:
runs-on: macos-latest
strategy:
max-parallel: 4
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ helm-chart/renku-core/charts
renku/templates/
temp/
tmp/

# pytest-recording cache
cassettes

0 comments on commit 1e33c65

Please sign in to comment.