Skip to content

Commit 5acd2a6

Browse files
* Use dedicated workflow to update caching packages
* Read the cahe in another workflows
1 parent 727e6e8 commit 5acd2a6

29 files changed

Lines changed: 407 additions & 94 deletions

.github/workflows/test_linting.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
uses: actions/setup-python@v6
3131
with:
3232
python-version: "3.11"
33+
cache: 'pip'
34+
cache-dependency-path: requirements-test.txt
3335

3436
- name: Install test dependencies.
3537
run: |

.github/workflows/test_plugins.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
uses: actions/setup-python@v6
4545
with:
4646
python-version: ${{ matrix.python_version }}
47+
cache: 'pip'
4748

4849
- name: Install Ansible
4950
run: |
@@ -86,6 +87,7 @@ jobs:
8687
uses: actions/setup-python@v6
8788
with:
8889
python-version: ${{ matrix.python_version }}
90+
cache: 'pip'
8991

9092
- name: Install Ansible
9193
run: |
@@ -123,6 +125,7 @@ jobs:
123125
uses: actions/setup-python@v6
124126
with:
125127
python-version: 3.11
128+
cache: 'pip'
126129

127130
- name: Install dependencies
128131
run: |
@@ -172,13 +175,53 @@ jobs:
172175
uses: actions/setup-python@v6
173176
with:
174177
python-version: "3.11"
178+
cache: 'pip'
179+
cache-dependency-path: requirements-test.txt
175180

176181
- name: Install dependencies
177182
run: |
178183
python3 -m pip install --upgrade pip
179184
python3 -m pip install "ansible-core>=2.19,<2.20"
180185
python3 -m pip install -r requirements-test.txt
181186
187+
- name: Get latest Elasticsearch release
188+
id: elastic-version
189+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
190+
run: |
191+
curl -fsSL \
192+
"https://artifacts.elastic.co/packages/${{ matrix.release }}.x/apt/dists/stable/main/binary-amd64/Packages.gz" \
193+
-o /tmp/Packages.gz
194+
VERSION=$(zcat /tmp/Packages.gz \
195+
| awk '$1=="Package:" && $2=="elasticsearch"{p=1} p && $1=="Version:"{print $2; p=0}' \
196+
| sort -V \
197+
| tail -n 1)
198+
rm -f /tmp/Packages.gz
199+
echo "version=$VERSION" >> $GITHUB_OUTPUT
200+
201+
- name: Debug - latest Elasticsearch version
202+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
203+
run: echo "Latest Elasticsearch ${{ matrix.release }}.x = ${{ steps.elastic-version.outputs.version }}"
204+
205+
- name: Restore Elastic apt cache
206+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
207+
uses: actions/cache/restore@v5
208+
with:
209+
path: /tmp/elastic-apt-cache
210+
key: ${{ runner.os }}-apt-elastic-${{ steps.elastic-version.outputs.version }}
211+
restore-keys: |
212+
${{ runner.os }}-apt-elastic-${{ matrix.release }}.
213+
214+
- name: Debug - apt cache contents
215+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
216+
run: |
217+
echo "=== /tmp/elastic-apt-cache/ ==="
218+
ls -lh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(empty or does not exist)"
219+
echo "=== Total size ==="
220+
du -sh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(n/a)"
221+
222+
- name: Ensure apt cache directory exists
223+
run: mkdir -p /tmp/elastic-apt-cache
224+
182225
- name: Install collection
183226
run: |
184227
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE
@@ -217,6 +260,7 @@ jobs:
217260
uses: actions/setup-python@v6
218261
with:
219262
python-version: 3.11
263+
cache: 'pip'
220264

221265
- name: Install dependencies
222266
run: |

.github/workflows/test_role_beats.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,53 @@ jobs:
5656
uses: actions/setup-python@v6
5757
with:
5858
python-version: ${{ matrix.python_version }}
59+
cache: 'pip'
60+
cache-dependency-path: requirements-test.txt
5961

6062
- name: Install dependencies
6163
run: |
6264
python3 -m pip install --upgrade pip
6365
python3 -m pip install "${{ matrix.ansible_version }}"
6466
python3 -m pip install -r requirements-test.txt
6567
68+
- name: Get latest Elasticsearch release
69+
id: elastic-version
70+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
71+
run: |
72+
curl -fsSL \
73+
"https://artifacts.elastic.co/packages/${{ matrix.release }}.x/apt/dists/stable/main/binary-amd64/Packages.gz" \
74+
-o /tmp/Packages.gz
75+
VERSION=$(zcat /tmp/Packages.gz \
76+
| awk '$1=="Package:" && $2=="elasticsearch"{p=1} p && $1=="Version:"{print $2; p=0}' \
77+
| sort -V \
78+
| tail -n 1)
79+
rm -f /tmp/Packages.gz
80+
echo "version=$VERSION" >> $GITHUB_OUTPUT
81+
82+
- name: Debug - latest Elasticsearch version
83+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
84+
run: echo "Latest Elasticsearch ${{ matrix.release }}.x = ${{ steps.elastic-version.outputs.version }}"
85+
86+
- name: Restore Elastic apt cache
87+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
88+
uses: actions/cache/restore@v5
89+
with:
90+
path: /tmp/elastic-apt-cache
91+
key: ${{ runner.os }}-apt-elastic-${{ steps.elastic-version.outputs.version }}
92+
restore-keys: |
93+
${{ runner.os }}-apt-elastic-${{ matrix.release }}.
94+
95+
- name: Debug - apt cache contents
96+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
97+
run: |
98+
echo "=== /tmp/elastic-apt-cache/ ==="
99+
ls -lh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(empty or does not exist)"
100+
echo "=== Total size ==="
101+
du -sh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(n/a)"
102+
103+
- name: Ensure apt cache directory exists
104+
run: mkdir -p /tmp/elastic-apt-cache
105+
66106
- name: Install collection
67107
run: |
68108
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE

