Skip to content

Improve build times by caching cargo install artifacts for diesel, clippy, and rustfmt #1216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
fn_args_layout = "Block"
array_layout = "Block"
control_style = "Rfc"
where_style = "Rfc"
generics_indent = "Block"
fn_call_style = "Block"
combine_control_expr = true
fn_args_paren_newline = false
max_width = 100
error_on_line_overflow = false
write_mode = "Overwrite"
Expand Down
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ before_install:
- nvm install 8

install:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
- npm install
- cargo install --force diesel_cli --vers 0.16.0 --debug --no-default-features --features postgres && export PATH=$HOME/.cargo/bin:$PATH
- cargo install --force diesel_cli --vers 1.0.0 --no-default-features --features postgres && export PATH=$HOME/.cargo/bin:$PATH

before_script:
- diesel database setup
Expand All @@ -44,16 +42,17 @@ matrix:
allow_failures:
- rust: nightly
include:
- rust: nightly-2017-11-07
- rust: nightly-2017-12-28
script:
- cargo install --force rustfmt-nightly --vers 0.2.15
- cargo install --force clippy --vers 0.0.169
- cargo install --force rustfmt-nightly --vers 0.3.4
- cargo fmt -- --write-mode=diff
- cargo install --force clippy --vers 0.0.177
- cargo clippy
- rust: stable
script:
- cargo build
- cargo test
- npm install
- npm test
- rust: beta
script:
Expand All @@ -68,6 +67,7 @@ env:
global:
- DATABASE_URL=postgres://postgres:@localhost/cargo_registry_test
- TEST_DATABASE_URL=postgres://postgres:@localhost/cargo_registry_test
- CARGO_TARGET_DIR=target

notifications:
email:
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@ tokio-service = "0.1"
dotenv = "0.10"
diesel = { version = "1.0.0-beta1", features = ["postgres"] }
diesel_migrations = { version = "1.0.0-beta1", features = ["postgres"] }

# Remove once cookie depends on ring >= 0.13.0
[patch.crates-io]
ring = { git = "https://github.com/SergioBenitez/ring", branch = "v0.11" }
12 changes: 9 additions & 3 deletions src/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ pub enum Badge {
repository: String,
branch: Option<String>,
},
IsItMaintainedIssueResolution { repository: String },
IsItMaintainedOpenIssues { repository: String },
IsItMaintainedIssueResolution {
repository: String,
},
IsItMaintainedOpenIssues {
repository: String,
},
Codecov {
repository: String,
branch: Option<String>,
Expand All @@ -41,7 +45,9 @@ pub enum Badge {
branch: Option<String>,
service: Option<String>,
},
Maintenance { status: MaintenanceStatus },
Maintenance {
status: MaintenanceStatus,
},
}

