forked from OCamlPro/alt-ergo
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (82 loc) · 3.43 KB
/
linter.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
name: Linter
on: [push,pull_request]
env:
OCAML_DEFAULT_VERSION: 4.10.0
# Add OPAMYES=true to the environment, this is usefill to replace `-y` option
# in any opam call
OPAMYES: true
jobs:
check_indentation:
# Check that all `.ml` and `.mli` file are correctly indent with ocp-indent
name: Check indentation
strategy:
matrix:
ocp-indent-version:
# Fixed ocp-indent version. A PR with updated indented code is needed
# if this version is changed
- 1.8.1
runs-on: ubuntu-latest
steps:
# Checkout the code of the current branch
- name: Checkout code
uses: actions/checkout@v3
# Retrieve the opam cache with unique key
# A new cache is created/used if the `.opam` files changes or
# if we use another ocaml version
# This action only retrieve de .opam/ directory
- name: Retrieve opam cache
uses: actions/cache@v2
id: cache-opam
with:
path: ~/.opam
key: v1-${{ runner.os }}-alt-ergo-indentation-${{ env.OCAML_DEFAULT_VERSION }}-${{ hashFiles('*.opam') }}
# Get an OCaml environment with opam installed and the proper ocaml version
# opam will used opam cache environment if retrieved
- name: Use OCaml ${{ env.OCAML_DEFAULT_VERSION }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ env.OCAML_DEFAULT_VERSION }}
# Install ocp-indent with the fixed version
# Do nothing if ocp-indent is already installed
- name: Install ocp-indent ${{ matrix.ocp-indent-version }}
run: opam install ocp-indent.${{ matrix.ocp-indent-version }}
# Run indentation script, this script returns exit code 1 if some files
# are not well indented
- name: Run check_indentation.sh script
run: opam exec -- rsc/extra/check_indentation.sh
check_style:
# Check that all `.ml` and `.mli` files don't have line longer than
# 80 characters
name: Check style
runs-on: ubuntu-latest
steps:
# Checkout the code of the current branch
- name: Checkout code
uses: actions/checkout@v3
# Retrieve the opam cache with unique key
# A new cache is created/used if the `.opam` files changes or
# if we use another ocaml version
# This action only retrieve de .opam/ directory
- name: Retrieve opam cache
uses: actions/cache@v2
id: cache-opam
with:
path: ~/.opam
key: v1-${{ runner.os }}-alt-ergo-style-${{ env.OCAML_DEFAULT_VERSION }}-${{ hashFiles('*.opam') }}
# Get an OCaml environment with opam installed and the proper ocaml version
# opam will used opam cache environment if retrieved
- name: Use OCaml ${{ env.OCAML_DEFAULT_VERSION }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ env.OCAML_DEFAULT_VERSION }}
# Install dependencies of the ocpchecker executable
# Dune and stdlib-shims is needed to build the executable
# Since this executable has no opam file we need to manually add
# dependencies here
- name: opam install ocpchecker deps
run: opam install dune stdlib-shims
# Run check style script, this script build ocpchecker and run it on
# every *.ml and *.mli file, it returns exit code 1 if some files
# have line longer than 80 characters
- name: Run check_style.sh script
run: opam exec -- rsc/extra/check_style.sh