Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pip cache for GitHub Actions #6923

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/actions/pyenv/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: pyenv
description: Setup python and install required dependencies to venv with cache
inputs:
python-version:
default: '3.8'
description: 'Python version'
required: false

requirements:
default: 'requirements.txt'
description: 'The path to requirements.txt file'
required: false

outputs:
virtualenv-directory:
description: 'The path to the restored or created virtualenv'
value: ${{steps.cache-virtualenv.outputs.virtualenv-directory}}

runs:
using: 'composite'
steps:
- uses: actions/setup-python@v3
with:
python-version: ${{inputs.python-version}}

- name: Restore virtual env
uses: syphar/restore-virtualenv@v1
id: cache-virtualenv
with:
requirement_files: ${{inputs.requirements}}

- name: Install pip dependencies
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r ${{inputs.requirements}}
1 change: 0 additions & 1 deletion .github/workflows/!PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ jobs:
upload: false
os: ubuntu-20.04
python-version: 3.8

6 changes: 5 additions & 1 deletion .github/workflows/build_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ jobs:
fetch-depth: 0
ref: ${{github.event.pull_request.head.sha}}

- uses: actions/setup-python@v3
- name: Create python environment
id: pyenv
uses: ./.github/actions/pyenv
with:
python-version: ${{inputs.python-version}}
requirements: requirements-build.txt

- name: Save Git info
run: |
Expand All @@ -51,6 +54,7 @@ jobs:
QT_QPA_PLATFORM: offscreen
QT_ACCESSIBILITY: 1
QT_IM_MODULE: ibus
VENV: ${{steps.pyenv.outputs.virtualenv-directory}}
run: |
./build/debian/makedist_debian.sh

Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3

- name: Create python environment
uses: ./.github/actions/pyenv
with:
python-version: ${{inputs.python-version}}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./requirements-test.txt
requirements: requirements-test.txt

- name: Run Pytest with Coverage
run: |
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
- name: Create python environment
uses: ./.github/actions/pyenv
with:
python-version: ${{inputs.python-version}}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./doc/requirements.txt
requirements: ./doc/requirements.txt

- name: Build documentation
run: |
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/guitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
- name: Create python environment
uses: ./.github/actions/pyenv
with:
python-version: ${{inputs.python-version}}

- name: Install pip dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./requirements-test.txt
requirements: requirements-test.txt

- name: Install xvfb dependencies
run: |
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
- name: Create python environment
uses: ./.github/actions/pyenv
with:
python-version: ${{inputs.python-version}}
requirements: requirements-test.txt

- name: Install Libsodium (win)
if: matrix.os == 'windows-latest'
Expand All @@ -36,11 +38,6 @@ jobs:
7z x libsodium-1.0.17-msvc.zip
copy ./x64/Release/v141/dynamic/libsodium.dll C:\Windows\system32\

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./requirements-test.txt

- name: Run Pytest
run: |
pytest ./src/tribler/core ${{matrix.pytest-arguments}}
Expand Down