-
-
Notifications
You must be signed in to change notification settings - Fork 9
169 lines (140 loc) · 4.52 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
OPAM_VERSION: 2.3.0
DUNE_PROFILE: release
OCAMLRUNPARAM: b
permissions:
contents: write
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
defaults:
run:
shell: bash -xeuo pipefail {0}
jobs:
build:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
# - windows-latest
ocaml-compiler:
- 5.1.1
steps:
- uses: actions/checkout@v4
- name: Fix MacOS (by installing pkgconf) # https://github.com/ocaml/setup-ocaml/issues/897
if: matrix.os == 'macos-latest'
run: |
if ! brew list pkgconf &> /dev/null; then
brew update
brew upgrade
brew install pkgconf
brew link --overwrite pkgconf
fi
- name: Load opam cache
id: opam-cache
uses: actions/cache/restore@v4
with:
path: |
${{ runner.tool_cache }}/opam
~/.opam
_opam
.opam-path
key: opam-${{ matrix.os }}-${{ matrix.ocaml-compiler }}-${{ hashFiles('**.opam') }}
- name: Load npm cache
id: npm-cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
demo/node_modules
key: npm-${{ matrix.os }}-${{ hashFiles('package.json') }}
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/[email protected]
if: steps.opam-cache.outputs.cache-hit != 'true'
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: false
opam-disable-sandboxing: true
- name: Get OPAM executable path
if: steps.opam-cache.outputs.cache-hit != 'true'
uses: actions/github-script@v7
with:
script: |
const opam_path = await io.which('opam', true);
console.log('opam executable found: %s', opam_path);
const Fs = require('fs/promises');
await Fs.writeFile('.opam-path', opam_path, 'utf-8');
console.log('stored path to .opam-path');
- name: Use cached OPAM environment
# if: steps.opam-cache.outputs.cache-hit == 'true'
shell: bash
run: |
# https://github.com/ocaml/setup-ocaml/blob/b2105f9/packages/setup-ocaml/src/installer.ts#L33
echo "OPAMVERBOSE=$RUNNER_DEBUG" >> "$GITHUB_ENV"
echo "OPAMCOLOR=always" >> "$GITHUB_ENV"
echo "OPAMCONFIRMLEVEL=unsafe-yes" >> "$GITHUB_ENV"
echo "OPAMERRLOGLEN=0" >> "$GITHUB_ENV"
echo "OPAMPRECISETRACKING=1" >> "$GITHUB_ENV"
echo "OPAMYES=1" >> "$GITHUB_ENV"
echo "OPAMROOT=$HOME/.opam" >> "$GITHUB_ENV"
OPAM_PATH="$(cat .opam-path)"
chmod +x "$OPAM_PATH"
dirname "$OPAM_PATH" >> "$GITHUB_PATH"
- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: 'npm'
- name: Install opam deps
run: make install
- name: Install npm deps
# if: steps.npm-cache.outputs.cache-hit != 'true'
run: make install-npm
- name: Pin dependencies
if: steps.opam-cache.outputs.cache-hit != 'true'
run: make pin
- name: Build
run: make build
- name: Check formatting
run: make format-check
- name: Run tests
run: make test
- name: Generate docs
if: github.ref == 'refs/heads/main'
run: make docs
- name: Publish docs
uses: crazy-max/ghaction-github-pages@v1
if: github.ref == 'refs/heads/main'
with:
target_branch: gh-pages
build_dir: _build/default/_doc_new/html/docs/
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Run benchmarks
run: make bench
- name: Save opam cache
uses: actions/cache/save@v4
if: steps.opam-cache.outputs.cache-hit != 'true'
with:
path: |
${{ runner.tool_cache }}/opam
~/.opam
_opam
.opam-path
key: opam-${{ matrix.os }}-${{ matrix.ocaml-compiler }}-${{ hashFiles('**.opam') }}
- name: Save npm cache
uses: actions/cache/save@v4
with:
path: node_modules
key: npm-${{ matrix.os }}-${{ hashFiles('package.json') }}