From 5aa8028ff5b24a71ddf8661a45562e697a5889a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Tue, 13 Sep 2022 19:03:57 +0200 Subject: [PATCH] Use the same python version for all steps (#3864) --- .github/workflows/ci.yaml | 72 ++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4e8f8cf4b..fd36b0890 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,18 +17,17 @@ jobs: # This prevent upcoming jobs to do the same individually prepare: runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.10"] - name: Prepare Python ${{ matrix.python-version }} dependencies + outputs: + python-version: ${{ steps.python.outputs.python-version }} + name: Prepare Python dependencies steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python id: python uses: actions/setup-python@v4.2.0 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ env.DEFAULT_PYTHON }} - name: Restore Python virtual environment id: cache-venv uses: actions/cache@v3.0.8 @@ -65,18 +64,18 @@ jobs: steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python ${{ needs.prepare.outputs.python-version }} uses: actions/setup-python@v4.2.0 id: python with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version: ${{ needs.prepare.outputs.python-version }} - name: Restore Python virtual environment id: cache-venv uses: actions/cache@v3.0.8 with: path: venv key: | - ${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} + ${{ runner.os }}-venv-${{ needs.prepare.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} - name: Fail job if Python cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: | @@ -109,18 +108,18 @@ jobs: steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python ${{ needs.prepare.outputs.python-version }} uses: actions/setup-python@v4.2.0 id: python with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version: ${{ needs.prepare.outputs.python-version }} - name: Restore Python virtual environment id: cache-venv uses: actions/cache@v3.0.8 with: path: venv key: | - ${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} + ${{ runner.os }}-venv-${{ needs.prepare.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} - name: Fail job if Python cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: | @@ -153,18 +152,18 @@ jobs: steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python ${{ needs.prepare.outputs.python-version }} uses: actions/setup-python@v4.2.0 id: python with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version: ${{ needs.prepare.outputs.python-version }} - name: Restore Python virtual environment id: cache-venv uses: actions/cache@v3.0.8 with: path: venv key: | - ${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} + ${{ runner.os }}-venv-${{ needs.prepare.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} - name: Fail job if Python cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: | @@ -185,18 +184,18 @@ jobs: steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python ${{ needs.prepare.outputs.python-version }} uses: actions/setup-python@v4.2.0 id: python with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version: ${{ needs.prepare.outputs.python-version }} - name: Restore Python virtual environment id: cache-venv uses: actions/cache@v3.0.8 with: path: venv key: | - ${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} + ${{ runner.os }}-venv-${{ needs.prepare.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} - name: Fail job if Python cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: | @@ -226,18 +225,18 @@ jobs: steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python ${{ needs.prepare.outputs.python-version }} uses: actions/setup-python@v4.2.0 id: python with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version: ${{ needs.prepare.outputs.python-version }} - name: Restore Python virtual environment id: cache-venv uses: actions/cache@v3.0.8 with: path: venv key: | - ${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} + ${{ runner.os }}-venv-${{ needs.prepare.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} - name: Fail job if Python cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: | @@ -270,18 +269,18 @@ jobs: steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python ${{ needs.prepare.outputs.python-version }} uses: actions/setup-python@v4.2.0 id: python with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version: ${{ needs.prepare.outputs.python-version }} - name: Restore Python virtual environment id: cache-venv uses: actions/cache@v3.0.8 with: path: venv key: | - ${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} + ${{ runner.os }}-venv-${{ needs.prepare.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} - name: Fail job if Python cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: | @@ -302,18 +301,18 @@ jobs: steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python ${{ needs.prepare.outputs.python-version }} uses: actions/setup-python@v4.2.0 id: python with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version: ${{ needs.prepare.outputs.python-version }} - name: Restore Python virtual environment id: cache-venv uses: actions/cache@v3.0.8 with: path: venv key: | - ${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} + ${{ runner.os }}-venv-${{ needs.prepare.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} - name: Fail job if Python cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: | @@ -339,18 +338,15 @@ jobs: pytest: runs-on: ubuntu-latest needs: prepare - strategy: - matrix: - python-version: ["3.10"] - name: Run tests Python ${{ matrix.python-version }} + name: Run tests Python ${{ needs.prepare.outputs.python-version }} steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python ${{ needs.prepare.outputs.python-version }} uses: actions/setup-python@v4.2.0 id: python with: - python-version: ${{ matrix.python-version }} + python-version: ${{ needs.prepare.outputs.python-version }} - name: Install CAS tools uses: home-assistant/actions/helpers/cas@master with: @@ -361,7 +357,7 @@ jobs: with: path: venv key: | - ${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} + ${{ runner.os }}-venv-${{ needs.prepare.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} - name: Fail job if Python cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: | @@ -400,22 +396,22 @@ jobs: coverage: name: Process test coverage runs-on: ubuntu-latest - needs: pytest + needs: ["pytest", "prepare"] steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python ${{ needs.prepare.outputs.python-version }} uses: actions/setup-python@v4.2.0 id: python with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version: ${{ needs.prepare.outputs.python-version }} - name: Restore Python virtual environment id: cache-venv uses: actions/cache@v3.0.8 with: path: venv key: | - ${{ runner.os }}-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} + ${{ runner.os }}-venv-${{ needs.prepare.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_tests.txt') }} - name: Fail job if Python cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: |