Skip to content

Commit ed26e1b

Browse files
authored
Merge pull request #195 from shym/fix-caching-on-trunk
CI: Set caching based on the actual upstream compiler commit
2 parents 40e87c0 + 9dce707 commit ed26e1b

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

.github/workflows/common.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
description: 'Compiler to use'
1212
type: string
1313
default: 'ocaml-base-compiler.5.0.0~beta1'
14+
compiler_branch:
15+
description: 'Source branch of the compiler, to set up caching properly (must be set if CI is not using a tagged release of OCaml)'
16+
type: string
17+
default: ''
1418
timeout:
1519
description: 'Timeout'
1620
type: number
@@ -39,6 +43,7 @@ jobs:
3943
SEED: ${{ inputs.seed }}
4044
REPEATS: ${{ inputs.repeats }}
4145
OCAML_COMPILER_COMMIT: ${{ inputs.compiler_commit }}
46+
OCAML_COMPILER_BRANCH: ${{ inputs.compiler_branch }}
4247

4348
runs-on: ${{ inputs.runs_on }}
4449

@@ -51,6 +56,17 @@ jobs:
5156
- name: Add dummy binaries to $PATH
5257
run: echo "PATH=$GITHUB_WORKSPACE/.github/bin:$PATH" >> $GITHUB_ENV
5358

59+
- name: Pick up a robust cache prefix
60+
id: compute_prefix
61+
shell: bash
62+
run: |
63+
if [ -n "$OCAML_COMPILER_BRANCH" ]; then
64+
echo "cache_prefix=$(curl -sH "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/ocaml/ocaml/commits/$OCAML_COMPILER_BRANCH" | jq -r .commit.tree.sha)" >> "$GITHUB_OUTPUT"
65+
else
66+
echo "cache_prefix=v1" >> "$GITHUB_OUTPUT"
67+
fi
68+
cat "$GITHUB_OUTPUT"
69+
5470
- name: Install OCaml compiler ${{ inputs.compiler }}
5571
uses: ocaml/setup-ocaml@v2
5672
with:
@@ -60,6 +76,7 @@ jobs:
6076
alpha: https://github.com/kit-ty-kate/opam-alpha-repository.git
6177
opam-depext: false
6278
dune-cache: true
79+
cache-prefix: ${{ steps.compute_prefix.outputs.cache_prefix }}
6380

6481
- name: Override compiler to a particular commit
6582
if: inputs.compiler_commit != ''

.github/workflows/linux-500-bytecode-trunk-workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ jobs:
77
uses: ./.github/workflows/common.yml
88
with:
99
compiler: 'ocaml-variants.5.0.0+trunk,ocaml-option-bytecode-only'
10+
compiler_branch: '5.0'
1011
timeout: 360

.github/workflows/linux-500-trunk-workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ jobs:
77
uses: ./.github/workflows/common.yml
88
with:
99
compiler: 'ocaml-variants.5.0.0+trunk'
10+
compiler_branch: '5.0'

.github/workflows/macosx-500-trunk-workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ jobs:
77
uses: ./.github/workflows/common.yml
88
with:
99
compiler: 'ocaml-variants.5.0.0+trunk'
10+
compiler_branch: '5.0'
1011
runs_on: 'macos-latest'

0 commit comments

Comments
 (0)