Skip to content

Commit

Permalink
initial commit of s3 caching
Browse files Browse the repository at this point in the history
  • Loading branch information
felippeb committed Mar 15, 2024
1 parent 29a2fdb commit 8761927
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
5 changes: 1 addition & 4 deletions .github/actions/build-onedir-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,19 @@ inputs:
type: string
description: Seed used to invalidate caches


env:
COLUMNS: 190
PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
PIP_EXTRA_INDEX_URL: https://pypi.org/simple
RELENV_BUILDENV: 1


runs:
using: composite

steps:

- name: Cache Deps Onedir Package Directory
id: onedir-pkg-cache
uses: actions/cache@v3.3.1
uses: ./.github/actions/cache
with:
path: artifacts/${{ inputs.package-name }}
key: >
Expand Down
45 changes: 45 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: cache-decider
description: Decide which cache to use
inputs:
key:
required: false
type: string
description: The onedir package name to create
default: salt
path:
required: true
type: string
description: path to contents to cache

outputs:
cache-hit:
value: ${{ steps.s3-cache.outputs.cache-hit || steps.github-cache.outputs.cache-hit }}

runs:
using: composite

steps:
- name: Configure AWS Credentials to access cache bucket
if: ${{ env.USE_S3_CACHE == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2

- name: Cache Deps Onedir Package Directory
if: ${{ env.USE_S3_CACHE == 'true' }}
id: s3-cache
env:
RUNS_ON_S3_BUCKET_CACHE: "salt-project-test-salt-github-actions-s3-cache"
uses: runs-on/cache@v4
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}

- name: Cache Deps Onedir Package Directory
if: ${{ env.USE_S3_CACHE != 'true' }}
id: github-cache
uses: actions/[email protected]
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
2 changes: 1 addition & 1 deletion .github/actions/setup-python-tools-scripts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ runs:
cache-seed: tools|${{ steps.venv-hash.outputs.venv-hash }}

- name: Restore Python Tools Virtualenvs Cache
uses: actions/cache@v3.3.1
uses: ./.github/actions/cache
with:
path: ${{ inputs.cwd }}/.tools-venvs
key: ${{ inputs.cache-prefix }}|${{ steps.venv-hash.outputs.venv-hash }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/build-deps-onedir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
- self-hosted
- linux
- ${{ matrix.arch }}
env:
USE_S3_CACHE: 'true'
steps:

- name: "Throttle Builds"
Expand Down Expand Up @@ -96,7 +98,8 @@ jobs:
arch: ${{ inputs.github-enterprise-runners == true && fromJSON('["x86_64", "arm64"]') || fromJSON('["x86_64"]') }}
runs-on:
- ${{ matrix.arch == 'arm64' && 'macos-13-xlarge' || 'macos-12' }}

env:
USE_S3_CACHE: 'false'
steps:

- name: "Throttle Builds"
Expand Down Expand Up @@ -145,6 +148,8 @@ jobs:
- x86
- amd64
runs-on: windows-latest
env:
USE_S3_CACHE: 'false'
steps:

- name: "Throttle Builds"
Expand Down

0 comments on commit 8761927

Please sign in to comment.