Repository navigation
82 lines (72 loc) · 3.23 KB
/
Copy pathcache_elephant_data.yml
File metadata and controls
82 lines (72 loc) · 3.23 KB
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
name: Create caches for elephant_data
on:
workflow_dispatch: # Workflow can be triggered manually via GH actions webinterface
push: # When something is pushed into master this checks if caches need to re-created
branches:
- master
schedule:
- cron: "11 23 * * *" # Daily at 23:11 UTC
jobs:
create-data-cache-if-missing:
name: Caching data env
runs-on: ubuntu-latest
strategy:
# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false
steps:
- name: Get current hash (SHA) of the elephant_data repo
id: elephant-data
run: |
set -o pipefail
for attempt in 1 2 3; do
if response=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD); then
# Cut out the hash, and do a sanity check on the hash
if hash=$(echo "$response" | awk '{print $1}') && [[ "$hash" =~ ^[0-9a-f]{40}$ ]]; then
echo "dataset_hash=$hash" >> "$GITHUB_OUTPUT"
exit 0
fi
fi
echo "ls-remote failed (attempt $attempt)"
# Don't sleep after the last attempt
if [ "$attempt" -lt 3 ]; then
echo "retrying ..."; sleep $((attempt * 30))
fi
done
echo "::error::Could not get elephant-data HEAD from GIN"; exit 1
- uses: actions/cache@v5
# Loading cache of elephant-data
id: cache-datasets
with:
# Relative to $GITHUB_WORKSPACE, so the cache version matches across OSs.
# The leading dot in '.ci-data' keeps pytest from collecting the data
path: .ci-data/elephant-data
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
enableCrossOsArchive: true
- name: Cache found?
run: echo "Cache-hit == ${{steps.cache-datasets.outputs.cache-hit == 'true'}}"
- name: Configuring git
if: steps.cache-datasets.outputs.cache-hit != 'true'
run: |
git config --global user.email "elephant_ci@fake_mail.com"
git config --global user.name "elephant CI"
git config --global filter.annex.process "git-annex filter-process" # recommended for efficiency
- name: Install Datalad Linux
if: steps.cache-datasets.outputs.cache-hit != 'true'
run: |
python -m pip install -U pip # Official recommended way
pip install datalad-installer
datalad-installer --sudo ok git-annex --method datalad/packages
pip install datalad
- name: Download dataset
id: download-dataset
if: steps.cache-datasets.outputs.cache-hit != 'true'
# Use $GITHUB_WORKSPACE (the path cache step resolves against)
# This matches the cache path even if working-directory changes.
run: |
datalad --version
mkdir -p "$GITHUB_WORKSPACE/.ci-data"
datalad install --recursive --get-data -s https://gin.g-node.org/NeuralEnsemble/elephant-data "$GITHUB_WORKSPACE/.ci-data/elephant-data"
- name: Show size of the cache to assert data is downloaded
run: |
du -hs "$GITHUB_WORKSPACE/.ci-data/elephant-data"
ls -lh "$GITHUB_WORKSPACE/.ci-data/elephant-data"