Merge remote-tracking branch 'gbeck/master'

pull/9/head
Tomasz Drwięga 5 years ago
commit d322c48878
No known key found for this signature in database
GPG Key ID: 32E366A18EED312D

@ -0,0 +1,27 @@
stages:
- audit
- build
image: ${REGISTRY}/parity-ci-linux:latest
variables:
GIT_STRATEGY: fetch
GIT_SUBMODULE_STRATEGY: recursive
CI_SERVER_NAME: "GitLab CI"
CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}"
CARGO_TARGET: x86_64-unknown-linux-gnu
REGISTRY: registry.parity.io/parity/infrastructure/scripts
cargo_audit:
stage: audit
script:
- cargo audit
tags:
- linux-docker
allow_failure: true
cargo_remote_build:
stage: build
script:
- cargo build --release
tags:
- linux-docker

@ -25,7 +25,7 @@ the same rust version and have the same processor architecture. On the client `s
and `rsync` need to be installed.
If you want to pass remote flags you have to end the options/flags section using
`--`. E.g. to build in release mode and copy back the result use:
`--`. E.g. to build in release mode and copy back the result use:
```bash
cargo remote -c -- build --release
```
@ -42,29 +42,32 @@ remote = "builds@myserver"
### Flags and options
```
cargo-remote
USAGE:
cargo remote [FLAGS] [OPTIONS] <command>
cargo remote [FLAGS] [OPTIONS] <command> [remote options]...
FLAGS:
-c, --copy-back transfer the target folder back to the local machine
-c, --copy-back Transfer the target folder back to the local machine
--help Prints help information
-h, --transfer-hidden transfer hidden files and directories to the build server
-h, --transfer-hidden Transfer hidden files and directories to the build server
-V, --version Prints version information
OPTIONS:
--manifest-path <manifest_path> Path to the manifest to execute
-r, --remote <remote> remote ssh build server
-b, --build-env <build_env> Set remote environment variables. RUST_BACKTRACE, CC, LIB, etc. [default:
RUST_BACKTRACE=1]
-e, --env <env> Environment profile. default_value = /etc/profile [default: /etc/profile]
--manifest-path <manifest_path> Path to the manifest to execute [default: Cargo.toml]
-r, --remote <remote> Remote ssh build server
-d, --rustup-default <rustup_default> Rustup default (stable|beta|nightly) [default: stable]
ARGS:
<command> cargo command that will be executed remotely
<command> cargo command that will be executed remotely
<remote options>... cargo options and flags that will be applied remotely
```
## How to install
```bash
git clone https://github.com/sgeisler/cargo-remote.git
cd cargo-remote
cargo install
git clone https://gitlab.parity.io/General-Beck/cargo-remote.git
cargo install --path cargo-remote/
```

@ -0,0 +1,37 @@
1 step
nano /etc/profile
export PATH=/usr/local/cargo/bin:$PATH
export RUSTUP_HOME=/usr/local/rustup
export CARGO_HOME=/usr/local/cargo
2 install rust
wget https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --default-toolchain stable; \
rm rustup-init; \
chmod -R a+w+r /usr/local/cargo/; \
chmod -R a+w+r /usr/local/cargo/; \
rustup install nightly beta; \
rustup target add wasm32-unknown-unknown --toolchain nightly; \
cargo install cargo-audit --force; \
cargo install sccache --features redis --force; \
cargo install --git https://github.com/alexcrichton/wasm-gc --force ;
3 redis
protected mode no
maxmemory 50gb
maxmemory-policy allkeys-lru
service redis restart
3 setup sccache+redis
nano /etc/profile
export PATH=/usr/local/cargo/bin:$PATH
export RUSTUP_HOME=/usr/local/rustup
export CARGO_HOME=/usr/local/cargo
export SCCACHE_IDLE_TIMEOUT=0
export SCCACHE_REDIS=redis://127.0.0.1/0
export RUSTC_WRAPPER=sccache
4 user
export PATH="$HOME/.cargo/bin:$PATH"
export RUSTUP_HOME=$HOME/.rustup
export CARGO_HOME=$HOME/.cargo
rustup install stable

@ -1,6 +1,5 @@
use std::path::{Path, PathBuf};
use std::process::{exit, Command, Stdio};
use structopt::StructOpt;
use toml::Value;
@ -11,13 +10,37 @@ use log::{error, info, warn};
enum Opts {
#[structopt(name = "remote")]
Remote {
#[structopt(short = "r", long = "remote", help = "remote ssh build server")]
#[structopt(short = "r", long = "remote", help = "Remote ssh build server")]
remote: Option<String>,
#[structopt(
short = "b",
long = "build-env",
help = "Set remote environment variables. RUST_BACKTRACE, CC, LIB, etc. ",
default_value = "RUST_BACKTRACE=1"
)]
build_env: String,
#[structopt(
short = "d",
long = "rustup-default",
help = "Rustup default (stable|beta|nightly)",
default_value = "stable"
)]
rustup_default: String,
#[structopt(
short = "e",
long = "env",
help = "Environment profile. default_value = /etc/profile",
default_value = "/etc/profile"
)]
env: String,
#[structopt(
short = "c",
long = "copy-back",
help = "transfer the target folder or specific file from that folder back to the local machine"
help = "Transfer the target folder or specific file from that folder back to the local machine"
)]
copy_back: Option<Option<String>>,
@ -38,7 +61,7 @@ enum Opts {
#[structopt(
short = "h",
long = "transfer-hidden",
help = "transfer hidden files and directories to the build server"
help = "Transfer hidden files and directories to the build server"
)]
hidden: bool,
@ -85,6 +108,9 @@ fn main() {
let Opts::Remote {
remote,
build_env,
rustup_default,
env,
copy_back,
no_copy_lock,
manifest_path,
@ -97,16 +123,22 @@ fn main() {
metadata_cmd.manifest_path(manifest_path).no_deps();
let project_metadata = metadata_cmd.exec().unwrap();
// for now, assume that there is only one project and find it's root directory
let (project_dir, project_name) = project_metadata.packages.first().map_or_else(
|| {
error!("No project found.");
exit(-2);
},
|project| (&project_metadata.workspace_root, &project.name),
);
let project_dir = project_metadata.workspace_root;
info!("Project dir: {:?}", project_dir);
let mut manifest_path = project_dir.clone();
manifest_path.push("Cargo.toml");
let project_name = project_dir;
// .packages
// .iter()
// .find(|p| p.manifest_path == manifest_path)
// .map_or_else(
// || {
// info!("No metadata found. Use project dir name for remote");
// |p| p.name == project_dir;
// },
// |p| &p.name,
// );
info!("Project name: {:?}", project_name);
let configs = vec![
config_from_file(&project_dir.join(".cargo-remote.toml")),
xdg::BaseDirectories::with_prefix("cargo-remote")
@ -128,7 +160,7 @@ fn main() {
exit(-3);
});
let build_path = format!("~/remote-builds/{}/", project_name);
let build_path = format!("~/remote-builds/{:?}/", project_name);
info!("Transferring sources to build server.");
// transfer project to build server
@ -136,6 +168,7 @@ fn main() {
rsync_to
.arg("-a".to_owned())
.arg("--delete")
.arg("--compress")
.arg("--info=progress2")
.arg("--exclude")
.arg("target");
@ -157,17 +190,21 @@ fn main() {
error!("Failed to transfer project to build server (error: {})", e);
exit(-4);
});
info!("Build ENV: {:?}", build_env);
info!("Environment profile: {:?}", env);
info!("Build path: {:?}", build_path);
let build_command = format!(
"cd {}; $HOME/.cargo/bin/cargo {} {}",
"source {}; rustup default {}; cd {}; {} cargo {} {}",
env,
rustup_default,
build_path,
build_env,
command,
options.join(" ")
);
info!("Starting build process.");
let output = Command::new("ssh")
.arg("-t")
.arg(&build_server)
.arg(build_command)
.stdout(Stdio::inherit())

Loading…
Cancel
Save