mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Fix python venv restoring (#4965)
* Fix python venv restoring * Add shell * Fix indentation
This commit is contained in:
parent
41a618737b
commit
5a8b7c17da
2 changed files with 81 additions and 47 deletions
38
.github/actions/restore-python/action.yml
vendored
Normal file
38
.github/actions/restore-python/action.yml
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
name: Restore Python
|
||||||
|
inputs:
|
||||||
|
python-version:
|
||||||
|
description: Python version to restore
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
cache-key:
|
||||||
|
description: Cache key to use
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
outputs:
|
||||||
|
python-version:
|
||||||
|
description: Python version restored
|
||||||
|
value: ${{ steps.python.outputs.python-version }}
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Set up Python ${{ inputs.python-version }}
|
||||||
|
id: python
|
||||||
|
uses: actions/setup-python@v4.6.0
|
||||||
|
with:
|
||||||
|
python-version: ${{ inputs.python-version }}
|
||||||
|
- name: Restore Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache/restore@v3.3.1
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
# yamllint disable-line rule:line-length
|
||||||
|
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ inputs.cache-key }}
|
||||||
|
- name: Create Python virtual environment
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python -m venv venv
|
||||||
|
. venv/bin/activate
|
||||||
|
python --version
|
||||||
|
pip install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt
|
||||||
|
pip install -e .
|
90
.github/workflows/ci.yml
vendored
90
.github/workflows/ci.yml
vendored
|
@ -26,10 +26,16 @@ jobs:
|
||||||
common:
|
common:
|
||||||
name: Create common environment
|
name: Create common environment
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
cache-key: ${{ steps.cache-key.outputs.key }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
|
- name: Generate cache-key
|
||||||
|
id: cache-key
|
||||||
|
run: echo key="${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}" >> $GITHUB_OUTPUT
|
||||||
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
id: python
|
||||||
uses: actions/setup-python@v4.6.0
|
uses: actions/setup-python@v4.6.0
|
||||||
with:
|
with:
|
||||||
python-version: ${{ env.DEFAULT_PYTHON }}
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
@ -39,7 +45,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
path: venv
|
path: venv
|
||||||
# yamllint disable-line rule:line-length
|
# yamllint disable-line rule:line-length
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ steps.cache-key.outputs.key }}
|
||||||
- name: Create Python virtual environment
|
- name: Create Python virtual environment
|
||||||
if: steps.cache-venv.outputs.cache-hit != 'true'
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
|
@ -66,12 +72,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
- name: Restore Python virtual environment
|
- name: Restore Python
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: ./.github/actions/restore-python
|
||||||
with:
|
with:
|
||||||
path: venv
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
# yamllint disable-line rule:line-length
|
cache-key: ${{ needs.common.outputs.cache-key }}
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
||||||
- name: Run black
|
- name: Run black
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
|
@ -88,12 +93,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
- name: Restore Python virtual environment
|
- name: Restore Python
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: ./.github/actions/restore-python
|
||||||
with:
|
with:
|
||||||
path: venv
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
# yamllint disable-line rule:line-length
|
cache-key: ${{ needs.common.outputs.cache-key }}
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
||||||
- name: Run flake8
|
- name: Run flake8
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
|
@ -110,12 +114,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
- name: Restore Python virtual environment
|
- name: Restore Python
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: ./.github/actions/restore-python
|
||||||
with:
|
with:
|
||||||
path: venv
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
# yamllint disable-line rule:line-length
|
cache-key: ${{ needs.common.outputs.cache-key }}
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
||||||
- name: Run pylint
|
- name: Run pylint
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
|
@ -132,12 +135,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
- name: Restore Python virtual environment
|
- name: Restore Python
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: ./.github/actions/restore-python
|
||||||
with:
|
with:
|
||||||
path: venv
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
# yamllint disable-line rule:line-length
|
cache-key: ${{ needs.common.outputs.cache-key }}
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
||||||
- name: Run pyupgrade
|
- name: Run pyupgrade
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
|
@ -154,12 +156,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
- name: Restore Python virtual environment
|
- name: Restore Python
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: ./.github/actions/restore-python
|
||||||
with:
|
with:
|
||||||
path: venv
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
# yamllint disable-line rule:line-length
|
cache-key: ${{ needs.common.outputs.cache-key }}
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
||||||
- name: Register matcher
|
- name: Register matcher
|
||||||
run: echo "::add-matcher::.github/workflows/matchers/ci-custom.json"
|
run: echo "::add-matcher::.github/workflows/matchers/ci-custom.json"
|
||||||
- name: Run script/ci-custom
|
- name: Run script/ci-custom
|
||||||
|
@ -176,12 +177,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
- name: Restore Python virtual environment
|
- name: Restore Python
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: ./.github/actions/restore-python
|
||||||
with:
|
with:
|
||||||
path: venv
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
# yamllint disable-line rule:line-length
|
cache-key: ${{ needs.common.outputs.cache-key }}
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
||||||
- name: Register matcher
|
- name: Register matcher
|
||||||
run: echo "::add-matcher::.github/workflows/matchers/pytest.json"
|
run: echo "::add-matcher::.github/workflows/matchers/pytest.json"
|
||||||
- name: Run pytest
|
- name: Run pytest
|
||||||
|
@ -197,12 +197,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
- name: Restore Python virtual environment
|
- name: Restore Python
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: ./.github/actions/restore-python
|
||||||
with:
|
with:
|
||||||
path: venv
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
# yamllint disable-line rule:line-length
|
cache-key: ${{ needs.common.outputs.cache-key }}
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
||||||
- name: Install clang-format
|
- name: Install clang-format
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
|
@ -237,12 +236,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
- name: Restore Python virtual environment
|
- name: Restore Python
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: ./.github/actions/restore-python
|
||||||
with:
|
with:
|
||||||
path: venv
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
# yamllint disable-line rule:line-length
|
cache-key: ${{ needs.common.outputs.cache-key }}
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
||||||
- name: Cache platformio
|
- name: Cache platformio
|
||||||
uses: actions/cache@v3.3.1
|
uses: actions/cache@v3.3.1
|
||||||
with:
|
with:
|
||||||
|
@ -300,13 +298,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code from GitHub
|
- name: Check out code from GitHub
|
||||||
uses: actions/checkout@v3.5.2
|
uses: actions/checkout@v3.5.2
|
||||||
- name: Restore Python virtual environment
|
- name: Restore Python
|
||||||
uses: actions/cache/restore@v3.3.1
|
uses: ./.github/actions/restore-python
|
||||||
with:
|
with:
|
||||||
path: venv
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
# yamllint disable-line rule:line-length
|
cache-key: ${{ needs.common.outputs.cache-key }}
|
||||||
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-venv-${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}
|
|
||||||
# Use per check platformio cache because checks use different parts
|
|
||||||
- name: Cache platformio
|
- name: Cache platformio
|
||||||
uses: actions/cache@v3.3.1
|
uses: actions/cache@v3.3.1
|
||||||
with:
|
with:
|
||||||
|
|
Loading…
Reference in a new issue