From b2822df14d5f134b26f0e50a63c4e6ce17f21d3c Mon Sep 17 00:00:00 2001 From: Andrea Campi Date: Fri, 15 Mar 2024 09:59:12 -0700 Subject: [PATCH] Refactor the dev setup scripts to avoid duplication Summary: I recently added a third script (setup_lfs_server.sh) on top of the existing two, and that introduced even more copy and pasta; reviewers flagged that. Duplication also makes it hard to add new common functionality (e.g. using configerator vs local files). This diff introduces two more functions that let us cut down individual scripts by ~60%. The price for that is some complexity in the functions: consuming and filtering command-line flags pretty much requires arrays; reading and saving configuration requires references. I tried to make future maintenance easier by adding good comments and unit tests. Differential Revision: D54945927 fbshipit-source-id: c58a5b7b6110bc7f789d331d609fb802f08be6f0 --- eden/mononoke/facebook/scripts/TARGETS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eden/mononoke/facebook/scripts/TARGETS b/eden/mononoke/facebook/scripts/TARGETS index 2530f4443dc6b..6b772801d0bbb 100644 --- a/eden/mononoke/facebook/scripts/TARGETS +++ b/eden/mononoke/facebook/scripts/TARGETS @@ -1,3 +1,4 @@ +load("@fbcode_macros//build_defs:custom_unittest.bzl", "custom_unittest") load("@fbcode_macros//build_defs:native_rules.bzl", "buck_filegroup") load("@fbsource//tools/build_defs:glob_defs.bzl", "glob") load("//antlir/fbpkg:fbpkg.bzl", "fbpkg") @@ -28,3 +29,11 @@ fbpkg.builder( "scripts": ":scripts", }, ) + +custom_unittest( + name = "setup_common_test", + command = [ + "eden/mononoke/facebook/scripts/setup_common_test.sh", + ], + type = "simple", +)