...
 
Commits (7)
......@@ -31,6 +31,8 @@ docs/api/rpc.rst
docs/api/p2p.rst
src/bin_client/test/LOG.*
_coverage_output
_coverage_report
**/*.install
**/.merlin
......
......@@ -38,6 +38,8 @@ __pycache__
/docs/api/p2p.rst
/src/bin_client/test/LOG.*
/_coverage_output
/_coverage_report
*.install
.merlin
......
......@@ -56,6 +56,7 @@ check_linting:
script:
- src/tooling/lint.sh check.ci
- src/tooling/lint.sh check_scripts
- src/tooling/lint.sh check.ocamlformat
check_python_linting:
<<: *build_definition
......
......@@ -18,6 +18,8 @@ DOCKER_DEBUG_IMAGE_VERSION := latest
DOCKER_DEPS_IMAGE_NAME := registry.gitlab.com/tezos/opam-repository
DOCKER_DEPS_IMAGE_VERSION := ${opam_repository_tag}
DOCKER_DEPS_MINIMAL_IMAGE_VERSION := minimal--${opam_repository_tag}
COVERAGE_REPORT := _coverage_report
COVERAGE_OUTPUT := _coverage_output
ifeq ($(filter ${opam_version}.%,${current_opam_version}),)
$(error Unexpected opam version (found: ${current_opam_version}, expected: ${opam_version}.*))
......@@ -103,6 +105,29 @@ doc-html: all
doc-html-and-linkcheck: doc-html
@${MAKE} -C docs all
EXPECTED_BISECT_FILE := ${CURDIR}/${COVERAGE_OUTPUT}/bisect
.PHONY: coverage-setup
coverage-setup:
@mkdir -p ${COVERAGE_OUTPUT}
@echo "Before compiling, use ./scripts/instrument_dune_bisect.sh to add the"
@echo "bisect_ppx preprocessing directive to the dune files of the packages"
@echo "to be analyzed."
@echo
@echo "Examples:"
@echo " ./scripts/instrument_dune_bisect.sh src/lib_p2p/dune"
@echo " ./scripts/instrument_dune_bisect.sh src/proto_alpha/lib_protocol/dune.inc"
@echo
ifneq (${EXPECTED_BISECT_FILE}, ${BISECT_FILE})
@echo "Warning: BISECT_FILE isn't properly set. Run:"
@echo " export BISECT_FILE=${EXPECTED_BISECT_FILE}"
endif
.PHONY: coverage-report
coverage-report:
@bisect-ppx-report -ignore-missing-files -html ${COVERAGE_REPORT} ${COVERAGE_OUTPUT}/*.out
@echo "Report should be available in ${COVERAGE_REPORT}/index.html"
.PHONY: build-sandbox
build-sandbox:
@dune build src/bin_sandbox/main.exe
......@@ -191,8 +216,12 @@ install:
uninstall:
@dune uninstall
.PHONY: coverage-clean
coverage-clean:
@-rm -Rf ${COVERAGE_OUTPUT} ${COVERAGE_REPORT}
.PHONY: clean
clean:
clean: coverage-clean
@-dune clean
@-rm -f \
tezos-node \
......
......@@ -43,5 +43,5 @@ opam install --yes opam-depext
if [ -n "$dev" ]; then
opam repository add default --rank=-1 > /dev/null 2>&1 || true
opam install merlin odoc --criteria="-changed,-removed"
opam install merlin odoc bisect_ppx.1.4.2 --criteria="-changed,-removed"
fi
#!/bin/sh
readonly DIRECTIVE="(preprocess (pps bisect_ppx))"
readonly LINE_TO_ADD="$DIRECTIVE ; Added by $0"
usage () {
cat >&2 <<EOF
usage: $0 [FILES]
This script adds the line
$LINE_TO_ADD
to the library or executable stanzas of all Dune files passed
as parameters. It enables code covering instrumentation using
bisect_ppx.
EOF
}
if [ $# -eq 0 ]; then
usage
exit 1
fi
DUNE_FILES=[email protected]
for dune_file in $DUNE_FILES; do
if grep -Fq "$DIRECTIVE" $dune_file; then
echo "${dune_file}: directive already present in file. Skipping." >&2
continue
fi
tmp=$(mktemp)
# See this question for the Awk script
# https://stackoverflow.com/questions/9970124/sed-to-insert-on-first-match-only
awk "/public_name/ && !x {print \"$LINE_TO_ADD\"; x=0} 1" $dune_file > $tmp
if [ "$?" -ne 0 ]; then
echo "${dune_file}: unable to add directive to file. Skipping." >&2
rm $tmp
else
lines_before=`cat $dune_file | wc -l`
lines_after=`cat $tmp | wc -l`
lines_added=$((lines_after - lines_before))
mv $tmp $dune_file
echo "${dune_file}: added $lines_added time(s)."
fi
done
wrap-fun-args=false
let-binding-spacing=compact
field-space=loose
break-separators=after-and-docked
sequence-style=separator
doc-comments=before
margin=80
module-item-spacing=sparse
parens-tuple=always
parens-tuple-patterns=always
break-string-literals=newlines-and-wrap
wrap-fun-args=false
let-binding-spacing=compact
field-space=loose
break-separators=after-and-docked
sequence-style=separator
doc-comments=before
margin=80
module-item-spacing=sparse
parens-tuple=always
parens-tuple-patterns=always
break-string-literals=newlines-and-wrap
wrap-fun-args=false
let-binding-spacing=compact
field-space=loose
break-separators=after-and-docked
sequence-style=separator
doc-comments=before
margin=80
module-item-spacing=sparse
parens-tuple=always
parens-tuple-patterns=always
break-string-literals=newlines-and-wrap
......@@ -78,10 +78,10 @@ roll_repr.mli
roll_storage.ml
roll_storage.mli
script_expr_hash.ml
script_interpreter.ml
script_interpreter.mli
script_int_repr.ml
script_int_repr.mli
script_interpreter.ml
script_interpreter.mli
script_ir_annot.ml
script_ir_annot.mli
script_ir_translator.ml
......@@ -99,12 +99,12 @@ seed_storage.ml
seed_storage.mli
services_registration.ml
state_hash.ml
storage.ml
storage.mli
storage_description.ml
storage_description.mli
storage_functors.ml
storage_functors.mli
storage.ml
storage.mli
storage_sigs.ml
tez_repr.ml
tez_repr.mli
......
......@@ -78,10 +78,10 @@ roll_repr.mli
roll_storage.ml
roll_storage.mli
script_expr_hash.ml
script_interpreter.ml
script_interpreter.mli
script_int_repr.ml
script_int_repr.mli
script_interpreter.ml
script_interpreter.mli
script_ir_annot.ml
script_ir_annot.mli
script_ir_translator.ml
......@@ -99,12 +99,12 @@ seed_storage.ml
seed_storage.mli
services_registration.ml
state_hash.ml
storage.ml
storage.mli
storage_description.ml
storage_description.mli
storage_functors.ml
storage_functors.mli
storage.ml
storage.mli
storage_sigs.ml
tez_repr.ml
tez_repr.mli
......
......@@ -78,10 +78,10 @@ roll_repr.mli
roll_storage.ml
roll_storage.mli
script_expr_hash.ml
script_interpreter.ml
script_interpreter.mli
script_int_repr.ml
script_int_repr.mli
script_interpreter.ml
script_interpreter.mli
script_ir_annot.ml
script_ir_annot.mli
script_ir_translator.ml
......@@ -99,12 +99,12 @@ seed_storage.ml
seed_storage.mli
services_registration.ml
state_hash.ml
storage.ml
storage.mli
storage_description.ml
storage_description.mli
storage_functors.ml
storage_functors.mli
storage.ml
storage.mli
storage_sigs.ml
tez_repr.ml
tez_repr.mli
......
......@@ -78,10 +78,10 @@ roll_repr.mli
roll_storage.ml
roll_storage.mli
script_expr_hash.ml
script_interpreter.ml
script_interpreter.mli
script_int_repr.ml
script_int_repr.mli
script_interpreter.ml
script_interpreter.mli
script_ir_annot.ml
script_ir_annot.mli
script_ir_translator.ml
......@@ -99,12 +99,12 @@ seed_storage.ml
seed_storage.mli
services_registration.ml
state_hash.ml
storage.ml
storage.mli
storage_description.ml
storage_description.mli
storage_functors.ml
storage_functors.mli
storage.ml
storage.mli
storage_sigs.ml
tez_repr.ml
tez_repr.mli
......
......@@ -80,10 +80,10 @@ roll_repr.mli
roll_storage.ml
roll_storage.mli
script_expr_hash.ml
script_interpreter.ml
script_interpreter.mli
script_int_repr.ml
script_int_repr.mli
script_interpreter.ml
script_interpreter.mli
script_ir_annot.ml
script_ir_annot.mli
script_ir_translator.ml
......@@ -101,12 +101,12 @@ seed_storage.ml
seed_storage.mli
services_registration.ml
state_hash.ml
storage.ml
storage.mli
storage_description.ml
storage_description.mli
storage_functors.ml
storage_functors.mli
storage.ml
storage.mli
storage_sigs.ml
tez_repr.ml
tez_repr.mli
......
......@@ -80,10 +80,10 @@ roll_repr.mli
roll_storage.ml
roll_storage.mli
script_expr_hash.ml
script_interpreter.ml
script_interpreter.mli
script_int_repr.ml
script_int_repr.mli
script_interpreter.ml
script_interpreter.mli
script_ir_annot.ml
script_ir_annot.mli
script_ir_translator.ml
......@@ -101,12 +101,12 @@ seed_storage.ml
seed_storage.mli
services_registration.ml
state_hash.ml
storage.ml
storage.mli
storage_description.ml
storage_description.mli
storage_functors.ml
storage_functors.mli
storage.ml
storage.mli
storage_sigs.ml
tez_repr.ml
tez_repr.mli
......
alpha_context.ml
alpha_context.mli
alpha_services.ml
alpha_services.mli
amendment.ml
amendment.mli
apply.ml
apply_results.ml
apply_results.mli
baking.ml
baking.mli
blinded_public_key_hash.ml
blinded_public_key_hash.mli
block_header_repr.ml
block_header_repr.mli
bootstrap_storage.ml
bootstrap_storage.mli
commitment_repr.ml
commitment_repr.mli
commitment_storage.ml
commitment_storage.mli
constants_repr.ml
constants_services.ml
constants_services.mli
constants_storage.ml
contract_hash.ml
contract_repr.ml
contract_repr.mli
contract_services.ml
contract_services.mli
contract_storage.ml
contract_storage.mli
cycle_repr.ml
cycle_repr.mli
delegate_services.ml
delegate_services.mli
delegate_storage.ml
delegate_storage.mli
fees_storage.ml
fees_storage.mli
fitness_repr.ml
fitness_storage.ml
gas_limit_repr.ml
gas_limit_repr.mli
helpers_services.ml
helpers_services.mli
init_storage.ml
legacy_script_support_repr.ml
legacy_script_support_repr.mli
level_repr.ml
level_repr.mli
level_storage.ml
level_storage.mli
main.ml
main.mli
manager_repr.ml
manager_repr.mli
michelson_v1_gas.ml
michelson_v1_gas.mli
michelson_v1_primitives.ml
michelson_v1_primitives.mli
misc.ml
misc.mli
nonce_hash.ml
nonce_storage.ml
nonce_storage.mli
operation_repr.ml
operation_repr.mli
parameters_repr.ml
parameters_repr.mli
period_repr.ml
period_repr.mli
qty_repr.ml
raw_context.ml
raw_context.mli
raw_level_repr.ml
raw_level_repr.mli
roll_repr.ml
roll_repr.mli
roll_storage.ml
roll_storage.mli
script_expr_hash.ml
script_int_repr.ml
script_int_repr.mli
script_interpreter.ml
script_interpreter.mli
script_ir_annot.ml
script_ir_annot.mli
script_ir_translator.ml
script_ir_translator.mli
script_repr.ml
script_repr.mli
script_tc_errors.ml
script_tc_errors_registration.ml
script_timestamp_repr.ml
script_timestamp_repr.mli
script_typed_ir.ml
seed_repr.ml
seed_repr.mli
seed_storage.ml
seed_storage.mli
services_registration.ml
state_hash.ml
storage.ml
storage.mli
storage_description.ml
storage_description.mli
storage_functors.ml
storage_functors.mli
storage_sigs.ml
tez_repr.ml
tez_repr.mli
time_repr.ml
time_repr.mli
vote_repr.ml
vote_repr.mli
vote_storage.ml
vote_storage.mli
voting_period_repr.ml
voting_period_repr.mli
voting_services.ml
voting_services.mli
apply.ml
apply.mli
error.ml
error.mli
header.ml
header.mli
main.ml
main.mli
proto_operation.ml
proto_operation.mli
proto_params.ml
proto_params.mli
receipt.ml
receipt.mli
services.ml
services.mli
state.ml
state.mli
......@@ -8,6 +8,7 @@ Where <action> can be:
* update.ocamlformat: update all the \`.ocamlformat\` files and
git-commit (requires clean repo).
* check.ocamlformat: check the above does nothing.
* check.dune: check formatting while assuming running under Dune's
rule (\`dune build @runtest_lint\`).
* check.ci: check formatting using git (for GitLabCI's verbose run).
......@@ -61,7 +62,7 @@ EOF
source_directories="src docs/doc_gen"
update_all_dot_ocamlformats () {
interesting_directories=$(find $source_directories \( -name "*.ml" -o -name "*.mli" \) -type f | sed 's:/[^/]*$::' | sort -u)
interesting_directories=$(find $source_directories \( -name "*.ml" -o -name "*.mli" \) -type f | sed 's:/[^/]*$::' | LC_COLLATE=C sort -u)
if git diff --name-only HEAD --exit-code
then
say "Repository clean :thumbsup:"
......@@ -80,7 +81,7 @@ update_all_dot_ocamlformats () {
src/proto_*/lib_protocol )
say "This a protocol"
make_dot_ocamlformat "$ofmt"
( cd "$d" ; ls -1 *.mli *.ml > .ocamlformat-ignore ; )
( cd "$d" ; ls -1 *.mli *.ml | LC_COLLATE=C sort > .ocamlformat-ignore ; )
git add "$d/.ocamlformat-ignore"
;;
* )
......@@ -89,7 +90,6 @@ update_all_dot_ocamlformats () {
esac
git add "$ofmt"
done
git commit -m 'Update .ocamlformat files'
}
check_with_dune () {
......@@ -136,9 +136,21 @@ else
fi
fi
# $files may contain `*.pp.ml{i}` files which can't be linted. They are filtered
# by the following loop.
#
# Note: another option would be to filter them before calling the script but
# it was more convenient to do it here.
files=$(echo "$files" | sed "s/\S\+\.pp\.mli\?\b//g")
case "$action" in
"update.ocamlformat" )
update_all_dot_ocamlformats ;;
update_all_dot_ocamlformats
git commit -m 'Update .ocamlformat files' ;;
"check.ocamlformat" )
update_all_dot_ocamlformats
git diff --name-only HEAD --exit-code ;;
"check.dune" )
check_with_dune $files ;;
"check.ci" )
......