Skip to content

Commit a650146

Browse files
committed
Cache Hurl binary in CI
1 parent fe13e4a commit a650146

1 file changed

Lines changed: 40 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ concurrency:
2626

2727
env:
2828
CARGO_TERM_COLOR: always
29+
HURL_VERSION: 8.0.0
2930
REGISTRY_USERNAME: lovasoa
3031
REGISTRY_IMAGE: lovasoa/sqlpage
3132

@@ -426,6 +427,32 @@ jobs:
426427
run: |
427428
examples="$(find examples -mindepth 2 -maxdepth 2 -name test.hurl -print | sed 's#/test.hurl$##' | sort | jq -R -s -c 'split("\n")[:-1]')"
428429
echo "examples=$examples" >> "$GITHUB_OUTPUT"
430+
- name: Restore Hurl archive
431+
id: hurl-cache
432+
uses: actions/cache@v5
433+
with:
434+
path: .cache/hurl
435+
key: hurl-${{ runner.os }}-x86_64-unknown-linux-gnu-${{ env.HURL_VERSION }}
436+
- name: Download Hurl archive
437+
if: steps.hurl-cache.outputs.cache-hit != 'true'
438+
run: |
439+
set -euo pipefail
440+
archive="hurl-${HURL_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
441+
base_url="https://github.com/Orange-OpenSource/hurl/releases/download/${HURL_VERSION}"
442+
mkdir -p .cache/hurl
443+
curl --fail --location --retry 5 --retry-delay 2 --output ".cache/hurl/${archive}" "${base_url}/${archive}"
444+
curl --fail --location --retry 5 --retry-delay 2 --output ".cache/hurl/${archive}.sha256" "${base_url}/${archive}.sha256"
445+
(
446+
cd .cache/hurl
447+
sha256sum --check "${archive}.sha256"
448+
)
449+
- name: Upload Hurl archive
450+
uses: actions/upload-artifact@v7
451+
with:
452+
name: hurl-${{ env.HURL_VERSION }}-x86_64-unknown-linux-gnu
453+
path: .cache/hurl/*
454+
if-no-files-found: error
455+
retention-days: 1
429456

430457
hurl:
431458
name: hurl (${{ matrix.example }})
@@ -440,15 +467,21 @@ jobs:
440467
example: ${{ fromJSON(needs.hurl_examples.outputs.examples) }}
441468
steps:
442469
- uses: actions/checkout@v6
470+
- name: Download Hurl archive
471+
uses: actions/download-artifact@v8
472+
with:
473+
name: hurl-${{ env.HURL_VERSION }}-x86_64-unknown-linux-gnu
474+
path: ${{ runner.temp }}/hurl
443475
- name: Install Hurl
444-
env:
445-
GH_TOKEN: ${{ github.token }}
446476
run: |
447-
version=8.0.0
448-
archive="hurl-${version}-x86_64-unknown-linux-gnu.tar.gz"
449-
gh release download "$version" --repo Orange-OpenSource/hurl --pattern "$archive" --dir /tmp
450-
tar xzf "/tmp/$archive" -C /tmp
451-
echo "/tmp/hurl-${version}-x86_64-unknown-linux-gnu/bin" >> "$GITHUB_PATH"
477+
set -euo pipefail
478+
archive="hurl-${HURL_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
479+
(
480+
cd "$RUNNER_TEMP/hurl"
481+
sha256sum --check "${archive}.sha256"
482+
tar xzf "$archive" -C "$RUNNER_TEMP/hurl"
483+
)
484+
echo "$RUNNER_TEMP/hurl/hurl-${HURL_VERSION}-x86_64-unknown-linux-gnu/bin" >> "$GITHUB_PATH"
452485
- name: Download SQLPage image
453486
uses: actions/download-artifact@v8
454487
with:

0 commit comments

Comments
 (0)