Skip to content

Commit 123e09e

Browse files
committed
ci: create setup and upload ccache action
1 parent d523b6a commit 123e09e

File tree

3 files changed

+67
-57
lines changed

3 files changed

+67
-57
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: setup-ccache
2+
description: setup ccache artifacts
3+
inputs:
4+
key:
5+
description: "cache key name"
6+
required: true
7+
outputs:
8+
cache-hit:
9+
description: "Whether the key was found"
10+
value: ${{ steps.restore-cache.outputs.cache-hit }}
11+
runs:
12+
using: 'composite'
13+
steps:
14+
- name: Restore cache
15+
uses: actions/cache/restore@v4
16+
id: restore-cache
17+
with:
18+
path: .ccache
19+
key: ccache-${{ inputs.key }}-${{ github.sha }}
20+
restore-keys: ccache-${{ inputs.key }}
21+
- name: Configure cache
22+
shell: bash
23+
run: ccache -z
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: upload-ccache
2+
description: upload ccache artifacts
3+
inputs:
4+
key:
5+
description: "cache key name"
6+
required: true
7+
setup-ccache-outputs:
8+
description: "Output of ccache"
9+
required: true
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Print ccache statistics
14+
shell: bash
15+
run: ccache -s
16+
- name: Save cache
17+
uses: actions/cache/save@v4
18+
if: ${{ github.ref_name == 'master' && inputs.setup-ccache-outputs.cache-hit != 'true' }}
19+
id: save-cache
20+
with:
21+
path: .ccache
22+
key: ccache-${{ inputs.cache-key }}-${{ github.sha }}

.github/workflows/everything.yml

