Skip to content

Commit 59eed79

Browse files
committed
Cache ucm release
1 parent b151b2b commit 59eed79

File tree

3 files changed

+48
-16
lines changed

3 files changed

+48
-16
lines changed

.github/workflows/cloud-client-tests.yml

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
on:
2+
pull_request:
3+
push:
4+
branches:
5+
- main
26
workflow_dispatch:
37
schedule:
48
- cron: '46 * * * *'
@@ -20,10 +24,22 @@ jobs:
2024
steps:
2125
- name: Check out repository code
2226
uses: actions/checkout@v4
27+
- name: Restore cached ucm release
28+
id: restore-cached-ucm
29+
uses: actions/cache/restore@v4
30+
with:
31+
path: |
32+
/opt/unisonlanguage
33+
/usr/local/bin/ucm
34+
key: ${{ runner.os }}-ucm-${{ matrix.ucm-release-version }}
35+
- name: Install ucm
36+
if: steps.restore-cached-ucm.outputs.cache-hit != 'true'
37+
env:
38+
UCM_RELEASE: ${{ matrix.ucm-release-version }}
39+
run: ./install-ucm.sh
2340
- name: Run tests
2441
env:
2542
CLOUD_CLIENT_VERSION: ${{ matrix.cloud-client-version }}
26-
UCM_RELEASE: ${{ matrix.ucm-release-version }}
2743
UNISON_CLOUD_ACCESS_TOKEN: ${{ secrets.CLOUD_USER_ACCESS_TOKEN }}
2844
UNISON_DEBUG: timing
2945
run: |
@@ -49,3 +65,12 @@ jobs:
4965
}
5066
env:
5167
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
68+
- name: Cache ucm release
69+
if: ${{ !cancelled() && steps.restore-cached-ucm.outputs.cache-hit != 'true' && startsWith(matrix.ucm-release-version, 'release') }}
70+
id: save-ucm-to-cache
71+
uses: actions/cache/save@v4
72+
with:
73+
path: |
74+
/opt/unisonlanguage
75+
/usr/local/bin/ucm
76+
key: ${{ steps.restore-cached-ucm.outputs.cache-primary-key }}

install-ucm.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
release_file_name() {
6+
case "$UCM_RELEASE" in
7+
"release%2F0.5.25" | "release%2F0.5.26" | "release%2F0.5.27")
8+
echo "ucm-linux.tar.gz"
9+
;;
10+
*)
11+
echo "ucm-linux-x64.tar.gz"
12+
;;
13+
esac
14+
}
15+
16+
mkdir -p /opt/unisonlanguage
17+
18+
curl --fail-with-body -L "https://github.com/unisonweb/unison/releases/download/${UCM_RELEASE}/$(release_file_name)" | tar -xz -C /opt/unisonlanguage
19+
20+
ln -s /opt/unisonlanguage/ucm /usr/local/bin/ucm

run-tests.sh

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
set -euxo pipefail
44

5-
release_file_name() {
6-
case "$UCM_RELEASE" in
7-
"release%2F0.5.25" | "release%2F0.5.26" | "release%2F0.5.27")
8-
echo "ucm-linux.tar.gz"
9-
;;
10-
*)
11-
echo "ucm-linux-x64.tar.gz"
12-
;;
13-
esac
14-
}
15-
16-
curl --fail-with-body -L "https://github.com/unisonweb/unison/releases/download/${UCM_RELEASE}/$(release_file_name)" | tar -xz
17-
185
envsubst < cloud-tests.tpl.md > cloud-tests.md
196

207
exit_status=0
218

22-
./ucm transcript cloud-tests.md || exit_status=$?
9+
ucm transcript cloud-tests.md || exit_status=$?
2310
cat cloud-tests.output.md
2411

2512
exit "$exit_status"

0 commit comments

Comments
 (0)