Skip to content

Commit

Permalink
The setup-python-tools-scripts actions now takes care of all the ca…
Browse files Browse the repository at this point in the history
…ching

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch committed Nov 22, 2023
1 parent a34d223 commit e0f6bb5
Show file tree
Hide file tree
Showing 29 changed files with 234 additions and 213 deletions.
14 changes: 14 additions & 0 deletions .github/actions/get-python-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,33 @@ outputs:
value: ${{ steps.get-python-version.outputs.version }}
full-version:
value: ${{ steps.get-python-version.outputs.full-version }}
version-sha256sum:
value: ${{ steps.get-python-version.outputs.version-sha256sum }}


runs:
using: composite

steps:

- name: Install System Packages
if: ${{ runner.os == 'macOS' }}
shell: bash
run: |
brew install coreutils
- name: Get Python Version
id: get-python-version
shell: bash
run: |
echo "Python Binary: ${{ inputs.python-binary }}"
echo "binary=${{ inputs.python-binary }}" >> "$GITHUB_OUTPUT"
PY_VERSION=$(${{ inputs.python-binary }} -c "import sys; sys.stdout.write('{}.{}'.format(*sys.version_info))")
echo "PY_VERSION=$PY_VERSION"
echo "version=$PY_VERSION" >> "$GITHUB_OUTPUT"
PY_FULL_VERSION=$(${{ inputs.python-binary }} -c "import sys; sys.stdout.write('{}.{}.{}'.format(*sys.version_info))")
echo "PY_FULL_VERSION=$PY_FULL_VERSION"
echo "full-version=$PY_FULL_VERSION" >> "$GITHUB_OUTPUT"
VERSION_SHA256SUM=$(${{ inputs.python-binary }} --version --version | sha256sum | cut -d ' ' -f 1)
echo "VERSION_SHA256SUM=$VERSION_SHA256SUM"
echo "version-sha256sum=$VERSION_SHA256SUM" >> "$GITHUB_OUTPUT"
17 changes: 17 additions & 0 deletions .github/actions/setup-python-tools-scripts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ name: setup-python-tools-scripts
description: Setup 'python-tools-scripts'

inputs:
cache-prefix:
required: true
type: string
description: Seed used to invalidate caches
cache-suffix:
required: false
type: string
description: Seed used to invalidate caches
cwd:
type: string
description: The directory the salt checkout is located in
Expand All @@ -29,6 +37,15 @@ runs:
with:
python-binary: python3

