Git Product home page Git Product logo

cro3's Introduction

cro3 - Make ChromiumOS development extremely easy

cro3 is an extremely user-friendly tool for ChromiumOS developers.

It provides a simple way to do common development tasks and make the barrier for contributing to ChromiumOS and cro3 itself as low as possible.

It also makes discovering features and functionality as easy as and clear as possible, with command completions.

Moreover, it manages local development hardware including DUTs and Servos, and act as working examples of commands to interact with them.

We hope cro3 gives you some time for a nap and/or coffee, or other tasks by making your work more effective ;)

Core principles

  • Make the basic ChromiumOS development workflow extremely easy
    • Background: There have been a huge barriers to get started with the ChromiumOS development. It scares newcomers sometimes, and such environment is not sustainable, scalable or efficient. The top priority of cro3 is to mitigate this high barrier of entry.
    • Basic workflows include: checkout the source code, build images / deploying packages / run tests with / without modifications.
  • Make it extremely easy to start using cro3
    • Background: As stated in the above, our goal is lowering the barrier for people who are about to start contribution to ChromiumOS. To achive that, a tool that aids the goal should be extremely easy as well to start using it.
    • How: Follow best practices and common ways to do things. Prefer defaults always if there is no clear reason to change that.
  • Be an executable reference of how to do things by providing best practices as a code
    • Background: Documentation can be rotten silently. Code rots as well, but it is easier to notice that it's broken. Also, people tend to prefer coding over writing documents.
    • How: Provide enough background information in the code as comments. Put links to the documentation. Put anything useful that may help future developers and users. Avoid natural languages that is confusing. Instead, translate the logics and steps described in documentation as a code.

Build and install

Install the Rust toolchain and run:

make install

Shell completions

You can install the shell completion by running this at any time:

# Bash
cro3 setup bash-completion

# Zsh
cro3 setup zsh-completion

Please don't forget to follow instructions that are printed after running the command above and reload your shell!

This will be done automatically after make install if your default shell is supported by cro3.

...are you using other shells? We appreciate your pull-requests!

Command line reference

Please refer to docs/cmdline.md ( HTML version )

Tips: You can replace cro3 with cargo run -- to use your own modified version of cro3 instead.

Also, you can preview the command line reference by running:

gh extension install https://github.com/yusukebe/gh-markdown-preview
make preview

How to contribute

After making your change, please run:

make check

to verify your change with formatting checks and unit tests.

Once your commit is ready, please file a pull request on GitHub, as described in CONTRIBUTING.md.

To make sure the commits in the main tree to be bisectable, pull requests will be squashed and rebased on top of the main branch before being merged. Therefore, please make sure that the title and the description of a pull request can be treated as commit messages, before submitting it out for code review.

Happy hacking!

Disclaimer

This is not an officially supported Google product.

cro3's People

Contributors

hikalium avatar wtrgjadmw avatar mhiramat avatar 4n12i avatar brandonpollack23 avatar hidenorikobayashi avatar cynthia avatar dependabot[bot] avatar victorsavu3 avatar chiro avatar

Stargazers

Naoya Tezuka avatar Suraj avatar ANDREASCY avatar Michael Pishchagin avatar  avatar Jarrian Gojar avatar Shunsuke Mie avatar Ivan Chen avatar  avatar Shuhei Kishi avatar Nikita avatar Hayato Ohhashi avatar Yasuhiro Yamada avatar uint256_t avatar  avatar Chia avatar Ryotaro Banno avatar heyhoe avatar tomotomo avatar toto avatar Rizmy Abdulla avatar Jae-woo Kim avatar Seonghyun Park avatar Eishun Kondoh avatar Ubunsoft Corporation avatar Ananya Prasad avatar Tim Kersey avatar Azim Kurt avatar Madhawa Lakshan avatar  avatar hyperbola avatar Koichi Shiraishi avatar koyashiro avatar Hudson Newey avatar

Watchers

 avatar James Cloos avatar  avatar  avatar  avatar

cro3's Issues

pass packages list as positional for `deploy` and `build`

If we pass the packages list as positional argument, we can make it completable.

Let me explain more details.

The bash-completion is implemented by passing all available values to compgen and compgen filters the list using current argument as a prefix.

For example, if a command will get AAA BB BBC and CCC as an option, and if user inputs

command A[tab]
then, the completion script pass AAA BB BBC CCC to compgen. And compgen filters the list and returns only AAA.

If an option also takes AAA BB BBC CCC, same things happens.

But if the option takes a list of those, things become more complex. For example,

command --option "AAA BB[tab]
In this case, the completion script must pass a list of AAA AAA, AAA BB, AAA BBC and AAA CCC. And if

command --option "AAA BB [tab]
(there is a space separator after BB), then AAA BB AAA, AAA BB BB, AAA BB BBC and AAA BB CCC have to be passed. So it has to handle the space separators in the string in bash script. Also, if user add more options, the candidate list becomes longer.

But if we change don't use --option but just pass it as positional argument, we don't care about that.

command AAA BB [tab]
in any case, the completion script can pass AAA BB BBC CCC to compgen.

Pipe-processing friendly output for servo list output

Right now, the default output for servo list is JSON.

It would be nice if we didn't need to rely on arcane methods to massage the output into something usable. For example, here is how you get a list of the usb devices so that it can be processed by a shell script:

lium servo list | jq -r '.[] | map(.serial + ": " + .usb_sysfs_path)[]' \
| awk '{print $2 " " $1;}' | sort | tr -d ':'

Given that this is a CLI first, it'd make sense to make the default output pipe-processing friendly, and make JSON output an opt-in (as that would be more likely something that would be machine-processed).

`lium dut monitor` failed to connect to DUT

lium dut monitor doesn't work because of connection (portforwarding) failure. (ssh_stdout was None)

DUT                             Forward Addr    IP Addr
Failed to reconnect: ssh_stdout was None
krane_HA1584S2                  Reconnecting...

Warn (and confirm interactively) if user deploy "libchrome"

libchrome is a core library of the ChromeOS, and it is frequently updated incompatible way. Thus the user deploy a different version of libchrome, the DUT can be easily bricked.

If lium deploy finds libchrome in the packages list, it can warn user that something like "This can brick the DUT, do you really want to deploy libchrome? [Yes/No]"

And it also recommend user to sync the DUT's image version to the local cros-sdk version.

Add package list cache support

lium should be able to provide a list of packages which is available for build and deploy. Then we can avoid a tragedy of type miss of - and _!

Pass an option to the tast test

Tast test will accept -var option to control test (e.g. mute the sound), so lium tast run would be better to take an option string.

Add a command to fix the entire commit stack by clang-format.py

When working with a stack of commits, I often have to format individual ones by doing git rebase -i, selecting the commit with bad formatting, running clang-format.py, git commit --amend for each commit with bad formatting.

It'd be nice to have lium format that just iterates over every commit in git rebase -i, runs clang-format.py, and git commit --amend the changes.

FYI: one-liner to apply cros format for every commit

git rebase --keep-base --exec 'git diff-tree --no-commit-id --name-only HEAD -r --relative . | xargs -I {} -- cros format {} && git commit --amend -a --no-edit'

Add `lium servo show`

lium servo show --servo ${SERVO_SERIAL}
lium servo show --json --servo ${SERVO_SERIAL}

Add an AI supported interactive mode

Since lium covers so many features and hard to sort the command/subcommand, it is helpful if it has an AI suggested or supported interactive mode. In this mode, user can ask lium how to do something in natural language.

$ lium bard
> what DUTs I have?
(lium): here are your DUTs
lazor_ABCDEFG ...
kaisa_ABCD123 ...
> I want to flash the latest test image on my lazor DUT.
(lium): I do flash the latest (R123-45678.0.0) test image on lazor_ABCDEFG
...
> Oh, I want to update the firmware on that DUT
(lium): I update the firmware on lazor_ABCDEFG
...

default_ipv6_prefix takes any value, and produces non-compliant addresses

default_ipv6_prefix will take any value - and happily generates non-compliant IPv6 addresses.

A common mistake is for users to put in prefixes like:

"default_ipv6_prefix": "aabb:ccdd:1122:3344"

When the expectation is

"default_ipv6_prefix": "aabb:ccdd:1122:3344:"

emphasis on the last colon. There should be some handling for problematic input like this.

(Let's set aside the minor quirk that the address that comes out of the example is probably non-compliant too.)

build --full and flash local image doesn't work

This combination doesn't work

$ lium build --full --board arm64-generic
...
$ lium flash --board generic-arm64 --usb --use-local-image --version latest

Error message is something like,

ERROR: Locating image "xBuddy://local/generic-arm64/latest/test" failed. The path might not be valid or the image might not exist.
ERROR: To get the latest remote image, please run:
cros flash --board=None usb:// remote/latest
ERROR: cros flash failed before completing.
ERROR: Cannot locate image xBuddy://local/generic-arm64/latest/test: No builds found for generic-arm64. Did you run `cros build-image --board generic-arm64`?
ERROR: (Re-run with --debug for more details.)

lium build --full may not build image?

Add support for betty vms

Story

As an internal lium user I want to be be able to create vms both locally and on acloud so that I can connect to a virtual dut that I created form within lium alone so that I can have a virtualized development workflow from within lium.

Requirments

  1. Detection of internl/external user of lium (this won't support external users...yet), printing a sane error if the user is not a googler with gcert activated.
  2. Allow for creation of local vms using betty.sh or directly (if possible it would be nice if instead of using the script we could directly support all the features betty.sh does, but at least at first it will be easier to depend on betty.sh).
  • Selection of image
  • Selection of board
  • selection of display mode
  • run autologin
  • use of a local image
  • selection of android build to push with push_to_device.py
  • sevice account file cheeps mode
  • forwarding any other arguments directly to the script
  1. Allow for creation of vms with acloudw
  • It would be great if this removed the manual process of getting the cheeps image controller version and ab version and just pulled the latest version automatically.
  1. Connect to that vm as a registered dut in lium

Fix --help output

Currently, cargo run -- --help outputs the following. We should do better.

Usage: lium <command> [<args>]

yet another wrapper for CrOS developers. For more information, see: https://chromium.googlesource.com/chromiumos/platform/dev-util/+/refs/heads/main/contrib/lium/ . For Googlers, see go/lium and go/lium-bug

Options:
  --help            display usage information

Commands:
  arc               DUT controller
  build             build a package
  cl                CL (Change List) helpers
  chroot            cros_sdk wrapper
  config            DUT controller
  deploy            cros deploy wrapper
  dut               DUT controller
  flash             Flash CrOS images
  packages          Tast test wrapper
  servo             DUT controller
  setup             DUT controller
  sync              smart repo sync wrapper
  tast              Tast test wrapper
  version           display version info

Add sub-command to reboot into the other partition

It would be convenient if lium can boot into the other set of partition.

The proposal of this feature would be:

  • CLI: lium dut do reboot_other
  • figure out if there are two sets of partitions and run cgpt to prioritize the other one and reboot
  • if the DUT has only one set, it errors out without changing anything on the DUT

Impl command to query tast CI result

Given there is a script to get tast CI result, we can implement a wrapper to query the latest result and integrate it with other commands. e.g.

lium tast result --last-success --test ${TEST} --model ${MODEL}

b/271811998

Create a rustfmt.toml and reformat

This is based on my own rustfmt.toml I usually use. I tend to set these for the following reasons:

imports_granularity = "Crate" # this combines a bunch of lines at the top, but it doesnt match google style so I removed it
tab_spaces = 2 # param lists and chained calls tend to be longer and more common in rust, I think this increases readability
fn_params_layout = "Tall" # this is way easier to read than non tall
format_strings = true
use_try_shorthand = true # replace any ugly try! macros with the pretty ?
wrap_comments = true
max_width = 100 # If we can do it in Java, we can do it in Rust

implement a command to read / write GBB flag via servo

make a wrapper for this:

# (in chroot)
sudo emerge -1 hdctools
sudo flashrom -p raiden_debug_spi:target=AP,serial=0780A02E-8C65B668 -r -i GBB:/tmp/gbb.bin
sudo futility gbb -s --flags=0x40b9 /tmp/gbb.bin /tmp/gbb2.bin
sudo flashrom -p raiden_debug_spi:target=AP,serial=0780A02E-8C65B668 -w -i GBB:/tmp/gbb2.bin --noverify-all

Add a device to the list which doesn't have serial number

lium dut list --add requires serial number to add a device to the local DUT list. But some devices don't have the serial number.
Use some hash (e.g. from IPv6 addr) number if the device has no serial number. (But warn user that this device name is local one)

add --servo arg for lium dut do

Low-level operations like reboot can be done via servo as well and we should support doing such kind of tasks via servo as well for making recovery easy.

list known board and complete it

Add a feature to list known board (once it is used, it is registered) and complete it on the command line.
Maybe lium dut info will also be able to add its board name to this boad list. But mostly, the name passed to the --board option will be added if the command succeeded.

Do not crash lium on depot_tools update failure

For some reasons, I had depot_tools modified (which I do not know where it came from).
This caused lium to crash on sync .

Adding some printfs revealed that the variable repos in repo_sync() was empty. (Thanks @cynthia !)
So we should not do the following without checking that

let repos = repos[1..=repos.len() - 2].to_owned();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.