-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (77 loc) · 2.91 KB
/
cache-test-dataset.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Copyright (C) 2024 Roberto Rossini <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0
#
# This library is free software: you can redistribute it and/or
# modify it under the terms of the GNU Public License as published
# by the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Public License along
# with this library. If not, see
# <https://www.gnu.org/licenses/>.
name: Cache test datasets
on:
workflow_call:
outputs:
cache-key:
description: "Test dataset cache key"
value: ${{ jobs.cache-test-datasets.outputs.cache-key }}
defaults:
run:
shell: bash
env:
FETCH_TEST_DATASET_CMAKE: cmake/FetchTestDataset.cmake
TEST_DATASET_PATH: test/data/nchg_test_data.tar.zst
jobs:
cache-test-datasets:
name: Cache test datasets
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.generate-cache-key.outputs.key }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Generate cache key
id: generate-cache-key
run: |
key="test-dataset-${{ hashFiles( 'cmake/FetchTestDataset.cmake' ) }}"
echo "key=$key" | tee -a "$GITHUB_OUTPUT"
- name: Restore cache
id: cache-dset
uses: actions/cache/restore@v4
with:
key: ${{ steps.generate-cache-key.outputs.key }}
path: ${{ env.TEST_DATASET_PATH }}
lookup-only: true
- name: Extract test dataset URL and checksum
if: steps.cache-dset.outputs.cache-hit != 'true'
id: test-dataset
run: |
url="$(grep -F 'DOWNLOAD' "$FETCH_TEST_DATASET_CMAKE" | sed 's/.*DOWNLOAD[[:space:]]\+//')"
checksum="$(grep -F 'EXPECTED_HASH' "$FETCH_TEST_DATASET_CMAKE" | sed 's/.*SHA256=//')"
echo "url=$url" | tee -a "$GITHUB_OUTPUT"
echo "checksum=$checksum" | tee -a "$GITHUB_OUTPUT"
- name: Download test dataset
if: steps.cache-dset.outputs.cache-hit != 'true'
run: |
src="${{ steps.test-dataset.outputs.url }}"
dest="$TEST_DATASET_PATH"
mkdir -p "$(dirname "$dest")"
curl -L "$src" -o "$dest"
- name: Checksum test dataset
if: steps.cache-dset.outputs.cache-hit != 'true'
run: |
echo "${{ steps.test-dataset.outputs.checksum }} $TEST_DATASET_PATH" | tee checksum.sha256
shasum -c checksum.sha256
- name: Save cache
uses: actions/cache/save@v4
if: steps.cache-dset.outputs.cache-hit != 'true'
with:
key: ${{ steps.generate-cache-key.outputs.key }}
path: ${{ env.TEST_DATASET_PATH }}