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

examples: Add opam example #1439

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Add opam example
  • Loading branch information
rusty-key authored Jul 23, 2024
commit 0b16518fffd895fbef333c83f4e76a9f4565bf40
25 changes: 25 additions & 0 deletions examples.md
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
- [Node - Yarn](#node---yarn)
- [Node - Yarn 2](#node---yarn-2)
- [OCaml/Reason - esy](#ocamlreason---esy)
- [OCaml/Reason - opam](#ocamlreason---opam)
- [PHP - Composer](#php---composer)
- [Python - pip](#python---pip)
- [Simple example](#simple-example)
@@ -416,6 +417,30 @@ Esy allows you to export built dependencies and import pre-built dependencies.
if: steps.restore-cache.outputs.cache-hit != 'true'
```

## OCaml/Reason - opam

This example requires you to have `opam.locked` file which you can generate with `opam lock .`.

It's worth noting that even if lock file was change, it might be optimal to restore previous cache, so `hashFiles` in the key and if statement in "Save opam cache" step are optional.
```yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the separate steps for restore and save needed here?

The default action will add a save post step automatically for you and handle checking the cache-hit output.

    - name: Cache opam
      uses: actions/cache@v4
      with:
        path: _opam
        key: ${{ runner.os }}-opam-${{ hashFiles('opam.locked') }}

    - name: Install dependencies
      run: opam install . --locked --deps-only -y

- name: Restore opam cache
id: restore-cache
uses: actions/cache/restore@v4
with:
path: _opam
key: ${{ runner.os }}-opam-${{ hashFiles('opam.locked') }}

- name: Install dependencies
run: opam install . --locked --deps-only -y

- name: Save opam cache
if: steps.restore-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: _opam
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
```

## PHP - Composer

```yaml