.github/workflows/test_role_elasticsearch.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,53 @@ jobs:
5555
uses: actions/setup-python@v6
5656
with:
5757
python-version: ${{ matrix.python_version }}
58+
cache: 'pip'
59+
cache-dependency-path: requirements-test.txt
5860

5961
- name: Install dependencies
6062
run: |
6163
python3 -m pip install --upgrade pip
6264
python3 -m pip install "${{ matrix.ansible_version }}"
6365
python3 -m pip install -r requirements-test.txt
6466
67+
- name: Get latest Elasticsearch release
68+
id: elastic-version
69+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
70+
run: |
71+
curl -fsSL \
72+
"https://artifacts.elastic.co/packages/${{ matrix.release }}.x/apt/dists/stable/main/binary-amd64/Packages.gz" \
73+
-o /tmp/Packages.gz
74+
VERSION=$(zcat /tmp/Packages.gz \
75+
| awk '$1=="Package:" && $2=="elasticsearch"{p=1} p && $1=="Version:"{print $2; p=0}' \
76+
| sort -V \
77+
| tail -n 1)
78+
rm -f /tmp/Packages.gz
79+
echo "version=$VERSION" >> $GITHUB_OUTPUT
80+
81+
- name: Debug - latest Elasticsearch version
82+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
83+
run: echo "Latest Elasticsearch ${{ matrix.release }}.x = ${{ steps.elastic-version.outputs.version }}"
84+
85+
- name: Restore Elastic apt cache
86+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
87+
uses: actions/cache/restore@v5
88+
with:
89+
path: /tmp/elastic-apt-cache
90+
key: ${{ runner.os }}-apt-elastic-${{ steps.elastic-version.outputs.version }}
91+
restore-keys: |
92+
${{ runner.os }}-apt-elastic-${{ matrix.release }}.
93+
94+
- name: Debug - apt cache contents
95+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
96+
run: |
97+
echo "=== /tmp/elastic-apt-cache/ ==="
98+
ls -lh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(empty or does not exist)"
99+
echo "=== Total size ==="
100+
du -sh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(n/a)"
101+
102+
- name: Ensure apt cache directory exists
103+
run: mkdir -p /tmp/elastic-apt-cache
104+
65105
- name: Install collection
66106
run: |
67107
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE

.github/workflows/test_role_kibana.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,53 @@ jobs:
5656
uses: actions/setup-python@v6
5757
with:
5858
python-version: ${{ matrix.python_version }}
59+
cache: 'pip'
60+
cache-dependency-path: requirements-test.txt
5961

6062
- name: Install dependencies
6163
run: |
6264
python3 -m pip install --upgrade pip
6365
python3 -m pip install "${{ matrix.ansible_version }}"
6466
python3 -m pip install -r requirements-test.txt
6567
68+
- name: Get latest Elasticsearch release
69+
id: elastic-version
70+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
71+
run: |
72+
curl -fsSL \
73+
"https://artifacts.elastic.co/packages/${{ matrix.release }}.x/apt/dists/stable/main/binary-amd64/Packages.gz" \
74+
-o /tmp/Packages.gz
75+
VERSION=$(zcat /tmp/Packages.gz \
76+
| awk '$1=="Package:" && $2=="elasticsearch"{p=1} p && $1=="Version:"{print $2; p=0}' \
77+
| sort -V \
78+
| tail -n 1)
79+
rm -f /tmp/Packages.gz
80+
echo "version=$VERSION" >> $GITHUB_OUTPUT
81+
82+
- name: Debug - latest Elasticsearch version
83+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
84+
run: echo "Latest Elasticsearch ${{ matrix.release }}.x = ${{ steps.elastic-version.outputs.version }}"
85+
86+
- name: Restore Elastic apt cache
87+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
88+
uses: actions/cache/restore@v5
89+
with:
90+
path: /tmp/elastic-apt-cache
91+
key: ${{ runner.os }}-apt-elastic-${{ steps.elastic-version.outputs.version }}
92+
restore-keys: |
93+
${{ runner.os }}-apt-elastic-${{ matrix.release }}.
94+
95+
- name: Debug - apt cache contents
96+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
97+
run: |
98+
echo "=== /tmp/elastic-apt-cache/ ==="
99+
ls -lh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(empty or does not exist)"
100+
echo "=== Total size ==="
101+
du -sh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(n/a)"
102+
103+
- name: Ensure apt cache directory exists
104+
run: mkdir -p /tmp/elastic-apt-cache
105+
66106
- name: Install collection
67107
run: |
68108
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE

