Skip to content

Commit

Permalink
Merge pull request #403 from nberth/cache-fix
Browse files Browse the repository at this point in the history
Cache the local opam switch in CI workflows
  • Loading branch information
nberth authored Feb 5, 2025
2 parents e52e732 + 1339d3b commit 63ac90c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .drom

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,36 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Retrieve opam cache
uses: actions/cache@v4
id: cache-opam
with:
path: ~/.opam
key: v4-${{ runner.os }}-superbol-studio-oss-${{ matrix.ocaml-compiler }}-${{ hashFiles('opam/*.opam') }}-skip_tests=${{ matrix.skip_test }}-repo=
- name: Set git user
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: avsm/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
opam-pin: false

- name: Set git user
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
- name: Retrieve cache of local opam switch
uses: actions/cache@v4
id: cache-opam
with:
path: _opam
key: v4-${{ runner.os }}-superbol-studio-oss-${{ matrix.ocaml-compiler }}-${{ hashFiles('opam/*.opam') }}-skip_tests=${{ matrix.skip_test }}-repo=

# use fields.opam-repo = "git+https://" to add an 'extra' opam repository

- run: opam pin add . -y --no-action
if: ${{ ! steps.cache-opam.outputs.cache-hit }}

# - run: opam depext -y superbol-studio-oss superbol-vscode-platform interop-js-stubs node-js-stubs vscode-js-stubs vscode-languageclient-js-stubs vscode-json vscode-debugadapter vscode-debugprotocol superbol-free superbol_free_lib superbol_preprocs superbol_project cobol_common cobol_parser cobol_ptree ebcdic_lib cobol_lsp ppx_cobcflags pretty cobol_config cobol_indent cobol_indent_old cobol_preproc cobol_data cobol_typeck cobol_unit ez_toml ezr_toml sql_ast sql_parser cobol_cfg
# if: ${{ ! steps.cache-opam.outputs.cache-hit }}

- run: |
if ${{ matrix.skip_test }}
then opam install -y opam/*.opam --deps-only
else opam install -y opam/*.opam --deps-only --with-test
fi
if: ${{ ! steps.cache-opam.outputs.cache-hit }}
if: steps.cache-opam.outputs.cache-hit != 'true'
name: Run opam install -y opam/*.opam --deps-only [ --with-test ]
# - run: opam upgrade --fixup
# if: steps.cache-opam.outputs.cache-hit

# Use fields.build-scripts to add more scripts to convert here
- run: dos2unix scripts/*.sh
if: matrix.os == 'windows-latest'
Expand Down Expand Up @@ -160,3 +153,10 @@ jobs:

# Use fields.github-workflow-trailer to add a trailer here


- name: Cleanup local opam switch before caching
run: |
opam pin remove . --yes
opam clean --switch-cleanup --logs
find _opam -type f -a \( -name '*.cmt' -o -name '*.cmti' \) -delete
if: steps.cache-opam.outputs.cache-hit != 'true'
36 changes: 18 additions & 18 deletions .github/workflows/workflow.yml.drom-tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Retrieve opam cache
uses: actions/cache@v4
id: cache-opam
with:
path: ~/.opam
key: v4-${{ runner.os }}-!{name}-${{ matrix.ocaml-compiler }}-${{ hashFiles('opam/*.opam') }}-skip_tests=${{ matrix.skip_test }}-repo=!(opam-repo)
- name: Set git user
run: |
git config --global user.name github-actions
git config --global user.email [email protected]

- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: avsm/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
opam-pin: false

- name: Set git user
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
- name: Retrieve cache of local opam switch
uses: actions/cache@v4
id: cache-opam
with:
path: _opam
key: v4-${{ runner.os }}-!{name}-${{ matrix.ocaml-compiler }}-${{ hashFiles('opam/*.opam') }}-skip_tests=${{ matrix.skip_test }}-repo=!(opam-repo)

# use fields.opam-repo = "git+https://" to add an 'extra' opam repository
![if:field:opam-repo]
Expand All @@ -64,22 +64,15 @@ jobs:

![fi]
- run: opam pin add . -y --no-action
if: ${{ ! steps.cache-opam.outputs.cache-hit }}

# - run: opam depext -y !{packages}
# if: ${{ ! steps.cache-opam.outputs.cache-hit }}

- run: |
if ${{ matrix.skip_test }}
then opam install -y opam/*.opam --deps-only
else opam install -y opam/*.opam --deps-only --with-test
fi
if: ${{ ! steps.cache-opam.outputs.cache-hit }}
if: steps.cache-opam.outputs.cache-hit != 'true'
name: Run opam install -y opam/*.opam --deps-only [ --with-test ]

# - run: opam upgrade --fixup
# if: steps.cache-opam.outputs.cache-hit

# Use fields.build-scripts to add more scripts to convert here
- run: dos2unix scripts/*.sh !(build-scripts)
if: matrix.os == 'windows-latest'
Expand Down Expand Up @@ -125,3 +118,10 @@ jobs:

# Use fields.github-workflow-trailer to add a trailer here
!(github-workflow-trailer)

- name: Cleanup local opam switch before caching
run: |
opam pin remove . --yes
opam clean --switch-cleanup --logs
find _opam -type f -a \( -name '*.cmt' -o -name '*.cmti' \) -delete
if: steps.cache-opam.outputs.cache-hit != 'true'

0 comments on commit 63ac90c

Please sign in to comment.