Make installing package dependencies a cached middle step to save time

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-12-14 19:49:34 +00:00 committed by Pedro Algarvio
parent 2e4314b30f
commit ae0b869c55
3 changed files with 192 additions and 20 deletions

View file

@ -0,0 +1,56 @@
---
name: build-linux-onedir
description: Build Linux Onedir Package
inputs:
platform:
required: true
type: string
description: The platform to build
arch:
required: true
type: string
description: The platform arch to build
package-name:
required: false
type: string
description: The onedir package name to create
default: salt
runs:
using: composite
steps:
- name: Download Cached Bare Onedir Package Directory
id: onedir-bare-cache
uses: actions/cache@v3
with:
path: artifacts/${{ inputs.package-name }}
key: relenv|${{ env.RELENV_VERSION }}|bare|${{ inputs.platform }}|${{ inputs.arch }}|${{ inputs.package-name }}|${{ hashFiles('.relenv/**/*.xz') }}
- name: Cache Deps Onedir Package Directory
id: onedir-pkg-cache
uses: actions/cache@v3
with:
path: artifacts/${{ inputs.package-name }}
key: relenv|${{ env.RELENV_VERSION }}|deps|${{ inputs.platform }}|${{ inputs.arch }}|${{ inputs.package-name }}|${{ hashFiles('.relenv/**/*.xz', 'requirements/static/pkg/*/*.txt') }}
- name: Cache Pip Wheels
uses: actions/cache@v3
with:
path: .pip-download-cache
key: pip-download-cache|${{ env.RELENV_VERSION }}|deps|${{ inputs.platform }}|${{ inputs.arch }}|${{ inputs.package-name }}|${{ hashFiles('.relenv/**/*.xz', 'requirements/static/pkg/*/*.txt') }}
- name: Install Salt Onedir Package Dependencies
env:
PIP_DOWNLOAD_CACHE: .pip-download-cache
PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
PIP_EXTRA_INDEX_URL: https://pypi.org/simple
shell: bash
run: |
python3 -c "import os; os.makedirs('.downloaded-dependencies', exist_ok=True)"
if [ "${{ inputs.platform }}" != "windows" ]; then
artifacts/${{ inputs.package-name }}/bin/python3 -m pip install -r requirements/static/pkg/py3.10/${{ inputs.platform }}.txt
else
artifacts/${{ inputs.package-name }}/Scripts/python -m pip install -r requirements/static/pkg/py3.10/${{ inputs.platform }}.txt
fi

View file

@ -21,38 +21,25 @@ runs:
steps:
- name: Download Cached Bare Onedir Package Directory
- name: Download Cached Deps Onedir Package Directory
id: onedir-bare-cache
uses: actions/cache@v3
with:
path: artifacts/${{ inputs.package-name }}
key: relenv|${{ env.RELENV_VERSION }}|bare|${{ inputs.platform }}|${{ inputs.arch }}|${{ inputs.package-name }}|${{ hashFiles('.relenv/**/*.xz') }}
key: relenv|${{ env.RELENV_VERSION }}|deps|${{ inputs.platform }}|${{ inputs.arch }}|${{ inputs.package-name }}|${{ hashFiles('.relenv/**/*.xz', 'requirements/static/pkg/*/*.txt') }}
- name: Cache Pip Wheels
uses: actions/cache@v3
with:
path: .pip-download-cache
key: pip-download-cache|${{ env.RELENV_VERSION }}|salt|${{ inputs.platform }}|${{ inputs.arch }}|${{ inputs.package-name }}|${{ hashFiles('.relenv/**/*.xz', 'requirements/static/pkg/*/*.txt') }}
- name: Install Salt Onedir Package Dependencies
env:
PIP_DOWNLOAD_CACHE: .pip-download-cache
PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
PIP_EXTRA_INDEX_URL: https://pypi.org/simple
shell: bash
run: |
python3 -c "import os; os.makedirs('.downloaded-dependencies', exist_ok=True)"
if [ "${{ inputs.platform }}" != "windows" ]; then
artifacts/${{ inputs.package-name }}/bin/python3 -m pip install -r requirements/static/pkg/py3.10/${{ inputs.platform }}.txt
else
artifacts/${{ inputs.package-name }}/Scripts/python -m pip install -r requirements/static/pkg/py3.10/${{ inputs.platform }}.txt
fi
key: pip-download-cache|${{ env.RELENV_VERSION }}|deps|${{ inputs.platform }}|${{ inputs.arch }}|${{ inputs.package-name }}|${{ hashFiles('.relenv/**/*.xz', 'requirements/static/pkg/*/*.txt') }}
- name: Install Salt Into Onedir
env:
PIP_DOWNLOAD_CACHE: .pip-download-cache
PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
PIP_EXTRA_INDEX_URL: https://pypi.org/simple
USE_STATIC_REQUIREMENTS: "1"
shell: bash
run: |
if [ "${{ inputs.platform }}" != "windows" ]; then

