Skip to content

Commit

Permalink
GHA: factor out apt cache and install actions
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd committed May 17, 2024
1 parent ee9c74f commit d8f06b9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 129 deletions.
26 changes: 26 additions & 0 deletions .github/actions/apt-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Cache and Install APT Dependencies
description:
Light wrapper around the actions/cache action and our script
to maintain the input vars in only one place for all workflows.

runs:
using: "composite"
steps:
- name: Cache APT Dependencies
id: cache-apt-deps
uses: actions/cache@v4
with:
path: |
~/apt_cache
key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-v8-apt-
- name: Install APT Depedencies
env:
CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
./scripts/github/install-apt-packages-use-cache.sh
73 changes: 8 additions & 65 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,8 @@ jobs:
# don't want to retrieve previous cache
#restore-keys: |
# ${{ runner.os }}-v5-python-${{ matrix.python }}-
- name: Cache APT Dependencies
id: cache-apt-deps
uses: actions/cache@v4
with:
path: |
~/apt_cache
key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-v8-apt-
- name: Install APT Depedencies
env:
CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
./scripts/github/install-apt-packages-use-cache.sh
- name: Cache and Install APT Dependencies
uses: ./.github/actions/apt-packages.yaml
- name: Install virtualenv
run: |
./scripts/github/install-virtualenv.sh
Expand Down Expand Up @@ -197,23 +183,8 @@ jobs:
key: ${{ runner.os }}-v5-python-${{ matrix.python-version }}-${{ hashFiles('requirements.txt', 'test-requirements.txt', 'lockfiles/*.lock') }}
restore-keys: |
${{ runner.os }}-python-${{ matrix.python }}-
- name: Cache APT Dependencies
id: cache-apt-deps
uses: actions/cache@v4
with:
path: |
~/apt_cache
key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-v8-apt-
- name: Install APT Depedencies
env:
CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
cat /etc/environment
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
./scripts/github/install-apt-packages-use-cache.sh
- name: Cache and Install APT Dependencies
uses: ./.github/actions/apt-packages.yaml
- name: Install virtualenv
run: |
./scripts/github/install-virtualenv.sh
Expand Down Expand Up @@ -403,22 +374,8 @@ jobs:
# don't want to retrieve previous cache
#restore-keys: |
# ${{ runner.os }}-v5-python-${{ matrix.python }}-
- name: Cache APT Dependencies
id: cache-apt-deps
uses: actions/cache@v4
with:
path: |
~/apt_cache
key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-v8-apt-
- name: Install APT Depedencies
env:
CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
./scripts/github/install-apt-packages-use-cache.sh
- name: Cache and Install APT Dependencies
uses: ./.github/actions/apt-packages.yaml
- name: Install virtualenv
run: |
./scripts/github/install-virtualenv.sh
Expand Down Expand Up @@ -623,22 +580,8 @@ jobs:
# don't want to retrieve previous cache
#restore-keys: |
# ${{ runner.os }}-v5-python-${{ matrix.python }}-
- name: Cache APT Dependencies
id: cache-apt-deps
uses: actions/cache@v4
with:
path: |
~/apt_cache
key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-v8-apt-
- name: Install APT Depedencies
env:
CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
./scripts/github/install-apt-packages-use-cache.sh
- name: Cache and Install APT Dependencies
uses: ./.github/actions/apt-packages.yaml
- name: Install virtualenv
run: |
./scripts/github/install-virtualenv.sh
Expand Down
19 changes: 2 additions & 17 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,8 @@ jobs:
# a test uses a submodule, and pants needs access to it to calculate deps.
submodules: 'true'

#- name: Cache APT Dependencies
# id: cache-apt-deps
# uses: actions/cache@v4
# with:
# path: |
# ~/apt_cache
# key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }}
# restore-keys: |
# ${{ runner.os }}-v8-apt-
- name: Install APT Depedencies
env:
CACHE_HIT: 'false' # cache doesn't work
#CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
./scripts/github/install-apt-packages-use-cache.sh
- name: Cache and Install APT Dependencies
uses: ./.github/actions/apt-cache.yaml

- name: Initialize Pants and its GHA caches
uses: ./.github/actions/init-pants.yaml
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/microbenchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,8 @@ jobs:
# don't want to retrieve previous cache
#restore-keys: |
# ${{ runner.os }}-v5-python-${{ matrix.python }}-
- name: Cache APT Dependencies
id: cache-apt-deps
uses: actions/cache@v4
with:
path: |
~/apt_cache
key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-v8-apt-
- name: Install APT Dependencies
env:
CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
./scripts/github/install-apt-packages-use-cache.sh
- name: Cache and Install APT Dependencies
uses: ./.github/actions/apt-packages.yaml
- name: Install virtualenv
run: |
./scripts/github/install-virtualenv.sh
Expand Down
18 changes: 2 additions & 16 deletions .github/workflows/orquesta-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,8 @@ jobs:
# don't want to retrieve previous cache
#restore-keys: |
# ${{ runner.os }}-v5-python-${{ matrix.python }}-
- name: Cache APT Dependencies
id: cache-apt-deps
uses: actions/cache@v4
with:
path: |
~/apt_cache
key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-v8-apt-
- name: Install APT Depedencies
env:
CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
./scripts/github/install-apt-packages-use-cache.sh
- name: Cache and Install APT Dependencies
uses: ./.github/actions/apt-cache.yaml
- name: Install virtualenv
run: |
./scripts/github/install-virtualenv.sh
Expand Down
19 changes: 2 additions & 17 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,8 @@ jobs:
python-version: '${{ matrix.python-version }}'


#- name: Cache APT Dependencies
# id: cache-apt-deps
# uses: actions/cache@v4
# with:
# path: |
# ~/apt_cache
# key: ${{ runner.os }}-v8-apt-${{ hashFiles('scripts/github/apt-packages.txt') }}
# restore-keys: |
# ${{ runner.os }}-v8-apt-
- name: Install APT Depedencies
env:
CACHE_HIT: 'false' # cache doesn't work
#CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
./scripts/github/install-apt-packages-use-cache.sh
- name: Cache and Install APT Dependencies
uses: ./.github/actions/apt-cache.yaml

- name: Initialize Pants and its GHA caches
uses: ./.github/actions/init-pants.yaml
Expand Down

0 comments on commit d8f06b9

Please sign in to comment.