-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (113 loc) · 3.61 KB
/
ocaml.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
name: Main workflow
on:
pull_request:
branches: [main]
push:
branches: [main]
tags:
[
"v[0-9]+",
"v[0-9]+.[0-9]+",
"v[0-9]+.[0-9]+.[0-9]+",
"v[0-9]+.[0-9]+.[0-9]+-*",
]
jobs:
# We have two separate build jobs:
# - build-test-doc should run only once (one OS, one OCaml version), to avoid
# needlessly building the doc artifact repeatedly
# - build-test can run on as many version as we want
# - doc is also only run once, and only on push events, not on pull requests
build-test-doc:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
ocaml-compiler:
- 4.14.x
runs-on: ${{ matrix.os }}
outputs:
ref: ${{ steps.vars.outputs.ref }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
- name: Install dependencies
run: opam install . --deps-only --with-test
- name: Build library
run: opam exec -- dune build
- name: Run unit tests
run: opam exec -- dune test
- name: Build documentation
run: |
opam install . --deps-only --with-doc
opam exec -- dune build @doc
- id: vars
shell: bash
run: echo "ref=$(echo ${GITHUB_REF#refs/*/})" >> ${GITHUB_OUTPUT}
- uses: actions/upload-artifact@v4
if: github.event_name == 'push' &&
( github.ref == 'refs/heads/main' || startsWith(github.ref,'refs/tags') )
with:
name: doc-${{ steps.vars.outputs.ref }}
path: _build/default/_doc/_html/patricia-tree/
build-test:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
ocaml-compiler:
- 5.1.x
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
- name: Install dependencies
run: opam install . --deps-only --with-test
- name: Build library
run: opam exec -- dune build
- name: Run unit tests
run: opam exec -- dune test
doc:
needs: build-test-doc
if: github.event_name == 'push' &&
( github.ref == 'refs/heads/main' || startsWith(github.ref,'refs/tags') )
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Remove previous doc
run: rm -rf ${{ needs.build-test-doc.outputs.ref }}
- name: Retrieve new documentation
uses: actions/download-artifact@v4
with:
name: doc-${{ needs.build-test-doc.outputs.ref }}
path: ${{ needs.build-test-doc.outputs.ref }}
- name: Deploy documentation
run: |
git config user.email "${{ github.actor }}@users.noreply.github.com"
git config user.name "${{ github.actor }}"
git add ${{ needs.build-test-doc.outputs.ref }}
if ! git diff --cached --quiet --exit-code;
then
git commit -m "Deploy ${GITHUB_SHA}"
git push -f "https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git" gh-pages
else
echo "No changes to push"
fi