Lines changed: 22 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ jobs:
6262
run: |
6363
scripts/ci/gh-actions/get-changed-files.sh
6464
echo "::group::Test script output files"
65-
ls -la *-changed-files.txt
65+
ls -la ./*-changed-files.txt
6666
NUM_CHANGES=$(wc -l < filtered-changed-files.txt)
6767
echo "Number of files changed (filtered): ${NUM_CHANGES}"
68-
echo "num_code_changes=${NUM_CHANGES}" >> $GITHUB_OUTPUT
68+
echo "num_code_changes=${NUM_CHANGES}" >> "${GITHUB_OUTPUT}"
6969
7070
#######################################
7171
# Formatting jobs
@@ -175,16 +175,10 @@ jobs:
175175
with:
176176
ref: ${{ github.event.pull_request.head.sha }}
177177
path: source
178-
- name: Restore cache
179-
uses: actions/cache/restore@v4
180-
id: restore-cache
178+
- uses: ./source/.github/actions/setup-ccache
179+
id: setup-ccache
181180
with:
182-
path: .ccache
183-
key: ccache-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}${{ matrix.shared == 'static' && '-static' || ''}}-${{ github.sha }}
184-
restore-keys: |
185-
ccache-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}${{ matrix.shared == 'static' && '-static' || ''}}
186-
- name: Configure cache
187-
run: ccache -z
181+
key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}${{ matrix.shared == 'static' && '-static' || ''}}
188182
- name: Setup
189183
run: gha/scripts/ci/gh-actions/linux-setup.sh
190184
- name: Update
@@ -193,15 +187,10 @@ jobs:
193187
run: gha/scripts/ci/gh-actions/run.sh configure
194188
- name: Build
195189
run: gha/scripts/ci/gh-actions/run.sh build
196-
- name: Print ccache statistics
197-
run: ccache -s | tee $GITHUB_STEP_SUMMARY
198-
- name: Save cache
199-
uses: actions/cache/save@v4
200-
if: ${{ github.ref_name == 'master' && steps.restore-cache.outputs.cache-hit != 'true' }}
201-
id: save-cache
190+
- uses: ./source/.github/actions/upload-ccache
202191
with:
203-
path: .ccache
204-
key: ccache-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}${{ matrix.shared == 'static' && '-static' || ''}}-${{ github.sha }}
192+
key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}${{ matrix.shared == 'static' && '-static' || ''}}
193+
setup-ccache-outputs: steps.setup-ccache.outputs
205194
- name: Test
206195
if: ${{ matrix.constrains != 'build_only' }}
207196
run: gha/scripts/ci/gh-actions/run.sh test
@@ -240,16 +229,10 @@ jobs:
240229
with:
241230
ref: ${{ github.event.pull_request.head.sha }}
242231
path: source
243-
- name: Restore cache
244-
uses: actions/cache/restore@v4
245-
id: restore-cache
232+
- uses: ./source/.github/actions/setup-ccache
233+
id: setup-ccache
246234
with:
247-
path: .ccache
248-
key: ccache-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}-${{ github.sha }}
249-
restore-keys: |
250-
ccache-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}
251-
- name: Configure cache
252-
run: ccache -z
235+
key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}
253236
- name: Setup
254237
run: gha/scripts/ci/gh-actions/linux-setup.sh
255238
- name: Update
@@ -258,17 +241,10 @@ jobs:
258241
run: gha/scripts/ci/gh-actions/run.sh configure
259242
- name: Build
260243
run: gha/scripts/ci/gh-actions/run.sh build
261-
- name: Print ccache statistics
262-
run: ccache -s
263-
- name: Save cache
264-
uses: actions/cache/save@v4
265-
if: ${{ github.ref_name == 'master' && steps.restore-cache.outputs.cache-hit != 'true' }}
266-
id: save-cache
244+
- uses: ./source/.github/actions/upload-ccache
267245
with:
268-
path: .ccache
269-
key: ccache-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}-${{ github.sha }}
270-
- name: Test
271-
run: gha/scripts/ci/gh-actions/run.sh test
246+
key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.parallel }}
247+
setup-ccache-outputs: steps.setup-ccache.outputs
272248

273249
macos:
274250
needs: [format, git_checks]
@@ -318,31 +294,20 @@ jobs:
318294
path: source
319295
- name: Setup
320296
run: gha/scripts/ci/gh-actions/macos-setup.sh
321-
- name: Restore cache
322-
uses: actions/cache/restore@v4
323-
id: restore-cache
297+
- uses: ./source/.github/actions/setup-ccache
298+
id: setup-ccache
324299
with:
325-
path: .ccache
326-
key: ccache-${{ matrix.image}}-${{ matrix.compiler }}-${{ matrix.parallel }}-${{ matrix.shared }}-${{ github.sha }}
327-
restore-keys: |
328-
ccache-${{ matrix.image }}-${{ matrix.compiler }}-${{ matrix.parallel }}-${{ matrix.shared }}
329-
- name: Configure cache
330-
run: ccache -z
300+
key: ${{ matrix.image }}-${{ matrix.compiler }}-${{ matrix.parallel }}-${{ matrix.shared }}
331301
- name: Update
332302
run: gha/scripts/ci/gh-actions/run.sh update
333303
- name: Configure
334304
run: gha/scripts/ci/gh-actions/run.sh configure
335305
- name: Build
336306
run: gha/scripts/ci/gh-actions/run.sh build
337-
- name: Print ccache statistics
338-
run: ccache -s
339-
- name: Save cache
340-
uses: actions/cache/save@v4
341-
if: ${{ github.ref_name == 'master' && steps.restore-cache.outputs.cache-hit != 'true' }}
342-
id: save-cache
307+
- uses: ./source/.github/actions/upload-ccache
343308
with:
344-
path: .ccache
345-
key: ccache-${{ matrix.image }}-${{ matrix.compiler }}-${{ matrix.parallel }}-${{ matrix.shared }}-${{ github.sha }}
309+
key: ${{ matrix.image }}-${{ matrix.compiler }}-${{ matrix.parallel }}-${{ matrix.shared }}
310+
setup-ccache-outputs: steps.setup-ccache.outputs
346311
- name: Test
347312
run: gha/scripts/ci/gh-actions/run.sh test
348313

@@ -458,12 +423,12 @@ jobs:
458423
target_tag="${GITHUB_REF##refs/heads/}-${{ matrix.baseos }}"
459424
docker tag \
460425
ornladios/adios2:ci-tmp \
461-
ornladios/adios2:${target_tag}
426+
"ornladios/adios2:${target_tag}"
462427
docker login \
463428
--username="${DOCKERHUB_USERNAME}" \
464429
--password="${DOCKERHUB_PASSWORD}"
465430
docker push \
466-
ornladios/adios2:${target_tag}
431+
"ornladios/adios2:${target_tag}"
467432
468433
#######################################
469434
# Contract testing jobs

0 commit comments

Comments
 (0)