From e366508b76c9fa00bdbb97a39362f3accd575363 Mon Sep 17 00:00:00 2001 From: Jason LeBrun Date: Fri, 24 May 2024 20:03:35 +0000 Subject: [PATCH] Remove some unused xtask code Change-Id: I70313a00604b984417c6d990d8a76424ecaf6f5f --- .xtask_bash_completion | 182 +---------------------------------------- Cargo.lock | 2 - xtask/Cargo.toml | 4 +- xtask/src/examples.rs | 40 +-------- xtask/src/internal.rs | 5 -- xtask/src/launcher.rs | 11 --- xtask/src/main.rs | 51 +----------- 7 files changed, 5 insertions(+), 290 deletions(-) diff --git a/.xtask_bash_completion b/.xtask_bash_completion index af66355fe66..85c337d60cc 100644 --- a/.xtask_bash_completion +++ b/.xtask_bash_completion @@ -12,9 +12,6 @@ _xtask() { ",$1") cmd="xtask" ;; - xtask,build-enclave-binary) - cmd="xtask__build__enclave__binary" - ;; xtask,check-format) cmd="xtask__check__format" ;; @@ -27,9 +24,6 @@ _xtask() { xtask,help) cmd="xtask__help" ;; - xtask,run-cargo-clean) - cmd="xtask__run__cargo__clean" - ;; xtask,run-cargo-clippy) cmd="xtask__run__cargo__clippy" ;; @@ -39,24 +33,12 @@ _xtask() { xtask,run-cargo-fuzz) cmd="xtask__run__cargo__fuzz" ;; - xtask,run-cargo-tests) - cmd="xtask__run__cargo__tests" - ;; xtask,run-cargo-udeps) cmd="xtask__run__cargo__udeps" ;; - xtask,run-ci) - cmd="xtask__run__ci" - ;; - xtask,run-oak-functions-example) - cmd="xtask__run__oak__functions__example" - ;; xtask,run-tests) cmd="xtask__run__tests" ;; - xtask__help,build-enclave-binary) - cmd="xtask__help__build__enclave__binary" - ;; xtask__help,check-format) cmd="xtask__help__check__format" ;; @@ -69,9 +51,6 @@ _xtask() { xtask__help,help) cmd="xtask__help__help" ;; - xtask__help,run-cargo-clean) - cmd="xtask__help__run__cargo__clean" - ;; xtask__help,run-cargo-clippy) cmd="xtask__help__run__cargo__clippy" ;; @@ -81,18 +60,9 @@ _xtask() { xtask__help,run-cargo-fuzz) cmd="xtask__help__run__cargo__fuzz" ;; - xtask__help,run-cargo-tests) - cmd="xtask__help__run__cargo__tests" - ;; xtask__help,run-cargo-udeps) cmd="xtask__help__run__cargo__udeps" ;; - xtask__help,run-ci) - cmd="xtask__help__run__ci" - ;; - xtask__help,run-oak-functions-example) - cmd="xtask__help__run__oak__functions__example" - ;; xtask__help,run-tests) cmd="xtask__help__run__tests" ;; @@ -103,7 +73,7 @@ _xtask() { case "${cmd}" in xtask) - opts="-h --dry-run --logs --keep-going --help build-enclave-binary run-oak-functions-example format check-format run-tests run-cargo-clippy run-cargo-tests run-cargo-fuzz run-cargo-deny run-cargo-udeps run-ci run-cargo-clean completion help" + opts="-h --dry-run --logs --keep-going --help format check-format run-tests run-cargo-clippy run-cargo-fuzz run-cargo-deny run-cargo-udeps completion help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -116,20 +86,6 @@ _xtask() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; - xtask__build__enclave__binary) - opts="-h --help" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; xtask__check__format) opts="-h --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then @@ -177,7 +133,7 @@ _xtask() { return 0 ;; xtask__help) - opts="build-enclave-binary run-oak-functions-example format check-format run-tests run-cargo-clippy run-cargo-tests run-cargo-fuzz run-cargo-deny run-cargo-udeps run-ci run-cargo-clean completion help" + opts="format check-format run-tests run-cargo-clippy run-cargo-fuzz run-cargo-deny run-cargo-udeps completion help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -190,20 +146,6 @@ _xtask() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; - xtask__help__build__enclave__binary) - opts="" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; xtask__help__check__format) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -260,20 +202,6 @@ _xtask() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; - xtask__help__run__cargo__clean) - opts="" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; xtask__help__run__cargo__clippy) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -316,20 +244,6 @@ _xtask() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; - xtask__help__run__cargo__tests) - opts="" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; xtask__help__run__cargo__udeps) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -344,34 +258,6 @@ _xtask() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; - xtask__help__run__ci) - opts="" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; - xtask__help__run__oak__functions__example) - opts="" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; xtask__help__run__tests) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -386,20 +272,6 @@ _xtask() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; - xtask__run__cargo__clean) - opts="-h --help" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; xtask__run__cargo__clippy) opts="-h --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then @@ -446,20 +318,6 @@ _xtask() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; - xtask__run__cargo__tests) - opts="-h --cleanup --help" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; xtask__run__cargo__udeps) opts="-h --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then @@ -474,42 +332,6 @@ _xtask() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; - xtask__run__ci) - opts="-h --help" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; - xtask__run__oak__functions__example) - opts="-h --example-name --lookup-data-path --help" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - fi - case "${prev}" in - --example-name) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - --lookup-data-path) - COMPREPLY=($(compgen -f "${cur}")) - return 0 - ;; - *) - COMPREPLY=() - ;; - esac - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) - return 0 - ;; xtask__run__tests) opts="-h --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then diff --git a/Cargo.lock b/Cargo.lock index 8afb98060cb..aa75b8589e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6036,12 +6036,10 @@ dependencies = [ "colored", "itertools 0.12.1", "nix 0.27.1", - "oak_functions_test_utils", "once_cell", "portpicker", "regex", "serde", - "serde_yaml", "strum 0.24.1", "strum_macros", "tokio", diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 47c325bcf2c..8b948f0884f 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -16,13 +16,11 @@ clap = { version = "*", features = ["derive"] } clap_complete = "*" colored = "*" itertools = "*" -nix = "*" -oak_functions_test_utils = { workspace = true } +nix = { version = "*", features = ["signal"] } once_cell = "*" portpicker = "*" regex = "*" serde = { version = "*", features = ["derive"] } -serde_yaml = "*" strum = "0.24" strum_macros = "0.25" tokio = { version = "*", features = [ diff --git a/xtask/src/examples.rs b/xtask/src/examples.rs index 07932341d3d..4c4cfbe6ff2 100644 --- a/xtask/src/examples.rs +++ b/xtask/src/examples.rs @@ -14,14 +14,7 @@ // limitations under the License. // -use crate::{ - internal::*, - launcher, - launcher::{ - build_binary, build_stage0, run_oak_functions_launcher_example_with_lookup_data, - MOCK_LOOKUP_DATA_PATH, - }, -}; +use crate::internal::*; /// Build the Rust crate that will be used as the Wasm module for the Oak /// Functions server. @@ -39,34 +32,3 @@ pub fn build_rust_crate_wasm(crate_name: &str) -> Step { ), } } - -pub fn run_oak_functions_example(opt: &RunOakExampleOpt) -> Step { - let app = launcher::App::from_crate_name("oak_functions_enclave_app"); - - let wasm_path = oak_functions_test_utils::rust_crate_wasm_out_path(&opt.example_name); - - Step::Multiple { - name: "run Oak Functions example".to_string(), - steps: vec![ - build_stage0(), - crate::launcher::just_build("oak_restricted_kernel_wrapper"), - build_binary( - "build Oak Restricted Kernel orchestrator", - &launcher::App::from_crate_name("oak_orchestrator").enclave_crate_path(), - ), - build_binary("build Oak Functions enclave app", &app.enclave_crate_path()), - build_rust_crate_wasm(&opt.example_name), - Step::Single { - name: "server".to_string(), - command: run_oak_functions_launcher_example_with_lookup_data( - &app, - &wasm_path, - 8080, - &opt.lookup_data_path - .clone() - .unwrap_or(MOCK_LOOKUP_DATA_PATH.to_str().unwrap().to_string()), - ), - }, - ], - } -} diff --git a/xtask/src/internal.rs b/xtask/src/internal.rs index f0b889cde9e..d1a8f6b5b3f 100644 --- a/xtask/src/internal.rs +++ b/xtask/src/internal.rs @@ -44,18 +44,13 @@ pub struct Opt { #[derive(Subcommand, Clone, Debug)] pub enum Command { - BuildEnclaveBinary, - RunOakFunctionsExample(RunOakExampleOpt), Format, CheckFormat, RunTests, RunCargoClippy, - RunCargoTests(RunTestsOpt), RunCargoFuzz(RunCargoFuzz), RunCargoDeny, RunCargoUdeps, - RunCi, - RunCargoClean, #[command(about = "generate bash completion script to stdout")] Completion(Completion), } diff --git a/xtask/src/launcher.rs b/xtask/src/launcher.rs index 9bdcb5fb118..b4e7a3e3c0c 100644 --- a/xtask/src/launcher.rs +++ b/xtask/src/launcher.rs @@ -114,17 +114,6 @@ impl App { } } -pub fn build_enclave_binary() -> Step { - Step::Single { - name: "Build enclave binary variants".to_string(), - command: Cmd::new_in_dir( - "cargo", - vec!["build", "--release"], - Path::new(&App::from_crate_name("").enclave_crate_path()), - ), - } -} - pub fn build_stage0() -> Step { Step::Single { name: "build stage0".to_string(), diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 5433694ee63..730b33a4b6f 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -33,10 +33,9 @@ use xtask::{ check_build_licenses::*, check_license::*, check_todo::*, - examples::*, files::*, internal::{self, *}, - launcher, spread, + spread, }; #[tokio::main] @@ -93,19 +92,14 @@ async fn main() -> Result<(), Box> { fn match_cmd(opt: &Opt) -> Step { match opt.cmd { - Command::BuildEnclaveBinary => launcher::build_enclave_binary(), - Command::RunOakFunctionsExample(ref run_opt) => run_oak_functions_example(run_opt), Command::RunTests => run_tests(), Command::RunCargoClippy => run_cargo_clippy(), - Command::RunCargoTests(ref run_opt) => run_cargo_tests(run_opt), Command::RunCargoFuzz(ref opt) => run_cargo_fuzz(opt), Command::Format => format(), Command::CheckFormat => check_format(), - Command::RunCi => run_ci(), Command::Completion(ref opt) => run_completion(opt), Command::RunCargoDeny => run_cargo_deny(), Command::RunCargoUdeps => run_cargo_udeps(), - Command::RunCargoClean => run_cargo_clean(), } } @@ -222,33 +216,6 @@ fn run_completion(completion: &Completion) -> Step { Step::Multiple { name: "cargo completion".to_string(), steps: vec![] } } -fn run_ci() -> Step { - // parse cmds for ./scripts/xtask from ci.yaml to keep them in sync - let path_to_ci_yaml = ".github/workflows/ci.yaml"; - let file = std::fs::File::open(path_to_ci_yaml).expect("couldn't open file"); - let contents: serde_yaml::Value = - serde_yaml::from_reader(file).expect("couldn't read file contents"); - let mut ci_cmds = contents["jobs"]["xtask"]["strategy"]["matrix"]["cmd"] - .as_sequence() - .unwrap() - .iter() - .map(|c| c.as_str().unwrap().split_whitespace().collect()) - .collect::>>(); - - Step::Multiple { - name: "ci".to_string(), - steps: ci_cmds - .iter_mut() - .map(|cmd| { - let mut call = vec!["xtask"]; - call.append(cmd); - let opt = Opt::parse_from(call); - match_cmd(&opt) - }) - .collect(), - } -} - enum FormatMode { Check, Fix, @@ -608,19 +575,3 @@ fn run_cargo_udeps() -> Step { .collect(), } } - -fn run_cargo_clean() -> Step { - Step::Multiple { - name: "cargo clean".to_string(), - steps: crate_manifest_files() - .map(to_string) - .map(|manifest_path| Step::Single { - name: manifest_path.clone(), - command: Cmd::new( - "cargo", - ["clean", &format!("--manifest-path={}", manifest_path)], - ), - }) - .collect(), - } -}