- name: Restore Python Tools Virtualenvs Cache
uses: actions/cache@v3
with:
path: ${{ inputs.cwd }}/.tools-venvs
key: ${{ inputs.cache-prefix }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version-sha256sum }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}${{ inputs.cache-suffix && format('|{0}', inputs.cache-suffix) || '' }}
restore-keys: |
${{ inputs.cache-prefix }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version-sha256sum }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}${{ inputs.cache-suffix && format('|{0}', inputs.cache-suffix) || '' }}
${{ inputs.cache-prefix }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version-sha256sum }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}
- name: Install 'python-tools-scripts'
shell: bash
working-directory: ${{ inputs.cwd }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/build-deb-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
required: true
type: string
description: The backend to build the packages with
cache-prefix:
required: true
type: string
description: Seed used to invalidate caches

env:
COLUMNS: 190
Expand Down Expand Up @@ -75,6 +79,7 @@ jobs:
uses: ./.github/actions/setup-python-tools-scripts
with:
cwd: pkgs/checkout/
cache-prefix: ${{ inputs.cache-prefix }}

- name: Setup Salt Version
id: setup-salt-version
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
- name: Setup Python Tools Scripts
id: python-tools-scripts
uses: ./.github/actions/setup-python-tools-scripts
with:
cache-prefix: ${{ inputs.cache-seed }}

- name: Configure Git
if: ${{ startsWith(github.event.ref, 'refs/tags') == false }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/build-macos-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ on:
required: true
type: string
description: The backend to build the packages with
cache-prefix:
required: true
type: string
description: Seed used to invalidate caches

env:
COLUMNS: 190
Expand Down Expand Up @@ -81,6 +85,8 @@ jobs:

- name: Setup Python Tools Scripts
uses: ./.github/actions/setup-python-tools-scripts
with:
cache-prefix: ${{ inputs.cache-prefix }}

- name: Setup Salt Version
id: setup-salt-version
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/build-rpm-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
required: true
type: string
description: The backend to build the packages with
cache-prefix:
required: true
type: string
description: Seed used to invalidate caches

env:
COLUMNS: 190
Expand Down Expand Up @@ -64,6 +68,8 @@ jobs:

- name: Setup Python Tools Scripts
uses: ./.github/actions/setup-python-tools-scripts
with:
cache-prefix: ${{ inputs.cache-prefix }}

- name: Setup Salt Version
id: setup-salt-version
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/build-windows-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ on:
required: true
type: string
description: The backend to build the packages with
cache-prefix:
required: true
type: string
description: Seed used to invalidate caches

env:
COLUMNS: 190
Expand Down Expand Up @@ -92,6 +96,8 @@ jobs:

- name: Setup Python Tools Scripts
uses: ./.github/actions/setup-python-tools-scripts
with:
cache-prefix: ${{ inputs.cache-prefix }}

- name: Setup Salt Version
id: setup-salt-version
Expand Down
61 changes: 19 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,10 @@ jobs:
with:
python-version: "3.10"

- name: Get Python Version
id: get-python-version
uses: ./.github/actions/get-python-version
with:
python-binary: python3

- name: Restore Cached Python Tools Virtualenvs
uses: actions/cache@v3
with:
path: .tools-venvs
key: ${{ env.CACHE_SEED }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}

- name: Setup Python Tools Scripts
uses: ./.github/actions/setup-python-tools-scripts
with:
cache-prefix: ${{ env.CACHE_SEED }}

- name: Pretty Print The GH Actions Event
run:
Expand Down Expand Up @@ -286,23 +276,11 @@ jobs:
with:
python-version: "3.10"

- name: Get Python Version
id: get-python-version
uses: ./.github/actions/get-python-version
with:
python-binary: python3

- name: Restore Python Tools Virtualenvs Cache
uses: actions/cache@v3
with:
path: .tools-venvs
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog
restore-keys: |
${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog
${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}
- name: Setup Python Tools Scripts
uses: ./.github/actions/setup-python-tools-scripts
with:
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
cache-suffix: changelog

- name: Setup Salt Version
id: setup-salt-version
Expand Down Expand Up @@ -418,23 +396,11 @@ jobs:
with:
python-version: "3.10"

- name: Get Python Version
id: get-python-version
uses: ./.github/actions/get-python-version
with:
python-binary: python3

- name: Restore Python Tools Virtualenvs Cache
uses: actions/cache@v3
with:
path: .tools-venvs
key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build
restore-keys: |
${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build
${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}
- name: Setup Python Tools Scripts
uses: ./.github/actions/setup-python-tools-scripts
with:
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
cache-suffix: build

- name: Setup Salt Version
id: setup-salt-version
Expand Down Expand Up @@ -546,6 +512,7 @@ jobs:
uses: ./.github/workflows/build-rpm-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
relenv-version: "0.14.2"
python-version: "3.10.13"
source: "onedir"
Expand All @@ -559,6 +526,7 @@ jobs:
uses: ./.github/workflows/build-rpm-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
relenv-version: "0.14.2"
python-version: "3.10.13"
source: "src"
Expand All @@ -572,6 +540,7 @@ jobs:
uses: ./.github/workflows/build-deb-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
relenv-version: "0.14.2"
python-version: "3.10.13"
source: "onedir"
Expand All @@ -585,6 +554,7 @@ jobs:
uses: ./.github/workflows/build-deb-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
relenv-version: "0.14.2"
python-version: "3.10.13"
source: "src"
Expand All @@ -598,6 +568,7 @@ jobs:
uses: ./.github/workflows/build-windows-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
relenv-version: "0.14.2"
python-version: "3.10.13"
source: "onedir"
Expand All @@ -611,6 +582,7 @@ jobs:
uses: ./.github/workflows/build-windows-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
relenv-version: "0.14.2"
python-version: "3.10.13"
source: "src"
Expand All @@ -624,6 +596,7 @@ jobs:
uses: ./.github/workflows/build-macos-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
relenv-version: "0.14.2"
python-version: "3.10.13"
source: "onedir"
Expand All @@ -637,6 +610,7 @@ jobs:
uses: ./.github/workflows/build-macos-packages.yml
with:
salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}"
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
relenv-version: "0.14.2"
python-version: "3.10.13"
source: "src"
Expand Down Expand Up @@ -2765,6 +2739,9 @@ jobs:
- name: Setup Python Tools Scripts
id: python-tools-scripts
uses: ./.github/actions/setup-python-tools-scripts
with:
cache-prefix: ${{ needs.prepare-workflow.outputs.cache-seed }}
cache-suffix: coverage

- name: Install Nox
run: |
Expand Down
Loading

0 comments on commit e0f6bb5

Please sign in to comment.