forked from Kakadu/fp2024
-
Notifications
You must be signed in to change notification settings - Fork 0
231 lines (190 loc) · 8.01 KB
/
PR.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: Build PR
on:
pull_request:
branches:
- 'master'
env:
OPAMROOT: /home/user/.opam
OPAMCONFIRMLEVEL: unsafe-yes
jobs:
build:
runs-on: ubuntu-latest
container:
image: kakadu18/ocaml:fp2024
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Print
run: env | sort
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # fix me later
- name: Pin linter to the latest version
if: false # HACK!
run: |
opam pin add https://github.com/Kakadu/zanuda.git --no-action
opam reinstall zanuda --yes
- name: List installed OPAM packages
run: opam list
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
- name: Print Ref brach name
run: |
echo "${{ steps.branch-name.outputs.ref_branch }}"
#- run: git remote -vvv
#- run: git branch -vvv
# Outputs: "main"
############# Detecting and compiling fp2024
# Smart link about setting environment variables
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Detect latest directory with changes in ${{ github.event.repository.name }}
run: |
opam exec -- ocaml .github/detect_latest_pr.ml -v "pull/${{ steps.branch-name.outputs.ref_branch }}" -repo ${{ github.event.repository.name }} >> $GITHUB_ENV
echo "${{ env.latest }}"
#if: ${{ github.event.pull_request.user.login == 'fp2022-helper' }}
- name: Installing dependencies for ${{ env.latest }}
run: |
sudo apt-get update
opam update
opam install ./${{ env.latest }} --depext-only --with-test --with-doc
opam install ./${{ env.latest }} --deps-only --with-test --with-doc
- name: List installed OPAM packages
run: opam list
- name: Naive linting
run: |
cd ${{ env.latest }}
python ../.github/lint_filesystem.py ${{ env.latest }}
- name: Compiling ${{ env.latest }} (profile=dev)...
run: |
cd ${{ env.latest }}
opam exec -- dune build
- name: Running tests in ${{ env.latest }} (profile=dev)...
run: |
cd ${{ env.latest }}
opam exec -- dune runtest
- name: Compiling ${{ env.latest }} (profile=release)...
run: |
cd ${{ env.latest }}
opam exec -- dune build --profile=release
- name: Running tests in ${{ env.latest }}...
run: |
cd ${{ env.latest }}
opam exec -- dune runtest --profile=release
- name: Setting the environment
env:
LINTS_PATH: _build/default/_found_lints
run: |
echo "RDJSON_DIR_PATH=${{ env.LINTS_PATH }}" >> $GITHUB_ENV
echo "RDJSON_FILE_PATH=${{ env.LINTS_PATH }}/lints.rdjsonl" >> $GITHUB_ENV
cd ${{ env.latest }} && mkdir -p ${{ env.LINTS_PATH }}
echo "ZANUDA_REPORT_FILE_PATH=${{ env.LINTS_PATH }}/lints.txt" >> $GITHUB_ENV
- name: Running linter in ${{ env.latest }}...
run: |
cd ${{ env.latest }}
opam exec -- zanuda -dir . -add-prefix ${{ env.latest }}/ -no-no_toplevel_eval -ordjsonl ${{ env.RDJSON_FILE_PATH }} > ${{ env.ZANUDA_REPORT_FILE_PATH }}
- run: cat ${{ env.latest }}/${{ env.RDJSON_FILE_PATH }}
- name: Preparing lints tarball
run: |
echo ${{ env.latest }} > ${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/projectname.txt
echo ${{ github.event.pull_request.user.login }} > ${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/piarast.txt
echo ${{ github.event.number }} > ${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/PR_number.txt
echo ${{ github.event.pull_request.head.sha }} > ${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/CI_COMMIT.txt
# we use commit previous from head because HEAD is merge commit by some reason
# TODO: maybe PR_number is not required
- name: Upload linter (review.zip) artifact
uses: actions/upload-artifact@v4
with:
name: review
path: |
${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}
- run: echo $(git rev-parse HEAD)
- run: echo $(git rev-parse HEAD~1)
- run: echo ${{ github.event.pull_request.head.sha }}
- run: PAGER= git log
# Omitted. It is in docker image already
#- name: Installing a clone detector
# run: npm install jscpd
#- run: which jscpd || exit 0
#- run: ls ~/.local/bin || exit 0
#- run: pwd ~ || exit 0
- name: Looking for clones
if: false
run: |
echo ${{ env.latest }} > projectname.txt
python ./find_clones.py ${{ env.latest }}
#python3 -m trace --trace ./find_clones.py ${{ env.latest }}
- run: echo ${{ github.event.number }} > PR_number.txt
- run: cat jscpd_report.txt
if: false
- name: Update JSCPD artifact
uses: actions/upload-artifact@v4
if: false
with:
name: jscpd_report
path: |
jscpd_report.txt
PR_number.txt
projectname.txt
###################### Coverage #####################################
- name: Calculating coverage (1/2)
run: |
mkdir -p ${{ env.BISECT_DIR }}
cd ${{ env.latest }} && opam exec -- dune runtest --instrument-with bisect_ppx --force
env:
BISECT_DIR: /tmp/bisect_ppx_data
BISECT_FILE: /tmp/bisect_ppx_data/data
#- run: ls ${{ env.BISECT_DIR }}
# env:
# BISECT_DIR: /tmp/bisect_ppx_data
# BISECT_FILE: /tmp/bisect_ppx_data/data
- name: Calculating coverage (2/2)
id: calc-coverage
run: |
cd ${{ env.latest }}
mkdir -p ${{ env.BISECT_DIR }}
opam exec -- bisect-ppx-report html --coverage-path ${{ env.BISECT_DIR }}
opam exec -- bisect-ppx-report summary --coverage-path ${{ env.BISECT_DIR }}
opam exec -- bisect-ppx-report summary --coverage-path ${{ env.BISECT_DIR }} | cut -f3 | xargs -I{} echo "percent={}" >> $GITHUB_OUTPUT
opam exec -- bisect-ppx-report summary --coverage-path ${{ env.BISECT_DIR }} | cut -f3 -d' ' | xargs -I{} echo "{}" > _coverage/percent.txt
ls ${{ env.BISECT_DIR }}
ls _coverage
env:
BISECT_DIR: /tmp/bisect_ppx_data
BISECT_FILE: /tmp/bisect_ppx_data/data
- run: echo ${{ env.latest }} > ${{ env.latest }}/_coverage/projectname.txt
- name: Update coverage artifact ${{ steps.calc-coverage.outputs.percent }}
uses: actions/upload-artifact@v4
with:
name: coverage
path: ${{ env.latest }}/_coverage
###################### Upload Docs #####################################
- run: ls $(opam exec -- odig cache path)/html
continue-on-error: true
- name: Build API documentation for ${{ env.latest }}...
run: |
cd ${{ env.latest }}
opam exec -- dune b @install --profile=release
opam exec -- dune install
opam exec -- dune install
opam exec -- odig odoc --odoc-theme=odig.gruvbox.light --no-tag-index --no-pkg-deps ${{ env.latest }}
- run: ls $(opam exec -- odig cache path)/html
- name: Prepare artifact part for ${{ env.latest }} API ...
run: |
cp $(opam exec -- odig cache path)/html _html -r
rm _html/index.html
echo ${{ env.latest }} > projectname.txt
echo ${{ github.event.number }} > PR_number.txt
cp ${{ env.latest }}/_coverage/percent.txt percent.txt
- name: Update docs artifact
uses: actions/upload-artifact@v4
with:
name: docs
path: |
_html
projectname.txt
PR_number.txt
percent.txt
#${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/CI_COMMIT.txt