Skip to content

Commit

Permalink
Repro builds: Deterministically iterate through docker/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
kpcyrd committed Jul 22, 2021
1 parent 7405f27 commit b726b10
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::env;
use std::error::Error;
use std::fs::{read_dir, File};
use std::io::Write;
use std::fs::File;
use std::io::{self, Write};
use std::path::PathBuf;
use std::process::Command;

Expand Down Expand Up @@ -63,15 +63,21 @@ fn docker_images() -> String {
let mut images = String::from("[");
let mut dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
dir.push("docker");
for entry in read_dir(dir).unwrap() {
let path = entry.unwrap().path();

let dir = dir.read_dir().unwrap();
let mut paths = dir.collect::<io::Result<Vec<_>>>().unwrap();
paths.sort_by_key(|e| e.path());

for entry in paths {
let path = entry.path();
let file_name = path.file_name().unwrap().to_str().unwrap();
if file_name.starts_with("Dockerfile.") {
images.push_str("\"");
images.push_str(&file_name.replacen("Dockerfile.", "", 1));
images.push_str("\", ");
}
}

images.push_str("]");
images
}

0 comments on commit b726b10

Please sign in to comment.