View file

@ -283,12 +283,55 @@ jobs:
path: exitstatus
if-no-files-found: error
build-deps-linux:
name: Build Salt Onedir Dependencies Linux
if: ${{ fromJSON(needs.prepare-ci.outputs.jobs)['self-hosted-runners'] }}
needs:
- prepare-ci
- build-bare-linux
strategy:
fail-fast: false
matrix:
arch:
- x86_64
- aarch64
runs-on:
- self-hosted
- linux
- ${{ matrix.arch }}
steps:
- uses: actions/checkout@v3
- name: Setup Relenv
uses: ./.github/actions/setup-relenv
with:
platform: linux
arch: ${{ matrix.arch }}
- name: Install Salt Packaging Dependencies into Relenv Onedir
uses: ./.github/actions/build-onedir-deps
with:
platform: linux
arch: ${{ matrix.arch }}
- name: Set Exit Status
if: always()
run: |
python3 -c "import os; os.makedirs('exitstatus', exist_ok=True)"
echo "${{ job.status }}" > exitstatus/${{ github.job }}-linux-${{ matrix.arch }}
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error
build-salt-linux:
name: Build Salt Onedir Linux
if: ${{ fromJSON(needs.prepare-ci.outputs.jobs)['self-hosted-runners'] }}
needs:
- prepare-ci
- build-bare-linux
- build-deps-linux
strategy:
fail-fast: false
matrix:
@ -368,12 +411,55 @@ jobs:
path: exitstatus
if-no-files-found: error
build-deps-windows:
name: Build Salt Dependencies Onedir Windows
if: ${{ fromJSON(needs.prepare-ci.outputs.jobs)['github-hosted-runners'] }}
needs:
- prepare-ci
- build-bare-windows
strategy:
fail-fast: false
matrix:
arch:
- amd64
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Setup Relenv
uses: ./.github/actions/setup-relenv
with:
platform: windows
arch: ${{ matrix.arch }}
- name: Install Salt Packaging Dependencies into Relenv Onedir
uses: ./.github/actions/build-onedir-deps
with:
platform: windows
arch: ${{ matrix.arch }}
- name: Set Exit Status
if: always()
run: |
python3 -c "import os; os.makedirs('exitstatus', exist_ok=True)"
echo "${{ job.status }}" > exitstatus/${{ github.job }}-windows-${{ matrix.arch }}
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error
build-salt-windows:
name: Build Salt Onedir Windows
if: ${{ fromJSON(needs.prepare-ci.outputs.jobs)['github-hosted-runners'] }}
needs:
- prepare-ci
- build-bare-windows
- build-deps-windows
strategy:
fail-fast: false
matrix:
@ -453,12 +539,55 @@ jobs:
path: exitstatus
if-no-files-found: error
build-deps-macos:
name: Build Salt Dependencies Onedir macOS
if: ${{ fromJSON(needs.prepare-ci.outputs.jobs)['github-hosted-runners'] }}
needs:
- prepare-ci
- build-bare-macos
strategy:
fail-fast: false
matrix:
arch:
- x86_64
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Setup Relenv
uses: ./.github/actions/setup-relenv
with:
platform: darwin
arch: ${{ matrix.arch }}
- name: Install Salt Packaging Dependencies into Relenv Onedir
uses: ./.github/actions/build-onedir-deps
with:
platform: darwin
arch: ${{ matrix.arch }}
- name: Set Exit Status
if: always()
run: |
python3 -c "import os; os.makedirs('exitstatus', exist_ok=True)"
echo "${{ job.status }}" > exitstatus/${{ github.job }}-macos-${{ matrix.arch }}
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error
build-salt-macos:
name: Build Salt Onedir macOS
if: ${{ fromJSON(needs.prepare-ci.outputs.jobs)['github-hosted-runners'] }}
needs:
- prepare-ci
- build-bare-macos
- build-deps-macos
strategy:
fail-fast: false
matrix: