diff --git a/buildkite/src/Jobs/Lint/Fast.dhall b/buildkite/src/Jobs/Lint/Fast.dhall index 7c4649f975b..d9645e5b545 100644 --- a/buildkite/src/Jobs/Lint/Fast.dhall +++ b/buildkite/src/Jobs/Lint/Fast.dhall @@ -32,8 +32,6 @@ in Pipeline.build S.strictly (S.contains "Makefile"), S.strictlyStart (S.contains "src/"), S.strictlyStart (S.contains "rfcs/"), - S.exactly "scripts/compare_ci_diff_types" "sh", - S.exactly "scripts/compare_ci_diff_binables" "sh", S.exactly "scripts/check-snarky-submodule" "sh" ] , path = "Lint" @@ -51,31 +49,5 @@ in Pipeline.build , image = (../../Constants/ContainerImages.dhall).toolchainBase } } - , Command.build - Command.Config::{ - , commands = - RunInToolchain.runInToolchain - [ "CI=true" - , "BASE_BRANCH_NAME=\$BUILDKITE_PULL_REQUEST_BASE_BRANCH" - ] - "./scripts/compare_ci_diff_types.sh" - , label = "Versions compatibility linter" - , key = "lint-types" - , target = Size.Medium - , docker = None Docker.Type - } - , Command.build - Command.Config::{ - , commands = - RunInToolchain.runInToolchain - [ "CI=true" - , "BASE_BRANCH_NAME=\$BUILDKITE_PULL_REQUEST_BASE_BRANCH" - ] - "./scripts/compare_ci_diff_binables.sh" - , label = "Binable compatibility linter" - , key = "lint-binable" - , target = Size.Medium - , docker = None Docker.Type - } ] } diff --git a/scripts/compare_binables.py b/scripts/compare_binables.py deleted file mode 100755 index 6383dbef66d..00000000000 --- a/scripts/compare_binables.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python3 - -# compare representations of binable functors in OCaml files - -# expects two Ocaml files possibly containing included binable functors -# -# the first file is the original, the second is the modified file - -import sys - -from compare_versioned_items import run_comparison - -if __name__ == "__main__": - if len(sys.argv) != 3 or sys.argv[1] == sys.argv[2] : - print("Usage: %s path1-to-file.ml path2-to-file.ml" % sys.argv[0], file=sys.stderr) - print("The .ml files must have the same name, with different paths") - sys.exit(1) - - run_comparison('_build/default/src/lib/ppx_version/tools/print_binable_functors.exe','Binable functors',sys.argv[1],sys.argv[2]) diff --git a/scripts/compare_ci_diff_binables.sh b/scripts/compare_ci_diff_binables.sh deleted file mode 100755 index 19fbb6c2094..00000000000 --- a/scripts/compare_ci_diff_binables.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -if [ ! "$CI" = "true" ] || [ ! -f /.dockerenv ]; then - echo `basename $0` "can run only in Circle CI" - exit 1 -fi - -# cleanup if needed - -git clean -dfx -rm -rf base - -# build print_binable_functors, then run Python script to compare binable functors in a pull request -source ~/.profile && \ - (dune build --profile=dev src/lib/ppx_version/tools/print_binable_functors.exe) && \ - ./scripts/compare_pr_diff_binables.py ${BASE_BRANCH_NAME:-develop} diff --git a/scripts/compare_ci_diff_types.sh b/scripts/compare_ci_diff_types.sh deleted file mode 100755 index f75e47eb69e..00000000000 --- a/scripts/compare_ci_diff_types.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -# build print_versioned_types, then run Python script to compare versioned types in a pull request -source ~/.profile && \ - (dune build --profile=dev src/lib/ppx_version/tools/print_versioned_types.exe) && \ - ./scripts/compare_pr_diff_types.py ${BASE_BRANCH_NAME:-develop} diff --git a/scripts/compare_ci_diff_types_develop.sh b/scripts/compare_ci_diff_types_develop.sh deleted file mode 100755 index 51240b05332..00000000000 --- a/scripts/compare_ci_diff_types_develop.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -if [ ! "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" = "compatible" ]; then - exit 0 -fi - -# Exports to let Buildkite run the CircleCI scripts -export CI=true -export BASE_BRANCH_NAME="$BUILDKITE_PULL_REQUEST_BASE_BRANCH" - -./scripts/compare_ci_diff_types.sh -./scripts/compare_ci_diff_binables.sh diff --git a/scripts/compare_pr_diff_binables.py b/scripts/compare_pr_diff_binables.py deleted file mode 100755 index 516c4dffc8a..00000000000 --- a/scripts/compare_pr_diff_binables.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python3 - -# compare representations of binable functors in OCaml files in a Github pull request - -# in CI, this script is run from git root of the PR branch - -import sys - -from compare_pr_diff_items import run_comparison - -if __name__ == "__main__": - if len(sys.argv) != 2 : - print("Usage: %s base-branch" % sys.argv[0], file=sys.stderr) - sys.exit(1) - - run_comparison(sys.argv[1],'compare_binables.py') diff --git a/scripts/compare_pr_diff_items.py b/scripts/compare_pr_diff_items.py deleted file mode 100755 index 82ee68c4912..00000000000 --- a/scripts/compare_pr_diff_items.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 - -# compare representations of versioned items in OCaml files in a Github pull request - -import os -import sys -import shutil -import subprocess - -exit_code = 0 - - -def run_comparison(base_commit, compare_script): - cwd = os.getcwd() - # create a copy of the repo at base branch - if os.path.exists('base'): - shutil.rmtree('base') - os.mkdir('base') - os.chdir('base') - # it would be faster to do a clone of the local repo, but there's "smudge error" (?) - subprocess.run(['git', 'clone', 'https://github.com/MinaProtocol/mina.git']) - os.chdir('mina') - subprocess.run(['git', 'checkout', base_commit]) - os.chdir(cwd) - # changed files in the PR - diffs_raw = subprocess.check_output( - ['git', 'diff', '--name-only', 'origin/' + base_commit]) - diffs_decoded = diffs_raw.decode('UTF-8') - diffs = diffs_decoded.split('\n') - for diff in diffs: - fn = os.path.basename(diff) - if not fn.endswith('.ml'): - continue - orig = 'base/mina/' + diff - # don't compare if file added or deleted - if not (os.path.exists(orig) and os.path.exists(diff)): - continue - completed_process = subprocess.run( - ['./scripts/' + compare_script, orig, diff]) - if not completed_process.returncode == 0: - global exit_code - exit_code = 1 - sys.exit(exit_code) diff --git a/scripts/compare_pr_diff_types.py b/scripts/compare_pr_diff_types.py deleted file mode 100755 index e2618a165cf..00000000000 --- a/scripts/compare_pr_diff_types.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python3 - -# compare representations of versioned types in OCaml files in a Github pull request - -# in CI, this script is run from git root of the PR branch - -import sys - -from compare_pr_diff_items import run_comparison - -if __name__ == "__main__": - if len(sys.argv) != 2 : - print("Usage: %s base-branch" % sys.argv[0], file=sys.stderr) - sys.exit(1) - - run_comparison(sys.argv[1],'compare_versioned_types.py') diff --git a/scripts/compare_versioned_items.py b/scripts/compare_versioned_items.py deleted file mode 100755 index 8869fb91158..00000000000 --- a/scripts/compare_versioned_items.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python3 - -# compare representations of versioned items in OCaml files - -# expects two Ocaml files possibly containing versioned items (types, binable functors) -# -# the first file is the original, the second is the modified file - -# for each file, we create a dictionary mapping module-paths to the items -# since we want to detect changes, we run this algorithm -# for each item in the first file -# if item from the second file is different, there's an error -# if there is no item in the second file, that's OK (we can't serialize that type) -# new items in the second file are OK, we didn't change an existing serialization - -import os -import sys -import subprocess -import tempfile - -exit_code = 0 - -def create_dict (items_file) : - with open (items_file, 'r') as fp : - items = {} - line = fp.readline() - while line: - line = line.strip (' \n') - fields = line.split(':',1) - items[fields[0]] = fields[1] - line = fp.readline() - return items - -# expects files containing lines of the form -# path:item -def compare_items (item_kind,fn,original,modified) : - items_orig = create_dict (original) - items_mod = create_dict (modified) - for path in items_orig : - orig = items_orig[path] - try : - mod = items_mod[path] - except : - mod = None - if not (mod is None or mod == orig) : - print ('In file: ' + fn) - print (' ' + item_kind + ' changed at path: ' + path) - print (' Was: ' + orig) - print (' Now: ' + mod) - global exit_code - exit_code = 1 - -def create_items_file (printer,ocaml,tag) : - out_fn = os.path.basename (ocaml) + '-' + tag - if os.path.exists(out_fn) : - os.remove(out_fn) - with open (out_fn, 'w') as fp : - retval = subprocess.run([printer,ocaml,'-o','/dev/null'],stdout=fp); - # script should fail if printer fails - retval.check_returncode () - return out_fn - -def run_comparison (printer,item_kind,original,modified) : - orig_items = create_items_file (printer,original,'original') - mod_items = create_items_file (printer,modified,'modified') - compare_items (item_kind,modified,orig_items,mod_items) - sys.exit (exit_code) diff --git a/scripts/compare_versioned_types.py b/scripts/compare_versioned_types.py deleted file mode 100755 index ac562c1c035..00000000000 --- a/scripts/compare_versioned_types.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python3 - -# compare representations of versioned types in OCaml files - -# expects two Ocaml files possibly containing versioned types -# -# the first file is the original, the second is the modified file - -import sys - -from compare_versioned_items import run_comparison - -if __name__ == "__main__": - if len(sys.argv) != 3 or sys.argv[1] == sys.argv[2] : - print("Usage: %s path1-to-file.ml path2-to-file.ml" % sys.argv[0], file=sys.stderr) - print("The .ml files must have the same name, with different paths") - sys.exit(1) - - run_comparison('_build/default/src/lib/ppx_version/tools/print_versioned_types.exe','Versioned types',sys.argv[1],sys.argv[2]) diff --git a/scripts/version-linter.py b/scripts/version-linter.py index 74c0e44a461..8b334f8f213 100755 --- a/scripts/version-linter.py +++ b/scripts/version-linter.py @@ -188,6 +188,8 @@ def check_type_shapes(pr_branch_dict,base_branch,base_type_dict,release_branch,r base_branch=sys.argv[2] release_branch=sys.argv[3] + subprocess.run(['git','fetch'],capture_output=False) + base_branch_commit=branch_commit(base_branch) download_type_shapes('base',base_branch,base_branch_commit) diff --git a/src/lib/ppx_version/tools/dune b/src/lib/ppx_version/tools/dune deleted file mode 100644 index 5205c3bed88..00000000000 --- a/src/lib/ppx_version/tools/dune +++ /dev/null @@ -1,59 +0,0 @@ -(executable - (name print_versioned_types) - (modules print_versioned_types) - (libraries - ;; opam libraries - base - core_kernel - ppxlib - ppxlib.astlib - ;; every deriver we might encounter - ppx_bin_prot - lens.ppx_deriving - ppx_deriving.std - ppx_sexp_conv - ppx_compare - ppx_enumerate - ppx_fields_conv - ppx_hash - ppx_variants_conv - ppx_deriving_yojson - base_quickcheck.ppx_quickcheck - ;; local derivers - ppx_mina - h_list.ppx - ppx_annot - ppx_dhall_type - ppx_version - ) - (preprocess (pps ppxlib.metaquot))) - -(executable - (name print_binable_functors) - (modules print_binable_functors) - (libraries - ;; opam libraries - base - core_kernel - ppxlib - ppxlib.astlib - ;; every deriver we might encounter - ppx_bin_prot - lens.ppx_deriving - ppx_deriving.std - ppx_sexp_conv - ppx_compare - ppx_enumerate - ppx_fields_conv - ppx_hash - ppx_variants_conv - ppx_deriving_yojson - base_quickcheck.ppx_quickcheck - ;; local derivers - ppx_mina - h_list.ppx - ppx_annot - ppx_dhall_type - ppx_version - ) - (preprocess (pps ppxlib.metaquot))) diff --git a/src/lib/ppx_version/tools/print_binable_functors.ml b/src/lib/ppx_version/tools/print_binable_functors.ml deleted file mode 100644 index 6889e32c153..00000000000 --- a/src/lib/ppx_version/tools/print_binable_functors.ml +++ /dev/null @@ -1,106 +0,0 @@ -(* print_binable_functors.ml *) - -(* print out applications of functors Binable.Of... or Bin_prot.Utils.Make_binable - - within a versioned type, these should not change - and they should always appear within a versioned type -*) - -open Core_kernel -open Ppxlib -open Ppx_version -open Versioned_util - -let name = "print_binable_functors" - -type accumulator = { module_path : string list } - -let is_included_binable_functor_app (inc_decl : include_declaration) = - let of_binable_pattern = - Ast_pattern.( - pmod_apply - (pmod_apply (pmod_ident (ldot (lident (string "Binable")) __)) __) - __) - in - let of_binable = - match - parse_opt of_binable_pattern Location.none inc_decl.pincl_mod - (fun ftor _ _ -> Some ftor) - with - | Some ftor -> - List.mem - [ "Of_binable" - ; "Of_binable_without_uuid" - ; "Of_binable1" - ; "Of_binable1_without_uuid" - ; "Of_binable2" - ; "Of_binable2_without_uuid" - ; "Of_binable3" - ; "Of_binable3_without_uuid" - ; "Of_sexpable" - ; "Of_sexpable_without_uuid" - ; "Of_stringable" - ; "Of_stringable_without_uuid" - ] - ftor ~equal:String.equal - | _ -> - false - in - let make_binable_pattern = - Ast_pattern.( - pmod_apply - (pmod_ident - (ldot - (ldot (lident (string "Bin_prot")) (string "Utils")) - (string "Make_binable") ) ) - __) - in - let make_binable = - Option.is_some - (parse_opt make_binable_pattern Location.none inc_decl.pincl_mod (fun _ -> - Some () ) ) - in - of_binable || make_binable - -let print_included_binable_functor_app ~path inc = - let path_len = List.length path in - List.iteri path ~f:(fun i s -> - printf "%s" s ; - if i < path_len - 1 then printf "." ) ; - printf ":%!" ; - let formatter = Versioned_util.diff_formatter Format.std_formatter in - Pprintast.structure_item formatter inc ; - Format.pp_print_flush formatter () ; - printf "\n%!" - -let traverse_ast = - object (self) - inherit [accumulator] Ast_traverse.fold as super - - method! structure_item stri acc = - match stri.pstr_desc with - | Pstr_module { pmb_name = { txt = Some name; _ }; pmb_expr; _ } -> - ignore - (self#module_expr pmb_expr - { module_path = name :: acc.module_path } ) ; - acc - | Pstr_extension ((name, _payload), _attrs) - when List.mem - [ "test"; "test_unit"; "test_module" ] - name.txt ~equal:String.equal -> - (* don't print functors in test code *) - acc - | Pstr_include inc_decl when is_included_binable_functor_app inc_decl -> - print_included_binable_functor_app ~path:acc.module_path stri ; - acc - | _ -> - super#structure_item stri acc - end - -let preprocess_impl str = - ignore (traverse_ast#structure str { module_path = [] }) ; - str - -let () = - Ppxlib.Driver.register_transformation name ~preprocess_impl ; - Ppxlib.Driver.standalone () diff --git a/src/lib/ppx_version/tools/print_versioned_types.ml b/src/lib/ppx_version/tools/print_versioned_types.ml deleted file mode 100644 index 5c108f16cb0..00000000000 --- a/src/lib/ppx_version/tools/print_versioned_types.ml +++ /dev/null @@ -1,5 +0,0 @@ -(* print_versioned_types.ml *) - -let () = - Ppx_version.Versioned_type.set_printing () ; - Ppxlib.Driver.standalone ()