Skip to content

Commit 94f08e3

Browse files
Copilotpethers
andauthored
Add comprehensive dependency caching to workflows (APT, pip, Ruby gems, Docker) (#720)
* Initial plan * Add comprehensive caching to all workflows for improved performance Co-authored-by: pethers <[email protected]> * Add comprehensive caching strategy documentation Co-authored-by: pethers <[email protected]> * Fix cache keys to remove non-existent file references (code review feedback) Co-authored-by: pethers <[email protected]> * Update action versions to latest releases (setup-python v6.1.0, setup-ruby v1.270.0) Co-authored-by: pethers <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: pethers <[email protected]>
1 parent 502961f commit 94f08e3

File tree

3 files changed

+416
-0
lines changed

3 files changed

+416
-0
lines changed

.github/workflows/main.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,47 @@ jobs:
4343
api.snapcraft.io:443
4444
- name: Checkout
4545
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
46+
47+
- name: Cache APT packages
48+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
49+
with:
50+
path: |
51+
/var/cache/apt/archives
52+
/var/lib/apt/lists
53+
key: ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/main.yml') }}
54+
restore-keys: |
55+
${{ runner.os }}-apt-
56+
57+
- name: Setup Python
58+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
59+
with:
60+
python-version: '3.12'
61+
62+
- name: Cache Python dependencies
63+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
64+
with:
65+
path: |
66+
~/.cache/pip
67+
~/.local/lib/python3.12/site-packages
68+
key: ${{ runner.os }}-pip-cfn-lint-checkov-${{ hashFiles('.github/workflows/main.yml') }}
69+
restore-keys: |
70+
${{ runner.os }}-pip-cfn-lint-checkov-
71+
${{ runner.os }}-pip-
72+
73+
- name: Setup Ruby
74+
uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
75+
with:
76+
ruby-version: '3.3'
77+
78+
- name: Cache Ruby gems
79+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
80+
with:
81+
path: vendor/bundle
82+
key: ${{ runner.os }}-gems-cfn-nag-${{ hashFiles('.github/workflows/main.yml') }}
83+
restore-keys: |
84+
${{ runner.os }}-gems-cfn-nag-
85+
${{ runner.os }}-gems-
86+
4687
- name: Testing with CFN Lint Command
4788
uses: scottbrenner/cfn-lint-action@25ee47d1ab3146bda904df745511735cc0b9a970 # v2.5.2
4889
with:
@@ -165,6 +206,19 @@ jobs:
165206
capabilities: CAPABILITY_NAMED_IAM
166207
no-fail-on-empty-changeset: "1"
167208
parameter-overrides: "StackIrland=${{ env.StackId }},StackFrankfurt=${{ env.StackId2 }}"
209+
210+
- name: Set up Docker Buildx
211+
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
212+
213+
- name: Cache Docker layers
214+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
215+
with:
216+
path: /tmp/.buildx-cache
217+
key: ${{ runner.os }}-docker-zap-${{ hashFiles('.github/workflows/main.yml') }}
218+
restore-keys: |
219+
${{ runner.os }}-docker-zap-
220+
${{ runner.os }}-docker-
221+
168222
- name: ZAP API Scan
169223
uses: zaproxy/action-api-scan@5158fe4d9d8fcc75ea204db81317cce7f9e5453d # v0.10.0
170224
with:

.github/workflows/pullrequest.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,47 @@ jobs:
2222
docs.github.com:433
2323
api.github.com:443
2424
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
25+
26+
- name: Cache APT packages
27+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
28+
with:
29+
path: |
30+
/var/cache/apt/archives
31+
/var/lib/apt/lists
32+
key: ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/pullrequest.yml') }}
33+
restore-keys: |
34+
${{ runner.os }}-apt-
35+
36+
- name: Setup Python
37+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
38+
with:
39+
python-version: '3.12'
40+
41+
- name: Cache Python dependencies
42+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
43+
with:
44+
path: |
45+
~/.cache/pip
46+
~/.local/lib/python3.12/site-packages
47+
key: ${{ runner.os }}-pip-cfn-lint-checkov-${{ hashFiles('.github/workflows/pullrequest.yml') }}
48+
restore-keys: |
49+
${{ runner.os }}-pip-cfn-lint-checkov-
50+
${{ runner.os }}-pip-
51+
52+
- name: Setup Ruby
53+
uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
54+
with:
55+
ruby-version: '3.3'
56+
57+
- name: Cache Ruby gems
58+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
59+
with:
60+
path: vendor/bundle
61+
key: ${{ runner.os }}-gems-cfn-nag-${{ hashFiles('.github/workflows/pullrequest.yml') }}
62+
restore-keys: |
63+
${{ runner.os }}-gems-cfn-nag-
64+
${{ runner.os }}-gems-
65+
2566
- name: Run StandardLint
2667
uses: mikaelvesavuori/standardlint-action@b376b6d6afc5885d102894f6972133fa91d200f0 # v1.0.5
2768
env:

0 commit comments

Comments
 (0)