Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache the local opam switch in CI workflows #403

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'