.github/workflows/test_role_logstash.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,53 @@ jobs:
5656
uses: actions/setup-python@v6
5757
with:
5858
python-version: ${{ matrix.python_version }}
59+
cache: 'pip'
60+
cache-dependency-path: requirements-test.txt
5961

6062
- name: Install dependencies
6163
run: |
6264
python3 -m pip install --upgrade pip
6365
python3 -m pip install "${{ matrix.ansible_version }}"
6466
python3 -m pip install -r requirements-test.txt
6567
68+
- name: Get latest Elasticsearch release
69+
id: elastic-version
70+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
71+
run: |
72+
curl -fsSL \
73+
"https://artifacts.elastic.co/packages/${{ matrix.release }}.x/apt/dists/stable/main/binary-amd64/Packages.gz" \
74+
-o /tmp/Packages.gz
75+
VERSION=$(zcat /tmp/Packages.gz \
76+
| awk '$1=="Package:" && $2=="elasticsearch"{p=1} p && $1=="Version:"{print $2; p=0}' \
77+
| sort -V \
78+
| tail -n 1)
79+
rm -f /tmp/Packages.gz
80+
echo "version=$VERSION" >> $GITHUB_OUTPUT
81+
82+
- name: Debug - latest Elasticsearch version
83+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
84+
run: echo "Latest Elasticsearch ${{ matrix.release }}.x = ${{ steps.elastic-version.outputs.version }}"
85+
86+
- name: Restore Elastic apt cache
87+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
88+
uses: actions/cache/restore@v5
89+
with:
90+
path: /tmp/elastic-apt-cache
91+
key: ${{ runner.os }}-apt-elastic-${{ steps.elastic-version.outputs.version }}
92+
restore-keys: |
93+
${{ runner.os }}-apt-elastic-${{ matrix.release }}.
94+
95+
- name: Debug - apt cache contents
96+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
97+
run: |
98+
echo "=== /tmp/elastic-apt-cache/ ==="
99+
ls -lh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(empty or does not exist)"
100+
echo "=== Total size ==="
101+
du -sh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(n/a)"
102+
103+
- name: Ensure apt cache directory exists
104+
run: mkdir -p /tmp/elastic-apt-cache
105+
66106
- name: Install collection
67107
run: |
68108
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE

.github/workflows/test_role_repos.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,53 @@ jobs:
5959
uses: actions/setup-python@v6
6060
with:
6161
python-version: ${{ matrix.python_version }}
62+
cache: 'pip'
63+
cache-dependency-path: requirements-test.txt
6264

6365
- name: Install dependencies
6466
run: |
6567
python3 -m pip install --upgrade pip
6668
python3 -m pip install "${{ matrix.ansible_version }}"
6769
python3 -m pip install -r requirements-test.txt
6870
71+
- name: Get latest Elasticsearch release
72+
id: elastic-version
73+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
74+
run: |
75+
curl -fsSL \
76+
"https://artifacts.elastic.co/packages/${{ matrix.release }}.x/apt/dists/stable/main/binary-amd64/Packages.gz" \
77+
-o /tmp/Packages.gz
78+
VERSION=$(zcat /tmp/Packages.gz \
79+
| awk '$1=="Package:" && $2=="elasticsearch"{p=1} p && $1=="Version:"{print $2; p=0}' \
80+
| sort -V \
81+
| tail -n 1)
82+
rm -f /tmp/Packages.gz
83+
echo "version=$VERSION" >> $GITHUB_OUTPUT
84+
85+
- name: Debug - latest Elasticsearch version
86+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
87+
run: echo "Latest Elasticsearch ${{ matrix.release }}.x = ${{ steps.elastic-version.outputs.version }}"
88+
89+
- name: Restore Elastic apt cache
90+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
91+
uses: actions/cache/restore@v5
92+
with:
93+
path: /tmp/elastic-apt-cache
94+
key: ${{ runner.os }}-apt-elastic-${{ steps.elastic-version.outputs.version }}
95+
restore-keys: |
96+
${{ runner.os }}-apt-elastic-${{ matrix.release }}.
97+
98+
- name: Debug - apt cache contents
99+
if: contains(matrix.distro, 'ubuntu') || contains(matrix.distro, 'debian')
100+
run: |
101+
echo "=== /tmp/elastic-apt-cache/ ==="
102+
ls -lh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(empty or does not exist)"
103+
echo "=== Total size ==="
104+
du -sh /tmp/elastic-apt-cache/ 2>/dev/null || echo "(n/a)"
105+
106+
- name: Ensure apt cache directory exists
107+
run: mkdir -p /tmp/elastic-apt-cache
108+
69109
- name: Install collection
70110
run: |
71111
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE

0 commit comments

Comments
 (0)