-
Notifications
You must be signed in to change notification settings - Fork 1
139 lines (114 loc) · 3.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
name: CI
on:
pull_request:
push:
branches: main
tags: ["**"]
workflow_dispatch:
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: password
services:
database:
image: mariadb:10.6
env:
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
ports: ['3306:3306']
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
ocaml-compiler: [4.14.x]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use OCaml ${{ matrix.ocaml-version }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: true
opam-pin: true
opam-depext: false
- name: Install system dependencies
run: sudo apt-get update -y && sudo apt-get install -y libmariadb-dev
- name: Pin current guardian
run: |
opam pin add -yn guardian .
OPAMSOLVERTIMEOUT=180 opam depext --with-test --with-doc -y guardian
- name: Install dependencies
run: opam install --deps-only --with-test --with-doc -y .
- name: Build
run: |
make build
- name: Check formatting
run: |
opam install -y ocamlformat
make format
- name: Run tests
env:
DATABASE_URL: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@127.0.0.1:3306/${{ env.MYSQL_DATABASE }}
run: make test
- name: Build documentation
run: |
make doc
- uses: actions/upload-artifact@v3
with:
name: documentation
path: _build/default/_doc/_html
- uses: actions/upload-artifact@v3
if: failure()
with:
name: tests
path: _build/default/test/_build/_tests/
- name: Notify about failure
if: failure()
uses: ./.github/actions/notify-failure
with:
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }}
deploy-doc:
name: Deploy documentation
runs-on: ubuntu-latest
needs: [build]
if: github.ref_name == 'main'
environment:
name: github-pages
url: ${{ steps.deploy-doc.outputs.page_url }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Deploy odoc to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ github.token }}
publish_dir: documentation
- name: Notify about failure
if: failure()
uses: ./.github/actions/notify-failure
with:
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }}
release:
name: Release a new version
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Extract version changelog
run: sed -nr "/^## .?v?${GITHUB_REF_NAME}/,/^## /p" CHANGELOG.md | sed '1d;2d;$d' > changes.md
- name: Create release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
body_path: changes.md
- name: Notify about failure
if: failure()
uses: ./.github/actions/notify-failure
with:
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }}