rusty_ci/buildsystem/
bash.rs

1use crate::buildsystem::BuildSystem;
2use crate::{yes_or_no, File, AUTH_TOKEN_PATH};
3use std::process::exit;
4
5/// This is the best build system rusty-ci supports right now.
6/// It writes the dependency installation instructions to a shell script file,
7/// And tells you how to use them.
8/// The process for building the master and the workers is set to the default.
9#[derive(Default)]
10pub struct Bash;
11
12impl BuildSystem for Bash {
13    /// Writes install script to `install.sh` for user to run
14    fn install(&mut self) -> Result<(), String> {
15        if !yes_or_no(
16            "Do you already have python3-dev, python3-pip, and python3-venv installed? (y/n) ",
17        ) {
18            error!("You must install those packages before continuing!");
19            exit(0);
20        }
21        info!("Writing install file to `./install.sh`");
22        File::write(
23            "install.sh",
24            "#!/bin/sh
25
26python3 -m venv venv 2>&1
27. venv/bin/activate
28
29python3 -m pip install -U pip >/dev/null
30python3 -m pip install txrequests treq 'buildbot[bundle]' >/dev/null
31python3 -m pip install buildbot-worker setuptools-trial >/dev/null
32",
33        )?;
34        info!("Successfully wrote install file");
35        warn!("To install dependencies run `install.sh`");
36        warn!("Before building from a YAML file, be sure to run `. venv/bin/activate`");
37        info!(
38            "Next, write your VCS's api token to '{}', and then run the `build` subcommand",
39            AUTH_TOKEN_PATH
40        );
41        Ok(())
42    }
43
44    fn install_python(&mut self) -> Result<(), String> {
45        Ok(())
46    }
47    fn install_buildbot(&mut self) -> Result<(), String> {
48        Ok(())
49    }
50}