From 0d1df8361eb769e0bb9524cacbc6ab1cdabb6e7d Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 15:49:37 -0700 Subject: [PATCH 01/24] Split Makefile into smaller files --- Makefile.toml | 487 +----------------------------------- tools/scripts/data.toml | 76 ++++++ tools/scripts/tests.toml | 35 +++ tools/scripts/tidy.toml | 101 ++++++++ tools/scripts/valgrind.toml | 64 +++++ tools/scripts/wasm.toml | 221 ++++++++++++++++ 6 files changed, 501 insertions(+), 483 deletions(-) create mode 100644 tools/scripts/data.toml create mode 100644 tools/scripts/tests.toml create mode 100644 tools/scripts/tidy.toml create mode 100644 tools/scripts/valgrind.toml create mode 100644 tools/scripts/wasm.toml diff --git a/Makefile.toml b/Makefile.toml index 0f9239e5a12..df35f97d5d3 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -2,141 +2,14 @@ # called LICENSE at the top level of the ICU4X source tree # (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). +extend = [{ path = "./tools/scripts/data.toml"}, { path = "./tools/scripts/valgrind.toml"}, + { path = "./tools/scripts/tidy.toml"}, { path = "./tools/scripts/wasm.toml"}, + { path = "./tools/scripts/tests.toml"}] + [config] default_to_workspace = false load_cargo_aliases = true -### INDIVIDUAL TEST AND LINT TASKS ### -# Note: If a task is purely a cargo alias, define it in .cargo/config.toml - -[tasks.build-all-features] -description = "Build all permutations of all features" -category = "ICU4X Development" -install_crate = { crate_name = "cargo-all-features", binary = "cargo-build-all-features", test_arg = ["--help"] } -install_crate_args = ["--version", "^1.4"] -command = "cargo" -args = ["build-all-features"] - -[tasks.test-capi] -description = "Run C API tests" -category = "ICU4X Development" -script = ''' -cd ffi/capi/examples/pluralrules; -make -cd ../fixeddecimal; -make -cd ../locale; -make -''' - -[tasks.test-cpp] -description = "Run CPP tests" -category = "ICU4X Development" -script = ''' -cd ffi/cpp/examples/pluralrules; -make -cd ../fixeddecimal; -make -''' - -[tasks.license-header-check] -description = "Ensure all the source files have license headers" -category = "ICU4X Development" -script_runner = "@duckscript" -script = ''' -exit_on_error true - -glob_pattern_array = array "./**/*.rs" "./**/*.yml" "./**/*.toml" - -blank_line = set "" - -license_hash_line_1 = set "# This file is part of ICU4X. For terms of use, please see the file" -license_hash_line_2 = set "# called LICENSE at the top level of the ICU4X source tree" -license_hash_line_3 = set "# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE )." -license_hash_array = array ${license_hash_line_1} ${license_hash_line_2} ${license_hash_line_3} ${blank_line} -license_hash_str = array_join ${license_hash_array} "\n" - -license_slash_line_1 = set "// This file is part of ICU4X. For terms of use, please see the file" -license_slash_line_2 = set "// called LICENSE at the top level of the ICU4X source tree" -license_slash_line_3 = set "// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE )." -license_slash_array = array ${license_slash_line_1} ${license_slash_line_2} ${license_slash_line_3} ${blank_line} -license_slash_str = array_join ${license_slash_array} "\n" - -for pattern in ${glob_pattern_array} - handle = glob_array ${pattern} - for path in ${handle} - if not starts_with ${path} "target" # skip paths in target dir - text = readfile ${path} - result_hash = starts_with ${text} ${license_hash_str} - result_slash = starts_with ${text} ${license_slash_str} - not_result_hash = not ${result_hash} - not_result_slash = not ${result_slash} - if ${not_result_hash} and ${not_result_slash} - echo "License header missing in ${path}" - trigger_error "License header missing or misformatted in ${path}." - end - end - end - echo "License headers found in files matching ${pattern}" -end -echo "License header check complete" -''' - -[tasks.generate-readmes] -description = "Automatically generate README.md for each component." -category = "ICU4X Development" -script_runner = "@duckscript" -script = ''' -exit_on_error true - -glob_pattern = set "./**/Cargo.toml" -template = canonicalize README.tpl - -cargo_list = exec cargo --list -if not contains ${cargo_list.stdout} "readme" - trigger_error "Please run 'cargo install cargo-readme' to support generating README.md files" -end - -handle = glob_array ${glob_pattern} -for path in ${handle} - root_dir = dirname ${path} - if not is_empty ${root_dir} - echo "Automatically generating ${root_dir}/README.md" - exec --fail-on-error cargo readme -r ${root_dir} -o README.md -t ${template} - end -end -''' - -[tasks.generated-readme-check] -description = "Check that README.md was properly generated for each component." -category = "ICU4X Development" -dependencies = [ - "generate-readmes" -] -script_runner = "@duckscript" -script = ''' -exit_on_error true - -output = exec git status --porcelain=v1 -uno -output_length = length ${output.stdout} -if greater_than ${output_length} 0 - if contains ${output.stdout} README.md - msg = array "" "" - array_push ${msg} "A README.md file is out-of-sync with lib.rs" - array_push ${msg} "" - array_push ${msg} "If you modified a lib.rs file, please run `cargo make generate-readmes`. If you edited a" - array_push ${msg} "README.md file directly, please also update the corresponding lib.rs." - array_push ${msg} "" - array_push ${msg} "The modified files were:" - array_push ${msg} "${output.stdout}" - msg = array_join ${msg} "\n" - trigger_error ${msg} - end -end -''' - - -### META TASKS ### [tasks.test-ffi] description = "Run FFI tests" @@ -168,355 +41,3 @@ dependencies = [ "build-all-features", "bincode-gen-testdata", ] - -### WASM TASKS ### - -[tasks.wasm-build-dev] -description = "Build WASM FFI into the target directory (dev mode)" -category = "ICU4X WASM" -install_crate = { rustup_component_name = "rust-src" } -toolchain = "nightly-2021-02-28" -command = "cargo" -args = ["wasm-build-dev", "--package", "icu_capi"] - -[tasks.wasm-build-release] -description = "Build WASM FFI into the target directory (release mode)" -category = "ICU4X WASM" -install_crate = { rustup_component_name = "rust-src" } -toolchain = "nightly-2021-02-28" -# We don't care about panics in release mode because most incorrect inputs are handled by result types. -env = { "RUSTFLAGS" = "-C panic=abort -C opt-level=s" } -command = "cargo" -args = ["wasm-build-release", "--package", "icu_capi"] - -[tasks.wasm-dir] -description = "Make the WASM package directory" -category = "ICU4X WASM" -command = "mkdir" -args = ["-p", "wasmpkg"] - -[tasks.wasm-wasm-dev] -description = "Copy the WASM files from dev into wasmpkg" -category = "ICU4X WASM" -command = "cp" -args = ["${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-unknown-unknown/debug/icu_capi.wasm", "wasmpkg/"] -dependencies = ["wasm-build-dev", "wasm-dir"] - -[tasks.wasm-wasm-release] -description = "Copy the WASM files from release into wasmpkg" -category = "ICU4X WASM" -command = "cp" -args = ["${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-unknown-unknown/release/icu_capi.wasm", "wasmpkg/"] -dependencies = ["wasm-build-release", "wasm-dir"] - -[tasks.wasm-wat] -description = "Create WebAssembly Text files from the WASM files" -category = "ICU4X WASM" -dependencies = ["wasm-wasm-release"] -script_runner = "@duckscript" -script = ''' -exit_on_error true - -wasm2wat = which wasm2wat -assert ${wasm2wat} "Could not find 'wasm2wat' in path.\n*** Please run 'npm install -g wabt' ***" - -mkdir wasmpkg/wat - -handle = glob_array wasmpkg/*.wasm -for src_path in ${handle} - path_no_extension = substring ${src_path} -5 - basename = substring ${path_no_extension} 8 - out_path = concat wasmpkg/wat/ ${basename} ".wat" - - out_exists = is_path_exists ${out_path} - up_to_date = set false - if ${out_exists} - src_time = get_last_modified_time ${src_path} - out_time = get_last_modified_time ${out_path} - up_to_date = less_than ${src_time} ${out_time} - end - - if not ${up_to_date} - echo Writing ${out_path} - output = exec ${wasm2wat} ${src_path} -o ${out_path} - stdout = trim ${output.stdout} - stderr = trim ${output.stderr} - if ${stdout} or ${stderr} or ${output.code} - echo ${stdout}\n${stderr}\nexit code: ${output.code} - assert_fail "wasm2wat printed warnings (shown above)" - end - end -end -''' - -[tasks.wasm-dcmp] -description = "Create WebAssembly decompiled code files from the WASM files" -category = "ICU4X WASM" -dependencies = ["wasm-wasm-release"] -script_runner = "@duckscript" -script = ''' -exit_on_error true - -wasm-decompile = which wasm-decompile -assert ${wasm-decompile} "Could not find 'wasm-decompile' in path.\n*** Please run 'npm install -g wabt' ***" - -mkdir wasmpkg/wasm-decompile - -handle = glob_array wasmpkg/*.wasm -for src_path in ${handle} - path_no_extension = substring ${src_path} -5 - basename = substring ${path_no_extension} 8 - out_path = concat wasmpkg/wasm-decompile/ ${basename} ".dcmp" - - out_exists = is_path_exists ${out_path} - up_to_date = set false - if ${out_exists} - src_time = get_last_modified_time ${src_path} - out_time = get_last_modified_time ${out_path} - up_to_date = less_than ${src_time} ${out_time} - end - - if not ${up_to_date} - echo Writing ${out_path} - output = exec ${wasm-decompile} ${src_path} -o ${out_path} - stdout = trim ${output.stdout} - stderr = trim ${output.stderr} - if ${stdout} or ${stderr} or ${output.code} - echo ${stdout}\n${stderr}\nexit code: ${output.code} - assert_fail "wasm-decompile printed warnings (shown above)" - end - end -end -''' - -[tasks.wasm-opt] -description = "Create optimized WASM files from the WASM files" -category = "ICU4X WASM" -dependencies = ["wasm-wasm-release"] -script_runner = "@duckscript" -script = ''' -exit_on_error true - -wasm-opt = which wasm-opt -assert ${wasm-opt} "Could not find 'wasm-opt' in path.\n*** Please run 'npm install -g wasm-opt' ***" - -mkdir wasmpkg/wasm-opt - -handle = glob_array wasmpkg/*.wasm -for src_path in ${handle} - path_no_extension = substring ${src_path} -5 - basename = substring ${path_no_extension} 8 - out_path = concat wasmpkg/wasm-opt/ ${basename} "+opt.wasm" - - out_exists = is_path_exists ${out_path} - up_to_date = set false - if ${out_exists} - src_time = get_last_modified_time ${src_path} - out_time = get_last_modified_time ${out_path} - up_to_date = less_than ${src_time} ${out_time} - end - - if not ${up_to_date} - echo Writing ${out_path} - output = exec ${wasm-opt} -Os ${src_path} -o ${out_path} - stdout = trim ${output.stdout} - stderr = trim ${output.stderr} - if ${stdout} or ${stderr} or ${output.code} - echo ${stdout}\n${stderr}\nexit code: ${output.code} - assert_fail "wasm-opt printed warnings (shown above)" - end - end -end -''' - -[tasks.wasm-twiggy-dominators] -description = "Create Twiggy Dominator files from the WASM files" -category = "ICU4X WASM" -script_runner = "@duckscript" -script = ''' -exit_on_error true - -twiggy = which twiggy -assert ${twiggy} "Could not find 'twiggy' in path.\n*** Please run 'cargo install twiggy' ***" - -mkdir wasmpkg/twiggy - -handle = glob_array wasmpkg/*.wasm -for src_path in ${handle} - path_no_extension = substring ${src_path} -5 - basename = substring ${path_no_extension} 8 - out_path = concat wasmpkg/twiggy/ ${basename} "+twiggy.txt" - - out_exists = is_path_exists ${out_path} - up_to_date = set false - if ${out_exists} - src_time = get_last_modified_time ${src_path} - out_time = get_last_modified_time ${out_path} - up_to_date = less_than ${src_time} ${out_time} - end - - if not ${up_to_date} - echo Writing ${out_path} - exec --fail-on-error ${twiggy} dominators ${src_path} -o ${out_path} - end -end -''' -dependencies = ["wasm-wasm-release"] - -[tasks.wasm-dev] -description = "All-in-one command to build dev-mode WASM FFI to wasmpkg" -category = "ICU4X WASM" -dependencies = [ - "wasm-wasm-dev", -] - -[tasks.wasm-release] -description = "All-in-one command to build release-mode WASM FFI to wasmpkg" -category = "ICU4X WASM" -dependencies = [ - "wasm-wasm-release", - "wasm-wat", - "wasm-dcmp", - "wasm-opt", - "wasm-twiggy-dominators", -] - -[tasks.wasm-clean] -description = "Clean up WASM build artifacts" -category = "ICU4X WASM" -command = "rm" -args = ["-rf", "wasmpkg"] - -### VALGRIND TASKS ### - -[tasks.valgrind-build] -description = "Pre-build artifacts for use with the Valgrind task" -category = "ICU4X Valgrind" -command = "cargo" -toolchain = "nightly-2021-02-28" -args = ["build", "--examples", "--features", "icu_benchmark_macros/rust_global_allocator", "--profile", "bench", "-Z", "unstable-options"] - -[tasks.valgrind] -description = "Build ICU4X example files with default features and run through Valgrind" -category = "ICU4X Valgrind" -dependencies = [ - "valgrind-build", -] -script_runner = "@duckscript" -script = ''' -exit_on_error true - -valgrind = which valgrind -assert ${valgrind} "Could not find 'valgrind' in path.\n***\nRead about Valgrind: https://valgrind.org/\nInstall on Ubuntu: `apt-get install valgrind`\n***" - -mkdir benchmarks -mkdir benchmarks/valgrind - -# Re-run the build command only to generate the JSON output (--message-format=json) -output = exec cargo +nightly-2021-02-28 build --examples --message-format=json --features icu_benchmark_macros/rust_global_allocator --profile bench -Z unstable-options -if ${output.code} - trigger_error "Build failed! To debug, build examples with `--features icu_benchmark_macros/rust_global_allocator`" -end - -# Parse the JSON messages from --message-format=json line by line -trimmed_stdout = trim ${output.stdout} -json_messages = split ${trimmed_stdout} "\n" -for json_message in ${json_messages} - json_obj = json_parse ${json_message} - - # The following two JSON keys determine whether this is an example artifact - is_compiler_artifact = eq ${json_obj.reason} "compiler-artifact" - is_example = eq ${json_obj.target.kind[0]} "example" - if ${is_compiler_artifact} and ${is_example} - - # Run the example through Valgrind and save the output in the benchmarks folder - out_file = concat "benchmarks/valgrind/" ${json_obj.target.name} ".out" - set_env LD_BIND_NOW "y" - vg_output = exec ${valgrind} --tool=callgrind --zero-before=_start --callgrind-out-file=${out_file} ${json_obj.executable} - if ${vg_output.code} - echo ${vg_output.stdout} - echo ${vg_output.stderr} - trigger_error "Valgrind failed; see output above" - else - # Display the summary line - grep_output = exec grep "summary" ${out_file} - summary_line = trim ${grep_output.stdout} - ir_count = substring ${summary_line} 9 - echo ${ir_count} "Ir:" ${json_obj.target.name} - end - end -end -''' - -### DATA TASKS ### - -[tasks.testdata-download] -description = "Download fresh CLDR JSON, overwriting the existing CLDR JSON." -category = "ICU4X Data" -command = "cargo" -args = [ - "run", - "--bin=icu4x-testdata-download", - "--", - "-v", -] - -[tasks.testdata-build-json] -description = "Build ICU4X JSON from the downloaded CLDR JSON, overwriting the existing ICU4X JSON." -category = "ICU4X Data" -command = "cargo" -args = [ - "run", - "--bin=icu4x-datagen", - "--", - "-v", - "--cldr-testdata", - "--out-testdata", - "--all-keys", - "--test-locales", - "--syntax=json", - "--pretty", - "--overwrite", -] - -[tasks.testdata] -description = "Download fresh data and then build ICU4X JSON from it" -category = "ICU4X Data" -dependencies = [ - "testdata-download", - "testdata-build-json", -] - -[tasks.bincode-clean] -description = "Clean out the bincode data." -category = "ICU4X Data" -script_runner = "@duckscript" -script = ''' -# Use duckscript, rather than a unix command, so that this works on Windows. -rm -r ./provider/testdata/data/bincode -''' - -[tasks.bincode-gen-testdata-no-clean] -description = "Generate bincode testdata without removing the old data" -category = "ICU4X Data" -command = "cargo" -args = [ - "run", - "--bin=icu4x-datagen", - "--", - "-v", - "--cldr-testdata", - "--out-testdata", - "--all-keys", - "--test-locales", - "--syntax=bincode", -] - -[tasks.bincode-gen-testdata] -description = "Generate bincode for the testdata" -category = "ICU4X Data" -run_task = [ - # Running "bincode-clean" first ensures that this command won't fail because the data - # already exists at that location. - { name = ["bincode-clean", "bincode-gen-testdata-no-clean"] }, -] diff --git a/tools/scripts/data.toml b/tools/scripts/data.toml new file mode 100644 index 00000000000..07dce0a7fe6 --- /dev/null +++ b/tools/scripts/data.toml @@ -0,0 +1,76 @@ +# This file is part of ICU4X. For terms of use, please see the file +# called LICENSE at the top level of the ICU4X source tree +# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +# This is a cargo-make file included in the toplevel Makefile.toml + +[tasks.testdata-download] +description = "Download fresh CLDR JSON, overwriting the existing CLDR JSON." +category = "ICU4X Data" +command = "cargo" +args = [ + "run", + "--bin=icu4x-testdata-download", + "--", + "-v", +] + +[tasks.testdata-build-json] +description = "Build ICU4X JSON from the downloaded CLDR JSON, overwriting the existing ICU4X JSON." +category = "ICU4X Data" +command = "cargo" +args = [ + "run", + "--bin=icu4x-datagen", + "--", + "-v", + "--cldr-testdata", + "--out-testdata", + "--all-keys", + "--test-locales", + "--syntax=json", + "--pretty", + "--overwrite", +] + +[tasks.testdata] +description = "Download fresh data and then build ICU4X JSON from it" +category = "ICU4X Data" +dependencies = [ + "testdata-download", + "testdata-build-json", +] + +[tasks.bincode-clean] +description = "Clean out the bincode data." +category = "ICU4X Data" +script_runner = "@duckscript" +script = ''' +# Use duckscript, rather than a unix command, so that this works on Windows. +rm -r ./provider/testdata/data/bincode +''' + +[tasks.bincode-gen-testdata-no-clean] +description = "Generate bincode testdata without removing the old data" +category = "ICU4X Data" +command = "cargo" +args = [ + "run", + "--bin=icu4x-datagen", + "--", + "-v", + "--cldr-testdata", + "--out-testdata", + "--all-keys", + "--test-locales", + "--syntax=bincode", +] + +[tasks.bincode-gen-testdata] +description = "Generate bincode for the testdata" +category = "ICU4X Data" +run_task = [ + # Running "bincode-clean" first ensures that this command won't fail because the data + # already exists at that location. + { name = ["bincode-clean", "bincode-gen-testdata-no-clean"] }, +] diff --git a/tools/scripts/tests.toml b/tools/scripts/tests.toml new file mode 100644 index 00000000000..ad8b7f9c4a5 --- /dev/null +++ b/tools/scripts/tests.toml @@ -0,0 +1,35 @@ +# This file is part of ICU4X. For terms of use, please see the file +# called LICENSE at the top level of the ICU4X source tree +# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +# This is a cargo-make file included in the toplevel Makefile.toml + +[tasks.build-all-features] +description = "Build all permutations of all features" +category = "ICU4X Development" +install_crate = { crate_name = "cargo-all-features", binary = "cargo-build-all-features", test_arg = ["--help"] } +install_crate_args = ["--version", "^1.4"] +command = "cargo" +args = ["build-all-features"] + +[tasks.test-capi] +description = "Run C API tests" +category = "ICU4X Development" +script = ''' +cd ffi/capi/examples/pluralrules; +make +cd ../fixeddecimal; +make +cd ../locale; +make +''' + +[tasks.test-cpp] +description = "Run CPP tests" +category = "ICU4X Development" +script = ''' +cd ffi/cpp/examples/pluralrules; +make +cd ../fixeddecimal; +make +''' \ No newline at end of file diff --git a/tools/scripts/tidy.toml b/tools/scripts/tidy.toml new file mode 100644 index 00000000000..667fef4e923 --- /dev/null +++ b/tools/scripts/tidy.toml @@ -0,0 +1,101 @@ +# This file is part of ICU4X. For terms of use, please see the file +# called LICENSE at the top level of the ICU4X source tree +# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +# This is a cargo-make file included in the toplevel Makefile.toml + +[tasks.license-header-check] +description = "Ensure all the source files have license headers" +category = "ICU4X Development" +script_runner = "@duckscript" +script = ''' +exit_on_error true + +glob_pattern_array = array "./**/*.rs" "./**/*.yml" "./**/*.toml" + +blank_line = set "" + +license_hash_line_1 = set "# This file is part of ICU4X. For terms of use, please see the file" +license_hash_line_2 = set "# called LICENSE at the top level of the ICU4X source tree" +license_hash_line_3 = set "# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE )." +license_hash_array = array ${license_hash_line_1} ${license_hash_line_2} ${license_hash_line_3} ${blank_line} +license_hash_str = array_join ${license_hash_array} "\n" + +license_slash_line_1 = set "// This file is part of ICU4X. For terms of use, please see the file" +license_slash_line_2 = set "// called LICENSE at the top level of the ICU4X source tree" +license_slash_line_3 = set "// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE )." +license_slash_array = array ${license_slash_line_1} ${license_slash_line_2} ${license_slash_line_3} ${blank_line} +license_slash_str = array_join ${license_slash_array} "\n" + +for pattern in ${glob_pattern_array} + handle = glob_array ${pattern} + for path in ${handle} + if not starts_with ${path} "target" # skip paths in target dir + text = readfile ${path} + result_hash = starts_with ${text} ${license_hash_str} + result_slash = starts_with ${text} ${license_slash_str} + not_result_hash = not ${result_hash} + not_result_slash = not ${result_slash} + if ${not_result_hash} and ${not_result_slash} + echo "License header missing in ${path}" + trigger_error "License header missing or misformatted in ${path}." + end + end + end + echo "License headers found in files matching ${pattern}" +end +echo "License header check complete" +''' + +[tasks.generate-readmes] +description = "Automatically generate README.md for each component." +category = "ICU4X Development" +script_runner = "@duckscript" +script = ''' +exit_on_error true + +glob_pattern = set "./**/Cargo.toml" +template = canonicalize README.tpl + +cargo_list = exec cargo --list +if not contains ${cargo_list.stdout} "readme" + trigger_error "Please run 'cargo install cargo-readme' to support generating README.md files" +end + +handle = glob_array ${glob_pattern} +for path in ${handle} + root_dir = dirname ${path} + if not is_empty ${root_dir} + echo "Automatically generating ${root_dir}/README.md" + exec --fail-on-error cargo readme -r ${root_dir} -o README.md -t ${template} + end +end +''' + +[tasks.generated-readme-check] +description = "Check that README.md was properly generated for each component." +category = "ICU4X Development" +dependencies = [ + "generate-readmes" +] +script_runner = "@duckscript" +script = ''' +exit_on_error true + +output = exec git status --porcelain=v1 -uno +output_length = length ${output.stdout} +if greater_than ${output_length} 0 + if contains ${output.stdout} README.md + msg = array "" "" + array_push ${msg} "A README.md file is out-of-sync with lib.rs" + array_push ${msg} "" + array_push ${msg} "If you modified a lib.rs file, please run `cargo make generate-readmes`. If you edited a" + array_push ${msg} "README.md file directly, please also update the corresponding lib.rs." + array_push ${msg} "" + array_push ${msg} "The modified files were:" + array_push ${msg} "${output.stdout}" + msg = array_join ${msg} "\n" + trigger_error ${msg} + end +end +''' \ No newline at end of file diff --git a/tools/scripts/valgrind.toml b/tools/scripts/valgrind.toml new file mode 100644 index 00000000000..cd1da8ac705 --- /dev/null +++ b/tools/scripts/valgrind.toml @@ -0,0 +1,64 @@ +# This file is part of ICU4X. For terms of use, please see the file +# called LICENSE at the top level of the ICU4X source tree +# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +# This is a cargo-make file included in the toplevel Makefile.toml + +[tasks.valgrind-build] +description = "Pre-build artifacts for use with the Valgrind task" +category = "ICU4X Valgrind" +command = "cargo" +toolchain = "nightly-2021-02-28" +args = ["build", "--examples", "--features", "icu_benchmark_macros/rust_global_allocator", "--profile", "bench", "-Z", "unstable-options"] + +[tasks.valgrind] +description = "Build ICU4X example files with default features and run through Valgrind" +category = "ICU4X Valgrind" +dependencies = [ + "valgrind-build", +] +script_runner = "@duckscript" +script = ''' +exit_on_error true + +valgrind = which valgrind +assert ${valgrind} "Could not find 'valgrind' in path.\n***\nRead about Valgrind: https://valgrind.org/\nInstall on Ubuntu: `apt-get install valgrind`\n***" + +mkdir benchmarks +mkdir benchmarks/valgrind + +# Re-run the build command only to generate the JSON output (--message-format=json) +output = exec cargo +nightly-2021-02-28 build --examples --message-format=json --features icu_benchmark_macros/rust_global_allocator --profile bench -Z unstable-options +if ${output.code} + trigger_error "Build failed! To debug, build examples with `--features icu_benchmark_macros/rust_global_allocator`" +end + +# Parse the JSON messages from --message-format=json line by line +trimmed_stdout = trim ${output.stdout} +json_messages = split ${trimmed_stdout} "\n" +for json_message in ${json_messages} + json_obj = json_parse ${json_message} + + # The following two JSON keys determine whether this is an example artifact + is_compiler_artifact = eq ${json_obj.reason} "compiler-artifact" + is_example = eq ${json_obj.target.kind[0]} "example" + if ${is_compiler_artifact} and ${is_example} + + # Run the example through Valgrind and save the output in the benchmarks folder + out_file = concat "benchmarks/valgrind/" ${json_obj.target.name} ".out" + set_env LD_BIND_NOW "y" + vg_output = exec ${valgrind} --tool=callgrind --zero-before=_start --callgrind-out-file=${out_file} ${json_obj.executable} + if ${vg_output.code} + echo ${vg_output.stdout} + echo ${vg_output.stderr} + trigger_error "Valgrind failed; see output above" + else + # Display the summary line + grep_output = exec grep "summary" ${out_file} + summary_line = trim ${grep_output.stdout} + ir_count = substring ${summary_line} 9 + echo ${ir_count} "Ir:" ${json_obj.target.name} + end + end +end +''' diff --git a/tools/scripts/wasm.toml b/tools/scripts/wasm.toml new file mode 100644 index 00000000000..a51f0b72df8 --- /dev/null +++ b/tools/scripts/wasm.toml @@ -0,0 +1,221 @@ +# This file is part of ICU4X. For terms of use, please see the file +# called LICENSE at the top level of the ICU4X source tree +# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +# This is a cargo-make file included in the toplevel Makefile.toml + +[tasks.wasm-build-dev] +description = "Build WASM FFI into the target directory (dev mode)" +category = "ICU4X WASM" +install_crate = { rustup_component_name = "rust-src" } +toolchain = "nightly-2021-02-28" +command = "cargo" +args = ["wasm-build-dev", "--package", "icu_capi"] + +[tasks.wasm-build-release] +description = "Build WASM FFI into the target directory (release mode)" +category = "ICU4X WASM" +install_crate = { rustup_component_name = "rust-src" } +toolchain = "nightly-2021-02-28" +# We don't care about panics in release mode because most incorrect inputs are handled by result types. +env = { "RUSTFLAGS" = "-C panic=abort -C opt-level=s" } +command = "cargo" +args = ["wasm-build-release", "--package", "icu_capi"] + +[tasks.wasm-dir] +description = "Make the WASM package directory" +category = "ICU4X WASM" +command = "mkdir" +args = ["-p", "wasmpkg"] + +[tasks.wasm-wasm-dev] +description = "Copy the WASM files from dev into wasmpkg" +category = "ICU4X WASM" +command = "cp" +args = ["${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-unknown-unknown/debug/icu_capi.wasm", "wasmpkg/"] +dependencies = ["wasm-build-dev", "wasm-dir"] + +[tasks.wasm-wasm-release] +description = "Copy the WASM files from release into wasmpkg" +category = "ICU4X WASM" +command = "cp" +args = ["${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-unknown-unknown/release/icu_capi.wasm", "wasmpkg/"] +dependencies = ["wasm-build-release", "wasm-dir"] + +[tasks.wasm-wat] +description = "Create WebAssembly Text files from the WASM files" +category = "ICU4X WASM" +dependencies = ["wasm-wasm-release"] +script_runner = "@duckscript" +script = ''' +exit_on_error true + +wasm2wat = which wasm2wat +assert ${wasm2wat} "Could not find 'wasm2wat' in path.\n*** Please run 'npm install -g wabt' ***" + +mkdir wasmpkg/wat + +handle = glob_array wasmpkg/*.wasm +for src_path in ${handle} + path_no_extension = substring ${src_path} -5 + basename = substring ${path_no_extension} 8 + out_path = concat wasmpkg/wat/ ${basename} ".wat" + + out_exists = is_path_exists ${out_path} + up_to_date = set false + if ${out_exists} + src_time = get_last_modified_time ${src_path} + out_time = get_last_modified_time ${out_path} + up_to_date = less_than ${src_time} ${out_time} + end + + if not ${up_to_date} + echo Writing ${out_path} + output = exec ${wasm2wat} ${src_path} -o ${out_path} + stdout = trim ${output.stdout} + stderr = trim ${output.stderr} + if ${stdout} or ${stderr} or ${output.code} + echo ${stdout}\n${stderr}\nexit code: ${output.code} + assert_fail "wasm2wat printed warnings (shown above)" + end + end +end +''' + +[tasks.wasm-dcmp] +description = "Create WebAssembly decompiled code files from the WASM files" +category = "ICU4X WASM" +dependencies = ["wasm-wasm-release"] +script_runner = "@duckscript" +script = ''' +exit_on_error true + +wasm-decompile = which wasm-decompile +assert ${wasm-decompile} "Could not find 'wasm-decompile' in path.\n*** Please run 'npm install -g wabt' ***" + +mkdir wasmpkg/wasm-decompile + +handle = glob_array wasmpkg/*.wasm +for src_path in ${handle} + path_no_extension = substring ${src_path} -5 + basename = substring ${path_no_extension} 8 + out_path = concat wasmpkg/wasm-decompile/ ${basename} ".dcmp" + + out_exists = is_path_exists ${out_path} + up_to_date = set false + if ${out_exists} + src_time = get_last_modified_time ${src_path} + out_time = get_last_modified_time ${out_path} + up_to_date = less_than ${src_time} ${out_time} + end + + if not ${up_to_date} + echo Writing ${out_path} + output = exec ${wasm-decompile} ${src_path} -o ${out_path} + stdout = trim ${output.stdout} + stderr = trim ${output.stderr} + if ${stdout} or ${stderr} or ${output.code} + echo ${stdout}\n${stderr}\nexit code: ${output.code} + assert_fail "wasm-decompile printed warnings (shown above)" + end + end +end +''' + +[tasks.wasm-opt] +description = "Create optimized WASM files from the WASM files" +category = "ICU4X WASM" +dependencies = ["wasm-wasm-release"] +script_runner = "@duckscript" +script = ''' +exit_on_error true + +wasm-opt = which wasm-opt +assert ${wasm-opt} "Could not find 'wasm-opt' in path.\n*** Please run 'npm install -g wasm-opt' ***" + +mkdir wasmpkg/wasm-opt + +handle = glob_array wasmpkg/*.wasm +for src_path in ${handle} + path_no_extension = substring ${src_path} -5 + basename = substring ${path_no_extension} 8 + out_path = concat wasmpkg/wasm-opt/ ${basename} "+opt.wasm" + + out_exists = is_path_exists ${out_path} + up_to_date = set false + if ${out_exists} + src_time = get_last_modified_time ${src_path} + out_time = get_last_modified_time ${out_path} + up_to_date = less_than ${src_time} ${out_time} + end + + if not ${up_to_date} + echo Writing ${out_path} + output = exec ${wasm-opt} -Os ${src_path} -o ${out_path} + stdout = trim ${output.stdout} + stderr = trim ${output.stderr} + if ${stdout} or ${stderr} or ${output.code} + echo ${stdout}\n${stderr}\nexit code: ${output.code} + assert_fail "wasm-opt printed warnings (shown above)" + end + end +end +''' + +[tasks.wasm-twiggy-dominators] +description = "Create Twiggy Dominator files from the WASM files" +category = "ICU4X WASM" +script_runner = "@duckscript" +script = ''' +exit_on_error true + +twiggy = which twiggy +assert ${twiggy} "Could not find 'twiggy' in path.\n*** Please run 'cargo install twiggy' ***" + +mkdir wasmpkg/twiggy + +handle = glob_array wasmpkg/*.wasm +for src_path in ${handle} + path_no_extension = substring ${src_path} -5 + basename = substring ${path_no_extension} 8 + out_path = concat wasmpkg/twiggy/ ${basename} "+twiggy.txt" + + out_exists = is_path_exists ${out_path} + up_to_date = set false + if ${out_exists} + src_time = get_last_modified_time ${src_path} + out_time = get_last_modified_time ${out_path} + up_to_date = less_than ${src_time} ${out_time} + end + + if not ${up_to_date} + echo Writing ${out_path} + exec --fail-on-error ${twiggy} dominators ${src_path} -o ${out_path} + end +end +''' +dependencies = ["wasm-wasm-release"] + +[tasks.wasm-dev] +description = "All-in-one command to build dev-mode WASM FFI to wasmpkg" +category = "ICU4X WASM" +dependencies = [ + "wasm-wasm-dev", +] + +[tasks.wasm-release] +description = "All-in-one command to build release-mode WASM FFI to wasmpkg" +category = "ICU4X WASM" +dependencies = [ + "wasm-wasm-release", + "wasm-wat", + "wasm-dcmp", + "wasm-opt", + "wasm-twiggy-dominators", +] + +[tasks.wasm-clean] +description = "Clean up WASM build artifacts" +category = "ICU4X WASM" +command = "rm" +args = ["-rf", "wasmpkg"] From 933e0beac21c6c4b9ced995116ca32ae857b181a Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 15:52:40 -0700 Subject: [PATCH 02/24] Add a tidy task for non-fmt/lint checks --- Makefile.toml | 3 +-- tools/scripts/tidy.toml | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index df35f97d5d3..3571e877a36 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -26,8 +26,7 @@ dependencies = [ "test-all", "fmt-check", "clippy-all", - "license-header-check", - "generated-readme-check", + "tidy", "test-ffi", ] diff --git a/tools/scripts/tidy.toml b/tools/scripts/tidy.toml index 667fef4e923..b9a806a000c 100644 --- a/tools/scripts/tidy.toml +++ b/tools/scripts/tidy.toml @@ -4,6 +4,14 @@ # This is a cargo-make file included in the toplevel Makefile.toml +[tasks.tidy] +description = "Run miscellaneous tidy checks" +category = "ICU4X Development" +dependencies = [ + "license-header-check", + "generated-readme-check", +] + [tasks.license-header-check] description = "Ensure all the source files have license headers" category = "ICU4X Development" From 97251354270e26370cf815bbb49e5f2f14a939e1 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 15:53:29 -0700 Subject: [PATCH 03/24] Move test-ffi into tests.toml --- Makefile.toml | 9 --------- tools/scripts/tests.toml | 8 ++++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 3571e877a36..78e472c60f6 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -10,15 +10,6 @@ extend = [{ path = "./tools/scripts/data.toml"}, { path = "./tools/scripts/valgr default_to_workspace = false load_cargo_aliases = true - -[tasks.test-ffi] -description = "Run FFI tests" -category = "ICU4X Development" -dependencies = [ - "test-capi", - "test-cpp", -] - [tasks.quick] description = "Run quick version of all lints and tests" category = "ICU4X Development" diff --git a/tools/scripts/tests.toml b/tools/scripts/tests.toml index ad8b7f9c4a5..0806340e584 100644 --- a/tools/scripts/tests.toml +++ b/tools/scripts/tests.toml @@ -12,6 +12,14 @@ install_crate_args = ["--version", "^1.4"] command = "cargo" args = ["build-all-features"] +[tasks.test-ffi] +description = "Run FFI tests" +category = "ICU4X Development" +dependencies = [ + "test-capi", + "test-cpp", +] + [tasks.test-capi] description = "Run C API tests" category = "ICU4X Development" From cdf13554a8813ded8450c59ac86545b496bc90c5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 16:30:09 -0700 Subject: [PATCH 04/24] Move all CI jobs to Makefile.toml, refactor Makefile.toml --- .cargo/config.toml | 17 ++----- .github/workflows/build-test.yml | 79 +++++++++++++++----------------- Makefile.toml | 66 +++++++++++++++++++++++--- tools/scripts/tests.toml | 26 ++++++++++- tools/scripts/wasm.toml | 15 +++++- 5 files changed, 140 insertions(+), 63 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index c15ffe23df7..e69d438af47 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -7,22 +7,16 @@ ### INDIVIDUAL TEST AND LINT TASKS ### # Build and run all code paths except docs -test-all = "test --all-features --all-targets" +test-all = "make test-all-features" # Build and run all docs tests -test-docs = "test --all-features --doc" +test-docs = "make test-docs" # Build and run docs tests with default features -test-docs-defaults = "test --doc" +test-docs-defaults = "make test-docs-defaults" # Check for formatting on all code -fmt-check = "fmt -- --check" - -# Check for license headers -license-check = "make license-header-check" - -# Check for generated README.md -readme-check = "make generated-readme-check" +fmt-check = "make fmt-check" # Run Clippy on all code paths # Keep args in sync with `clippy` job in .github/workflows/build-test.yml @@ -38,8 +32,7 @@ quick = "make quick" # Run all lints and tests ci = "make ci" -# Run all lints and tests -bincode-gen-testdata = "make bincode-gen-testdata" +tidy = "make tidy" ### WASM TASKS ### diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e8b896428c0..c06ff5c4854 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -6,6 +6,13 @@ name: Build and Test # TODO(#234) re-include cache steps, also using Rust version in cache key +# Note: Each of these jobs, except for the clippy job and the optional benchmarking/coverage +# jobs, maps to a `ci-job-foo` entry in Makefile.toml. If adding further CI jobs, please add them +# as makefile targets as well, and list them under `ci-all`. +# +# Clippy is special because we're using actions-rs/clippy-check which is able to surface clippy failures on +# PR bodies + on: push: branches: [ main ] @@ -24,8 +31,8 @@ jobs: - name: Check uses: actions-rs/cargo@v1.0.1 with: - command: check - args: --all-targets --all-features + command: make + args: ci-job-check # Test job - runs all "cargo make" testing commands test: @@ -44,14 +51,11 @@ jobs: with: command: build args: --all-targets --all-features - - name: Test All Targets - uses: actions-rs/cargo@v1.0.1 - with: - command: test-all - - name: Test Docs + - name: Run `cargo make ci-job-test` uses: actions-rs/cargo@v1.0.1 with: - command: test-docs + command: make + args: ci-job-test # Feature coverage job - builds all permutations of features @@ -75,7 +79,8 @@ jobs: - name: Build All Feature Permutations uses: actions-rs/cargo@v1.0.1 with: - command: build-all-features + command: make + args: ci-job-features # WASM Tests - runs Node.js tests for WASM bindings wasm: @@ -106,14 +111,14 @@ jobs: uses: actions/setup-node@v1 with: node-version: 14.17.0 - - name: Test - run: | - npm install - npm test - working-directory: ./ffi/wasm/test + - name: Build + uses: actions-rs/cargo@v1.0.1 + with: + command: make + args: wasm-test-release - # Lint job - runs all "cargo make" linting commands - lint: + # Fmt job - runs cargo fmt + fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -130,54 +135,44 @@ jobs: crate: cargo-make version: latest - - name: Install cargo-readme - uses: actions-rs/install@v0.1.2 - with: - crate: cargo-readme - version: latest - - # TODO(#234) re-include cache steps, also using Rust version in cache key - - name: Check Format uses: actions-rs/cargo@v1.0.1 with: - command: fmt-check - - - name: Check License Headers - uses: actions-rs/cargo@v1.0.1 - with: - command: license-check + command: make + args: ci-job-format - - name: Check Generated README.md - uses: actions-rs/cargo@v1.0.1 - with: - command: readme-check - # Bincode job - Test that the bincode data provider can be generated correctly. - bincode: + # Lint job - runs all "cargo make" tidy commands + tidy: runs-on: ubuntu-latest - # Wait for the initial build to finish. Note that this step does not currently re-use any - # artifacts from the build step. It's only waiting on the build to minimize resource use - # in case the build fails. - needs: [build] steps: - uses: actions/checkout@v2 - name: Load the default Rust toolchain via the rust-toolchain file. run: rustup show + - name: Install rustfmt + run: rustup component add rustfmt + - name: Install cargo-make uses: actions-rs/install@v0.1.2 with: crate: cargo-make version: latest + - name: Install cargo-readme + uses: actions-rs/install@v0.1.2 + with: + crate: cargo-readme + version: latest + # TODO(#234) re-include cache steps, also using Rust version in cache key - - name: Build the bincode + - name: Tidy uses: actions-rs/cargo@v1.0.1 with: - command: bincode-gen-testdata + command: make + args: ci-job-tidy # Clippy job (cargo-clippy) - completes and puts warnings inline in PR clippy: diff --git a/Makefile.toml b/Makefile.toml index 78e472c60f6..9c0437968ed 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -8,26 +8,80 @@ extend = [{ path = "./tools/scripts/data.toml"}, { path = "./tools/scripts/valgr [config] default_to_workspace = false -load_cargo_aliases = true + [tasks.quick] description = "Run quick version of all lints and tests" category = "ICU4X Development" dependencies = [ - "test-all", + "test-all-features", "fmt-check", "clippy-all", "tidy", "test-ffi", ] -[tasks.ci] -description = "Run all lints and tests" +[tasks.ci-job-check] +description = "Run all tests for the CI 'check' job" category = "ICU4X Development" +command = "cargo" +args = ["check", "--all-targets", "--all-features"] + +[tasks.ci-job-test] +description = "Run all tests for the CI 'test' job" +category = "CI" dependencies = [ - "quick", + "test-all-features", + "test-ffi", "test-docs-defaults", "test-docs", - "build-all-features", "bincode-gen-testdata", ] + +[tasks.ci-job-features] +description = "Run all tests for the CI 'features' job" +category = "CI" +dependencies = [ + "build-all-features", +] + +[tasks.ci-job-fmt] +description = "Run all tests for the CI 'fmt' job" +category = "CI" +dependencies = [ + "fmt-check", +] + +[tasks.ci-job-tidy] +description = "Run all tests for the CI 'tidy' job" +category = "CI" +dependencies = [ + "tidy", +] + +[tasks.ci-job-wasm] +description = "Run all tests for the CI 'wasm' job" +category = "CI" +dependencies = [ + "wasm-test-release", +] + +[tasks.ci-all] +# Note that updating this list will not update what is run on CI, +# it simply exists as a shortcut to run everything locally +description = "Locally run all CI jobs" +category = "ICU4X Development" +dependencies = [ + "ci-job-check", + "ci-job-tidy", + "ci-job-fmt", + "ci-job-features", + "ci-job-test", + "ci-job-wasm", + + # CI runs this a little differently to allow for lint failures to show + # up on PRs + "clippy-all", + + # benchmarking and coverage jobs not included +] diff --git a/tools/scripts/tests.toml b/tools/scripts/tests.toml index 0806340e584..60760cac347 100644 --- a/tools/scripts/tests.toml +++ b/tools/scripts/tests.toml @@ -12,6 +12,30 @@ install_crate_args = ["--version", "^1.4"] command = "cargo" args = ["build-all-features"] +[tasks.fmt-check] +description = "Build all permutations of all features" +category = "ICU4X Development" +command = "cargo" +args = ["fmt", "--", "--check"] + +[tasks.test-all-features] +description = "Run all Rust tests with all features and targets" +category = "ICU4X Development" +command = "cargo" +args = ["test", "--all-features", "--all-targets"] + +[tasks.test-docs] +description = "Run all Rust doctests with all features" +category = "ICU4X Development" +command = "cargo" +args = ["test", "--all-features", "--doc"] + +[tasks.test-docs-default] +description = "Run all Rust doctests with default features" +category = "ICU4X Development" +command = "cargo" +args = ["test", "--doc"] + [tasks.test-ffi] description = "Run FFI tests" category = "ICU4X Development" @@ -40,4 +64,4 @@ cd ffi/cpp/examples/pluralrules; make cd ../fixeddecimal; make -''' \ No newline at end of file +''' diff --git a/tools/scripts/wasm.toml b/tools/scripts/wasm.toml index a51f0b72df8..7962d044ed2 100644 --- a/tools/scripts/wasm.toml +++ b/tools/scripts/wasm.toml @@ -210,10 +210,21 @@ dependencies = [ "wasm-wasm-release", "wasm-wat", "wasm-dcmp", - "wasm-opt", - "wasm-twiggy-dominators", + "opt", + "wasm-twiggy-dowasm-minators", ] +[tasks.wasm-test-release] +description = "Run WASM tests in release mode" +category = "ICU4X WASM" +script_runner = "@duckscript" +script = ''' +cd ./ffi/wasm/test; +npm install; +npm test; +''' +dependencies = ["wasm-release"] + [tasks.wasm-clean] description = "Clean up WASM build artifacts" category = "ICU4X WASM" From 66fc6ba3d4c58e66f41177dd7b03b68f4fee01d4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 16:35:32 -0700 Subject: [PATCH 05/24] build -> check --- .github/workflows/build-test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index c06ff5c4854..dbea5bb577a 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -22,7 +22,7 @@ on: jobs: # Build job - basic smoke test - build: + check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -61,7 +61,7 @@ jobs: # Feature coverage job - builds all permutations of features features: runs-on: ubuntu-latest - needs: [build] + needs: [check] steps: - uses: actions/checkout@v2 @@ -85,7 +85,7 @@ jobs: # WASM Tests - runs Node.js tests for WASM bindings wasm: runs-on: ubuntu-latest - needs: [build] + needs: [check] steps: - uses: actions/checkout@v2 @@ -142,7 +142,7 @@ jobs: args: ci-job-format - # Lint job - runs all "cargo make" tidy commands + # Tidy job - runs all "cargo make" tidy commands tidy: runs-on: ubuntu-latest steps: @@ -218,7 +218,7 @@ jobs: runs-on: ubuntu-latest - needs: [build] + needs: [check] steps: - uses: actions/checkout@v2 @@ -349,7 +349,7 @@ jobs: # Only run the memory benchmark if the main build succeeded. The memory benchmark does not # rely on any of the build artifacts. - needs: [build] + needs: [check] steps: - uses: actions/checkout@v2 @@ -446,7 +446,7 @@ jobs: runs-on: ubuntu-latest - needs: [build, lint, bincode, benchmark, memory] + needs: [check, lint, bincode, benchmark, memory] ## Only create docs for merges/pushes to main (skip PRs). ## Multiple unfinished PRs should not clobber docs from approved code. From 55f9cbc5b997227c3fc6c243aaf4a7160d519e7b Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 16:53:14 -0700 Subject: [PATCH 06/24] install cargo make in ci --- .cargo/config.toml | 23 ----------------------- .github/workflows/build-test.yml | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index e69d438af47..ec28c1e74b7 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,19 +4,6 @@ [alias] -### INDIVIDUAL TEST AND LINT TASKS ### - -# Build and run all code paths except docs -test-all = "make test-all-features" - -# Build and run all docs tests -test-docs = "make test-docs" - -# Build and run docs tests with default features -test-docs-defaults = "make test-docs-defaults" - -# Check for formatting on all code -fmt-check = "make fmt-check" # Run Clippy on all code paths # Keep args in sync with `clippy` job in .github/workflows/build-test.yml @@ -24,16 +11,6 @@ fmt-check = "make fmt-check" # field-reassign-with-default: https://github.com/rust-lang/rust-clippy/issues/6559 (fixed in nightly but not stable) clippy-all = "clippy --all-features --all-targets -- -D warnings -Aclippy::field-reassign-with-default" -### META TASKS ### - -# Run quick version of all lints and tests -quick = "make quick" - -# Run all lints and tests -ci = "make ci" - -tidy = "make tidy" - ### WASM TASKS ### # Re-build standard library with panic=abort. diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index dbea5bb577a..1a3cda956ce 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -28,6 +28,11 @@ jobs: - uses: actions/checkout@v2 - name: Load the default Rust toolchain via the rust-toolchain file. run: rustup show + - name: Install cargo-make + uses: actions-rs/install@v0.1.2 + with: + crate: cargo-make + version: latest - name: Check uses: actions-rs/cargo@v1.0.1 with: @@ -46,6 +51,11 @@ jobs: - uses: actions/checkout@v2 - name: Load the default Rust toolchain via the rust-toolchain file. run: rustup show + - name: Install cargo-make + uses: actions-rs/install@v0.1.2 + with: + crate: cargo-make + version: latest - name: Build uses: actions-rs/cargo@v1.0.1 with: @@ -62,7 +72,6 @@ jobs: features: runs-on: ubuntu-latest needs: [check] - steps: - uses: actions/checkout@v2 - name: Load the default Rust toolchain via the rust-toolchain file. @@ -72,6 +81,11 @@ jobs: with: command: install args: cargo-all-features --version "^1.4" + - name: Install cargo-make + uses: actions-rs/install@v0.1.2 + with: + crate: cargo-make + version: latest - name: Test Docs with Default Features uses: actions-rs/cargo@v1.0.1 with: From eb3a07983535712bc87c16d6ccb75c7cfe4e80a8 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 16:56:35 -0700 Subject: [PATCH 07/24] Fix error --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 1a3cda956ce..fd93202b0ae 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -460,7 +460,7 @@ jobs: runs-on: ubuntu-latest - needs: [check, lint, bincode, benchmark, memory] + needs: [check, tidy, benchmark, memory] ## Only create docs for merges/pushes to main (skip PRs). ## Multiple unfinished PRs should not clobber docs from approved code. From 5d9a32d7adf16f0ed22c0946ed866111fdc739ab Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 17:00:07 -0700 Subject: [PATCH 08/24] fix CONTRIBUTING --- .cargo/config.toml | 2 ++ CONTRIBUTING.md | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index ec28c1e74b7..ac07f28e9e5 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,6 +4,8 @@ [alias] +quick = "make quick" +tidy = "make tidy" # Run Clippy on all code paths # Keep args in sync with `clippy` job in .github/workflows/build-test.yml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e8b08cea55..304e2aa3aba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,8 +34,9 @@ Each commit and pull request should follow the [style guide][style_guide] and be Handy commands (run from the root directory): +- `cargo tidy` runs tidy-checks (not including fmt/clippy) - `cargo quick` runs the fastest tests and lints. -- `cargo ci` runs all tests and lints. +- `cargo make ci-all` runs all tests and lints ### Structure of commits in a Pull Request From 4a39bf6f85473c4d8527a044d927a51c15eafc85 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 17:06:32 -0700 Subject: [PATCH 09/24] tyop --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index fd93202b0ae..be92f5a58da 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -153,7 +153,7 @@ jobs: uses: actions-rs/cargo@v1.0.1 with: command: make - args: ci-job-format + args: ci-job-fmt # Tidy job - runs all "cargo make" tidy commands From 40a92420c1f301de04aa46ec8f1ae13a6423e93b Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 17:19:13 -0700 Subject: [PATCH 10/24] Fix makefile --- Makefile.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index 9c0437968ed..921fb6f99c3 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -33,7 +33,7 @@ category = "CI" dependencies = [ "test-all-features", "test-ffi", - "test-docs-defaults", + "test-docs-default", "test-docs", "bincode-gen-testdata", ] From a5fd5f9ad4571dc98f8beae34270143641038153 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 17:22:01 -0700 Subject: [PATCH 11/24] fix --- .github/workflows/build-test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index be92f5a58da..f34f6f6d5b9 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -86,10 +86,6 @@ jobs: with: crate: cargo-make version: latest - - name: Test Docs with Default Features - uses: actions-rs/cargo@v1.0.1 - with: - command: test-docs-defaults - name: Build All Feature Permutations uses: actions-rs/cargo@v1.0.1 with: From 26f5c8ebe7f4bdd44a0825fe8d515621cedaa580 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 17:39:33 -0700 Subject: [PATCH 12/24] fix wasm, dirs --- tools/scripts/wasm.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/scripts/wasm.toml b/tools/scripts/wasm.toml index 7962d044ed2..1f81f6bd5e6 100644 --- a/tools/scripts/wasm.toml +++ b/tools/scripts/wasm.toml @@ -210,7 +210,7 @@ dependencies = [ "wasm-wasm-release", "wasm-wat", "wasm-dcmp", - "opt", + "wasm-opt", "wasm-twiggy-dowasm-minators", ] From 17dff326a760be1dc256795f1724c3c1959a3720 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 17:50:37 -0700 Subject: [PATCH 13/24] switch to duckscript --- Makefile.toml | 2 +- tools/scripts/tests.toml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index 921fb6f99c3..e0275b5a47e 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -31,8 +31,8 @@ args = ["check", "--all-targets", "--all-features"] description = "Run all tests for the CI 'test' job" category = "CI" dependencies = [ - "test-all-features", "test-ffi", + "test-all-features", "test-docs-default", "test-docs", "bincode-gen-testdata", diff --git a/tools/scripts/tests.toml b/tools/scripts/tests.toml index 60760cac347..fc6d3af91cb 100644 --- a/tools/scripts/tests.toml +++ b/tools/scripts/tests.toml @@ -47,6 +47,7 @@ dependencies = [ [tasks.test-capi] description = "Run C API tests" category = "ICU4X Development" +script_runner = "@duckscript" script = ''' cd ffi/capi/examples/pluralrules; make @@ -59,6 +60,7 @@ make [tasks.test-cpp] description = "Run CPP tests" category = "ICU4X Development" +script_runner = "@duckscript" script = ''' cd ffi/cpp/examples/pluralrules; make From efd51c6b37e1acc2df4472fd713ad18682b2ea91 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 18:01:59 -0700 Subject: [PATCH 14/24] Cache cargo-make --- .github/workflows/build-test.yml | 86 ++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f34f6f6d5b9..267eff8a48a 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -28,11 +28,25 @@ jobs: - uses: actions/checkout@v2 - name: Load the default Rust toolchain via the rust-toolchain file. run: rustup show + + - name: Get cargo-make version + id: cargo-make-version + run: | + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + shell: bash + - name: Cache cargo-make + uses: actions/cache@v2 + id: cargo-make-cache + with: + path: ~/.cargo/bin/cargo-make + key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make + if: steps.cargo-make-cache.outputs.cache-hit != 'true' uses: actions-rs/install@v0.1.2 with: crate: cargo-make version: latest + - name: Check uses: actions-rs/cargo@v1.0.1 with: @@ -51,11 +65,25 @@ jobs: - uses: actions/checkout@v2 - name: Load the default Rust toolchain via the rust-toolchain file. run: rustup show + + - name: Get cargo-make version + id: cargo-make-version + run: | + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + shell: bash + - name: Cache cargo-make + uses: actions/cache@v2 + id: cargo-make-cache + with: + path: ~/.cargo/bin/cargo-make + key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make + if: steps.cargo-make-cache.outputs.cache-hit != 'true' uses: actions-rs/install@v0.1.2 with: crate: cargo-make version: latest + - name: Build uses: actions-rs/cargo@v1.0.1 with: @@ -81,11 +109,25 @@ jobs: with: command: install args: cargo-all-features --version "^1.4" + + - name: Get cargo-make version + id: cargo-make-version + run: | + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + shell: bash + - name: Cache cargo-make + uses: actions/cache@v2 + id: cargo-make-cache + with: + path: ~/.cargo/bin/cargo-make + key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make + if: steps.cargo-make-cache.outputs.cache-hit != 'true' uses: actions-rs/install@v0.1.2 with: crate: cargo-make version: latest + - name: Build All Feature Permutations uses: actions-rs/cargo@v1.0.1 with: @@ -107,11 +149,25 @@ jobs: run: | sudo apt-get install wabt binaryen cargo install twiggy + + - name: Get cargo-make version + id: cargo-make-version + run: | + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + shell: bash + - name: Cache cargo-make + uses: actions/cache@v2 + id: cargo-make-cache + with: + path: ~/.cargo/bin/cargo-make + key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make + if: steps.cargo-make-cache.outputs.cache-hit != 'true' uses: actions-rs/install@v0.1.2 with: crate: cargo-make version: latest + - name: Build uses: actions-rs/cargo@v1.0.1 with: @@ -139,12 +195,26 @@ jobs: - name: Install rustfmt run: rustup component add rustfmt + + - name: Get cargo-make version + id: cargo-make-version + run: | + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + shell: bash + - name: Cache cargo-make + uses: actions/cache@v2 + id: cargo-make-cache + with: + path: ~/.cargo/bin/cargo-make + key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make + if: steps.cargo-make-cache.outputs.cache-hit != 'true' uses: actions-rs/install@v0.1.2 with: crate: cargo-make version: latest + - name: Check Format uses: actions-rs/cargo@v1.0.1 with: @@ -161,15 +231,25 @@ jobs: - name: Load the default Rust toolchain via the rust-toolchain file. run: rustup show - - name: Install rustfmt - run: rustup component add rustfmt - + - name: Get cargo-make version + id: cargo-make-version + run: | + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + shell: bash + - name: Cache cargo-make + uses: actions/cache@v2 + id: cargo-make-cache + with: + path: ~/.cargo/bin/cargo-make + key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make + if: steps.cargo-make-cache.outputs.cache-hit != 'true' uses: actions-rs/install@v0.1.2 with: crate: cargo-make version: latest + - name: Install cargo-readme uses: actions-rs/install@v0.1.2 with: From 696f573fb9c592db19b3eb05864304ca311f4b68 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 18:03:32 -0700 Subject: [PATCH 15/24] fix duckscript --- tools/scripts/tests.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/scripts/tests.toml b/tools/scripts/tests.toml index fc6d3af91cb..85e00590cfc 100644 --- a/tools/scripts/tests.toml +++ b/tools/scripts/tests.toml @@ -50,11 +50,11 @@ category = "ICU4X Development" script_runner = "@duckscript" script = ''' cd ffi/capi/examples/pluralrules; -make +exec make cd ../fixeddecimal; -make +exec make cd ../locale; -make +exec make ''' [tasks.test-cpp] @@ -63,7 +63,7 @@ category = "ICU4X Development" script_runner = "@duckscript" script = ''' cd ffi/cpp/examples/pluralrules; -make +exec make cd ../fixeddecimal; -make +exec make ''' From 8ffcd496773d3be3500e644b7ecb7a294b859ea5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 18:05:30 -0700 Subject: [PATCH 16/24] Fix syntax --- .github/workflows/build-test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 267eff8a48a..65701c9bc74 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -32,7 +32,7 @@ jobs: - name: Get cargo-make version id: cargo-make-version run: | - echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - name: Cache cargo-make uses: actions/cache@v2 @@ -69,7 +69,7 @@ jobs: - name: Get cargo-make version id: cargo-make-version run: | - echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - name: Cache cargo-make uses: actions/cache@v2 @@ -113,7 +113,7 @@ jobs: - name: Get cargo-make version id: cargo-make-version run: | - echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - name: Cache cargo-make uses: actions/cache@v2 @@ -153,7 +153,7 @@ jobs: - name: Get cargo-make version id: cargo-make-version run: | - echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - name: Cache cargo-make uses: actions/cache@v2 @@ -199,7 +199,7 @@ jobs: - name: Get cargo-make version id: cargo-make-version run: | - echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - name: Cache cargo-make uses: actions/cache@v2 @@ -234,7 +234,7 @@ jobs: - name: Get cargo-make version id: cargo-make-version run: | - echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make ='' | md5sum)" + echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - name: Cache cargo-make uses: actions/cache@v2 From 32e3a434d7170b979334c84f77e6c7bd4108de0e Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 18:12:38 -0700 Subject: [PATCH 17/24] cache cargo-readme too --- .github/workflows/build-test.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 65701c9bc74..ccdbf4aab7c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -249,6 +249,23 @@ jobs: crate: cargo-make version: latest + - name: Get cargo-readme version + id: cargo-readme-version + run: | + echo "::set-output name=hash::$(cargo search cargo-readme | grep '^cargo-readme =' | md5sum)" + shell: bash + - name: Cache cargo-readme + uses: actions/cache@v2 + id: cargo-readme-cache + with: + path: ~/.cargo/bin/cargo-readme + key: ${{ runner.os }}-${{ steps.cargo-readme-version.outputs.hash }} + - name: Install cargo-readme + if: steps.cargo-readme-cache.outputs.cache-hit != 'true' + uses: actions-rs/install@v0.1.2 + with: + crate: cargo-readme + version: latest - name: Install cargo-readme uses: actions-rs/install@v0.1.2 From 01af955b8fe285769697d0fc089fd23c81c44892 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 18:14:57 -0700 Subject: [PATCH 18/24] better action name --- .github/workflows/build-test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index ccdbf4aab7c..dcc34acd5fc 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -34,7 +34,7 @@ jobs: run: | echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - - name: Cache cargo-make + - name: Attempt to load cached cargo-make uses: actions/cache@v2 id: cargo-make-cache with: @@ -71,7 +71,7 @@ jobs: run: | echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - - name: Cache cargo-make + - name: Attempt to load cached cargo-make uses: actions/cache@v2 id: cargo-make-cache with: @@ -115,7 +115,7 @@ jobs: run: | echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - - name: Cache cargo-make + - name: Attempt to load cached cargo-make uses: actions/cache@v2 id: cargo-make-cache with: @@ -155,7 +155,7 @@ jobs: run: | echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - - name: Cache cargo-make + - name: Attempt to load cached cargo-make uses: actions/cache@v2 id: cargo-make-cache with: @@ -201,7 +201,7 @@ jobs: run: | echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - - name: Cache cargo-make + - name: Attempt to load cached cargo-make uses: actions/cache@v2 id: cargo-make-cache with: @@ -236,7 +236,7 @@ jobs: run: | echo "::set-output name=hash::$(cargo search cargo-make | grep '^cargo-make =' | md5sum)" shell: bash - - name: Cache cargo-make + - name: Attempt to load cached cargo-make uses: actions/cache@v2 id: cargo-make-cache with: @@ -254,7 +254,7 @@ jobs: run: | echo "::set-output name=hash::$(cargo search cargo-readme | grep '^cargo-readme =' | md5sum)" shell: bash - - name: Cache cargo-readme + - name: Attempt to load cached cargo-readme uses: actions/cache@v2 id: cargo-readme-cache with: From 118ccb337967b4ac26df8e12b8512db1d84f88be Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 18:20:09 -0700 Subject: [PATCH 19/24] don't double-install --- .github/workflows/build-test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index dcc34acd5fc..3c72f75ffeb 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -267,12 +267,6 @@ jobs: crate: cargo-readme version: latest - - name: Install cargo-readme - uses: actions-rs/install@v0.1.2 - with: - crate: cargo-readme - version: latest - # TODO(#234) re-include cache steps, also using Rust version in cache key - name: Tidy From 0a5e08e1cd311de087aa12bab3cd82dc8ad34505 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 18:28:03 -0700 Subject: [PATCH 20/24] improve cargo tidy --- CONTRIBUTING.md | 2 +- Makefile.toml | 14 +++++++++++--- tools/scripts/tidy.toml | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 304e2aa3aba..d61ab4951c5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,7 +34,7 @@ Each commit and pull request should follow the [style guide][style_guide] and be Handy commands (run from the root directory): -- `cargo tidy` runs tidy-checks (not including fmt/clippy) +- `cargo tidy` runs tidy-checks (license, fmt, readmes) - `cargo quick` runs the fastest tests and lints. - `cargo make ci-all` runs all tests and lints diff --git a/Makefile.toml b/Makefile.toml index e0275b5a47e..a801c560956 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -17,10 +17,18 @@ dependencies = [ "test-all-features", "fmt-check", "clippy-all", - "tidy", + "tidy-minus-fmt", "test-ffi", ] +[tasks.tidy] +description = "Run fmt and other tidy checks" +category = "ICU4X Development" +dependencies = [ + "fmt", + "tidy-minus-fmt", +] + [tasks.ci-job-check] description = "Run all tests for the CI 'check' job" category = "ICU4X Development" @@ -31,8 +39,8 @@ args = ["check", "--all-targets", "--all-features"] description = "Run all tests for the CI 'test' job" category = "CI" dependencies = [ - "test-ffi", "test-all-features", + "test-ffi", "test-docs-default", "test-docs", "bincode-gen-testdata", @@ -56,7 +64,7 @@ dependencies = [ description = "Run all tests for the CI 'tidy' job" category = "CI" dependencies = [ - "tidy", + "tidy-minus-fmt", ] [tasks.ci-job-wasm] diff --git a/tools/scripts/tidy.toml b/tools/scripts/tidy.toml index b9a806a000c..85910686e5f 100644 --- a/tools/scripts/tidy.toml +++ b/tools/scripts/tidy.toml @@ -4,7 +4,7 @@ # This is a cargo-make file included in the toplevel Makefile.toml -[tasks.tidy] +[tasks.tidy-minus-fmt] description = "Run miscellaneous tidy checks" category = "ICU4X Development" dependencies = [ From 09637069301bb874aece0fa607d06f5414eb47c8 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 18:46:56 -0700 Subject: [PATCH 21/24] include exes --- .github/workflows/build-test.yml | 28 +++++++++++++++++++++------- tools/scripts/wasm.toml | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 3c72f75ffeb..39e7d1ddcf1 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -38,7 +38,9 @@ jobs: uses: actions/cache@v2 id: cargo-make-cache with: - path: ~/.cargo/bin/cargo-make + path: | + ~/.cargo/bin/cargo-make + ~/.cargo/bin/cargo-make.exe key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make if: steps.cargo-make-cache.outputs.cache-hit != 'true' @@ -75,7 +77,9 @@ jobs: uses: actions/cache@v2 id: cargo-make-cache with: - path: ~/.cargo/bin/cargo-make + path: | + ~/.cargo/bin/cargo-make + ~/.cargo/bin/cargo-make.exe key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make if: steps.cargo-make-cache.outputs.cache-hit != 'true' @@ -119,7 +123,9 @@ jobs: uses: actions/cache@v2 id: cargo-make-cache with: - path: ~/.cargo/bin/cargo-make + path: | + ~/.cargo/bin/cargo-make + ~/.cargo/bin/cargo-make.exe key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make if: steps.cargo-make-cache.outputs.cache-hit != 'true' @@ -159,7 +165,9 @@ jobs: uses: actions/cache@v2 id: cargo-make-cache with: - path: ~/.cargo/bin/cargo-make + path: | + ~/.cargo/bin/cargo-make + ~/.cargo/bin/cargo-make.exe key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make if: steps.cargo-make-cache.outputs.cache-hit != 'true' @@ -205,7 +213,9 @@ jobs: uses: actions/cache@v2 id: cargo-make-cache with: - path: ~/.cargo/bin/cargo-make + path: | + ~/.cargo/bin/cargo-make + ~/.cargo/bin/cargo-make.exe key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make if: steps.cargo-make-cache.outputs.cache-hit != 'true' @@ -240,7 +250,9 @@ jobs: uses: actions/cache@v2 id: cargo-make-cache with: - path: ~/.cargo/bin/cargo-make + path: | + ~/.cargo/bin/cargo-make + ~/.cargo/bin/cargo-make.exe key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make if: steps.cargo-make-cache.outputs.cache-hit != 'true' @@ -258,7 +270,9 @@ jobs: uses: actions/cache@v2 id: cargo-readme-cache with: - path: ~/.cargo/bin/cargo-readme + path: | + ~/.cargo/bin/cargo-readme + ~/.cargo/bin/cargo-readme.exe key: ${{ runner.os }}-${{ steps.cargo-readme-version.outputs.hash }} - name: Install cargo-readme if: steps.cargo-readme-cache.outputs.cache-hit != 'true' diff --git a/tools/scripts/wasm.toml b/tools/scripts/wasm.toml index 1f81f6bd5e6..6e9a67533b0 100644 --- a/tools/scripts/wasm.toml +++ b/tools/scripts/wasm.toml @@ -211,7 +211,7 @@ dependencies = [ "wasm-wat", "wasm-dcmp", "wasm-opt", - "wasm-twiggy-dowasm-minators", + "wasm-twiggy-dominators", ] [tasks.wasm-test-release] From 5d28850effee1678ece645fef648085d9bfe06cb Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 18:51:07 -0700 Subject: [PATCH 22/24] syntax --- .github/workflows/build-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 39e7d1ddcf1..68154afb9fc 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -166,8 +166,8 @@ jobs: id: cargo-make-cache with: path: | - ~/.cargo/bin/cargo-make - ~/.cargo/bin/cargo-make.exe + ~/.cargo/bin/cargo-make + ~/.cargo/bin/cargo-make.exe key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }} - name: Install cargo-make if: steps.cargo-make-cache.outputs.cache-hit != 'true' From 612f643baf396f908aa3d8932218db2854d638c0 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 9 Jun 2021 19:04:43 -0700 Subject: [PATCH 23/24] fix npm duckscript --- tools/scripts/wasm.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/scripts/wasm.toml b/tools/scripts/wasm.toml index 6e9a67533b0..5a80e781841 100644 --- a/tools/scripts/wasm.toml +++ b/tools/scripts/wasm.toml @@ -220,8 +220,8 @@ category = "ICU4X WASM" script_runner = "@duckscript" script = ''' cd ./ffi/wasm/test; -npm install; -npm test; +exec npm install; +exec npm test; ''' dependencies = ["wasm-release"] From 21eaa1655bc209a02dd690b2baa63085069dece9 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 10 Jun 2021 06:47:39 -0700 Subject: [PATCH 24/24] rm tidy-minus-fmt --- Makefile.toml | 5 +++-- tools/scripts/tidy.toml | 8 -------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index a801c560956..454cb066595 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -26,7 +26,7 @@ description = "Run fmt and other tidy checks" category = "ICU4X Development" dependencies = [ "fmt", - "tidy-minus-fmt", + "ci-job-tidy", ] [tasks.ci-job-check] @@ -64,7 +64,8 @@ dependencies = [ description = "Run all tests for the CI 'tidy' job" category = "CI" dependencies = [ - "tidy-minus-fmt", + "license-header-check", + "generated-readme-check", ] [tasks.ci-job-wasm] diff --git a/tools/scripts/tidy.toml b/tools/scripts/tidy.toml index 85910686e5f..667fef4e923 100644 --- a/tools/scripts/tidy.toml +++ b/tools/scripts/tidy.toml @@ -4,14 +4,6 @@ # This is a cargo-make file included in the toplevel Makefile.toml -[tasks.tidy-minus-fmt] -description = "Run miscellaneous tidy checks" -category = "ICU4X Development" -dependencies = [ - "license-header-check", - "generated-readme-check", -] - [tasks.license-header-check] description = "Ensure all the source files have license headers" category = "ICU4X Development"