#[derive(Debug, PartialEq, Clone, Copy, Deserialize, Serialize)]
Expand Down
3 changes: 1 addition & 2 deletions src/bin/delete-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ fn delete(conn: &PgConnection) {
let krate = Crate::by_name(&name).first::<Crate>(conn).unwrap();
print!(
"Are you sure you want to delete {} ({}) [y/N]: ",
name,
krate.id
name, krate.id
);
io::stdout().flush().unwrap();
let mut line = String::new();
Expand Down
4 changes: 1 addition & 3 deletions src/bin/delete-version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ fn delete(conn: &PgConnection) {
.unwrap();
print!(
"Are you sure you want to delete {}#{} ({}) [y/N]: ",
name,
version,
v.id
name, version, v.id
);
io::stdout().flush().unwrap();
let mut line = String::new();
Expand Down
32 changes: 10 additions & 22 deletions src/bin/render-readmes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ fn main() {
let config = config.clone();
version.record_readme_rendering(&conn).expect(&format!(
"[{}-{}] Couldn't record rendering time",
krate_name,
version.num
krate_name, version.num
));
let handle = thread::spawn(move || {
println!("[{}-{}] Rendering README...", krate_name, version.num);
Expand All @@ -155,8 +154,7 @@ fn main() {
)
.expect(&format!(
"[{}-{}] Couldn't upload file to S3",
krate_name,
version.num
krate_name, version.num
));
});
tasks.push(handle);
Expand All @@ -182,8 +180,7 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
let date = Utc::now().to_rfc2822();
let url = Url::parse(&location).expect(&format!(
"[{}-{}] Couldn't parse crate URL",
krate_name,
version.num
krate_name, version.num
));

let mut headers = List::new();
Expand All @@ -206,9 +203,7 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
if let Err(err) = req.perform() {
println!(
"[{}-{}] Unable to fetch crate: {}",
krate_name,
version.num,
err
krate_name, version.num, err
);
return None;
}
Expand All @@ -217,31 +212,26 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
let response = String::from_utf8_lossy(&response);
println!(
"[{}-{}] Failed to get a 200 response: {}",
krate_name,
version.num,
response
krate_name, version.num, response
);
return None;
}
let reader = Cursor::new(response);
let reader = GzDecoder::new(reader).expect(&format!(
"[{}-{}] Invalid gzip header",
krate_name,
version.num
krate_name, version.num
));
let mut archive = Archive::new(reader);
let mut entries = archive.entries().expect(&format!(
"[{}-{}] Invalid tar archive entries",
krate_name,
version.num
krate_name, version.num
));
let manifest: Manifest = {
let path = format!("{}-{}/Cargo.toml", krate_name, version.num);
let contents = find_file_by_path(&mut entries, Path::new(&path), version, krate_name);
toml::from_str(&contents).expect(&format!(
"[{}-{}] Syntax error in manifest file",
krate_name,
version.num
krate_name, version.num
))
};
if manifest.package.readme.is_none() {
Expand All @@ -265,8 +255,7 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
manifest.package.repository.as_ref().map(|e| &**e),
).expect(&format!(
"[{}-{}] Couldn't render README",
krate_name,
version.num
krate_name, version.num
))
};
return Some(rendered);
Expand Down Expand Up @@ -315,8 +304,7 @@ fn find_file_by_path<R: Read>(
let mut contents = String::new();
file.read_to_string(&mut contents).expect(&format!(
"[{}-{}] Couldn't read file contents",
krate_name,
version.num
krate_name, version.num
));
contents
}
3 changes: 1 addition & 2 deletions src/bin/transfer-crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ fn transfer(conn: &PgConnection) {

println!(
"Are you sure you want to transfer crates from {} to {}",
from.gh_login,
to.gh_login
from.gh_login, to.gh_login
);
get_confirm("continue");

Expand Down
6 changes: 3 additions & 3 deletions src/boot/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ fn categories_from_toml(
let mut result = vec![];

for (slug, details) in categories {
let details = details.as_table().chain_error(|| {
internal(&format_args!("category {} was not a TOML table", slug))
})?;
let details = details
.as_table()
.chain_error(|| internal(&format_args!("category {} was not a TOML table", slug)))?;

let category = Category::from_parent(
slug,
Expand Down
12 changes: 4 additions & 8 deletions src/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ impl Category {
.collect();
let crate_categories = categories
.iter()
.map(|c| {
CrateCategory {
category_id: c.id,
crate_id: krate.id,
}
.map(|c| CrateCategory {
category_id: c.id,
crate_id: krate.id,
})
.collect::<Vec<_>>();

Expand Down Expand Up @@ -137,9 +135,7 @@ impl Category {
WHERE split_part(c.slug, '::', 1) = c.slug
GROUP BY c.id
{} LIMIT {} OFFSET {}",
sort_sql,
limit,
offset
sort_sql, limit, offset
))).load(conn)
}

Expand Down
4 changes: 1 addition & 3 deletions src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ pub fn add_dependencies(
.map(|dep| {
let krate = Crate::by_name(&dep.name)
.first::<Crate>(&*conn)
.map_err(|_| {
human(&format_args!("no known crate named `{}`", &*dep.name))
})?;
.map_err(|_| human(&format_args!("no known crate named `{}`", &*dep.name)))?;
if dep.version_req == semver::VersionReq::parse("*").unwrap() {
return Err(human(
"wildcard (`*`) dependency constraints are not allowed \
Expand Down
3 changes: 1 addition & 2 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ pub fn parse_github_response<'de, 'a: 'de, T: Deserialize<'de>>(
return Err(internal(&format_args!(
"didn't get a 200 result from \
github, got {} with: {}",
n,
resp
n, resp
)));
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ impl Keyword {
diesel::delete(CrateKeyword::belonging_to(krate)).execute(conn)?;
let crate_keywords = keywords
.into_iter()
.map(|kw| {
CrateKeyword {
crate_id: krate.id,
keyword_id: kw.id,
}
.map(|kw| CrateKeyword {
crate_id: krate.id,
keyword_id: kw.id,
})
.collect::<Vec<_>>();
diesel::insert_into(crates_keywords::table)
Expand Down
42 changes: 19 additions & 23 deletions src/krate/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ pub fn summary(req: &mut Request) -> CargoResult<Response> {
let recent_downloads = sql::<Nullable<BigInt>>("SUM(crate_downloads.downloads)");
let most_recently_downloaded = crates
.left_join(
crate_downloads::table.on(
id.eq(crate_downloads::crate_id)
.and(crate_downloads::date.gt(date(now - 90.days()))),
),
crate_downloads::table.on(id.eq(crate_downloads::crate_id)
.and(crate_downloads::date.gt(date(now - 90.days())))),
)
.group_by(id)
.order(recent_downloads.desc().nulls_last())
Expand Down Expand Up @@ -150,25 +148,23 @@ pub fn show(req: &mut Request) -> CargoResult<Response> {
keywords: Vec<EncodableKeyword>,
categories: Vec<EncodableCategory>,
}
Ok(
req.json(&R {
krate: krate.clone().encodable(
&max_version,
Some(ids),
Some(&kws),
Some(&cats),
Some(badges),
false,
recent_downloads,
),
versions: versions
.into_iter()
.map(|v| v.encodable(&krate.name))
.collect(),
keywords: kws.into_iter().map(|k| k.encodable()).collect(),
categories: cats.into_iter().map(|k| k.encodable()).collect(),
}),
)
Ok(req.json(&R {
krate: krate.clone().encodable(
&max_version,
Some(ids),
Some(&kws),
Some(&cats),
Some(badges),
false,
recent_downloads,
),
versions: versions
.into_iter()
.map(|v| v.encodable(&krate.name))
.collect(),
keywords: kws.into_iter().map(|k| k.encodable()).collect(),
categories: cats.into_iter().map(|k| k.encodable()).collect(),
}))
}

/// Handles the `GET /crates/:crate_id/:version/readme` route.
Expand Down
Loading