Skip to content
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

chore: speed up CI with new Cargo profile #755

Merged
merged 3 commits into from
Nov 20, 2024
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
9 changes: 5 additions & 4 deletions .github/workflows/build-artifacts-and-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,18 @@ jobs:
# there's no way to run tests for ARM64 Windows for now
if: matrix.target != 'aarch64-pc-windows-msvc'
run: |
${{ env.CARGO }} +stable test --release --target ${{ matrix.target }} $EXTRA_CARGO_FLAGS
${{ env.CARGO }} +stable test --profile fast --target ${{ matrix.target }} $EXTRA_CARGO_FLAGS

- name: Build artifacts (binary and completions)
- name: Build release artifacts (binary and completions)
if: ${{ inputs.upload_artifacts }}
run: |
${{ env.CARGO }} +stable build --release --target ${{ matrix.target }} $EXTRA_CARGO_FLAGS
env:
OUCH_ARTIFACTS_FOLDER: artifacts

- name: Upload artifacts
uses: actions/upload-artifact@v4
- name: Upload release artifacts
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@v4
with:
name: ouch-${{ matrix.target }}-${{ steps.concat-features.outputs.FEATURES }}
path: |
Expand Down
30 changes: 25 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[package]
name = "ouch"
version = "0.5.1"
authors = ["Vinícius Rodrigues Miguel <[email protected]>", "João M. Bezerra <[email protected]>"]
authors = [
"João M. Bezerra <[email protected]>",
"Vinícius Rodrigues Miguel <[email protected]>",
]
edition = "2021"
readme = "README.md"
repository = "https://github.com/ouch-org/ouch"
Expand All @@ -20,7 +23,9 @@ clap = { version = "4.5.20", features = ["derive", "env"] }
filetime_creation = "0.2"
flate2 = { version = "1.0.30", default-features = false }
fs-err = "2.11.0"
gzp = { version = "0.11.3", default-features = false, features = ["snappy_default"] }
gzp = { version = "0.11.3", default-features = false, features = [
"snappy_default",
] }
ignore = "0.4.23"
libc = "0.2.155"
linked-hash-map = "0.5.6"
Expand All @@ -36,8 +41,11 @@ tempfile = "3.10.1"
time = { version = "0.3.36", default-features = false }
unrar = { version = "0.5.6", optional = true }
xz2 = "0.1.7"
zip = { version = "0.6.6", default-features = false, features = ["time", "aes-crypto"] }
zstd = { version = "0.13.2", default-features = false, features = ["zstdmt"]}
zip = { version = "0.6.6", default-features = false, features = [
"time",
"aes-crypto",
] }
zstd = { version = "0.13.2", default-features = false, features = ["zstdmt"] }

[target.'cfg(not(unix))'.dependencies]
is_executable = "1.0.1"
Expand All @@ -53,7 +61,10 @@ infer = "0.16.0"
insta = { version = "1.40.0", features = ["filters"] }
parse-display = "0.9.1"
proptest = "1.5.0"
rand = { version = "0.8.5", default-features = false, features = ["small_rng", "std"] }
rand = { version = "0.8.5", default-features = false, features = [
"small_rng",
"std",
] }
regex = "1.10.4"
test-strategy = "0.4.0"

Expand All @@ -62,8 +73,17 @@ default = ["use_zlib", "use_zstd_thin", "unrar"]
use_zlib = ["flate2/zlib", "gzp/deflate_zlib", "zip/deflate-zlib"]
use_zstd_thin = ["zstd/thin"]

# For generating binaries for releases
[profile.release]
lto = true
codegen-units = 1
opt-level = 3
strip = true

# When we need a fast binary that compiles slightly faster `release` (useful for CI)
[profile.fast]
inherits = "release"
lto = false
opt-level = 2
incremental = true
codegen-units = 16
31 changes: 13 additions & 18 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ fn single_empty_file(ext: Extension, #[any(size_range(0..8).lift())] exts: Vec<F
}

/// Compress and decompress a single file
#[proptest(cases = 250)]
#[proptest(cases = 150)]
fn single_file(
ext: Extension,
#[any(size_range(0..8).lift())] exts: Vec<FileExtension>,
#[cfg_attr(not(target_arch = "arm"), strategy(proptest::option::of(0i16..12)))]
// Decrease the value of --level flag for `arm` systems, because our GitHub
// Actions CI runs QEMU which makes the memory consumption higher.
#[cfg_attr(target_arch = "arm", strategy(proptest::option::of(0i16..8)))]
#[any(size_range(0..6).lift())] exts: Vec<FileExtension>,
// Use faster --level for slower CI targets
#[cfg_attr(not(any(target_arch = "arm", target_abi = "eabihf")), strategy(proptest::option::of(0i16..12)))]
#[cfg_attr(target_arch = "arm", strategy(proptest::option::of(0i16..6)))]
level: Option<i16>,
) {
let dir = tempdir().unwrap();
Expand Down Expand Up @@ -135,10 +134,9 @@ fn single_file(
fn single_file_stdin(
ext: Extension,
#[any(size_range(0..8).lift())] exts: Vec<FileExtension>,
#[cfg_attr(not(target_arch = "arm"), strategy(proptest::option::of(0i16..12)))]
// Decrease the value of --level flag for `arm` systems, because our GitHub
// Actions CI runs QEMU which makes the memory consumption higher.
#[cfg_attr(target_arch = "arm", strategy(proptest::option::of(0i16..8)))]
// Use faster --level for slower CI targets
#[cfg_attr(not(any(target_arch = "arm", target_abi = "eabihf")), strategy(proptest::option::of(0i16..12)))]
#[cfg_attr(target_arch = "arm", strategy(proptest::option::of(0i16..6)))]
level: Option<i16>,
) {
let dir = tempdir().unwrap();
Expand Down Expand Up @@ -175,22 +173,19 @@ fn single_file_stdin(
assert_same_directory(before, after, false);
}

/// Compress and decompress a directory with random content generated with create_random_files
///
/// This one runs only 50 times because there are only `.zip` and `.tar` to be tested, and
/// single-file formats testing is done in the other test
#[proptest(cases = 50)]
/// Compress and decompress a directory with random content generated with `create_random_files`
#[proptest(cases = 25)]
fn multiple_files(
ext: DirectoryExtension,
#[any(size_range(0..5).lift())] exts: Vec<FileExtension>,
#[strategy(0u8..4)] depth: u8,
#[any(size_range(0..1).lift())] extra_extensions: Vec<FileExtension>,
#[strategy(0u8..3)] depth: u8,
) {
let dir = tempdir().unwrap();
let dir = dir.path();
let before = &dir.join("before");
let before_dir = &before.join("dir");
fs::create_dir_all(before_dir).unwrap();
let archive = &dir.join(format!("archive.{}", merge_extensions(&ext, exts)));
let archive = &dir.join(format!("archive.{}", merge_extensions(&ext, extra_extensions)));
let after = &dir.join("after");
create_random_files(before_dir, depth, &mut SmallRng::from_entropy());
ouch!("-A", "c", before_dir, archive);
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn create_files_in(dir: &Path, files: &[&str]) {

/// Write random content to a file
pub fn write_random_content(file: &mut impl Write, rng: &mut impl RngCore) {
let mut data = vec![0; rng.gen_range(0..4096)];
let mut data = vec![0; rng.gen_range(0..8192)];

rng.fill_bytes(&mut data);
file.write_all(&data).unwrap();
Expand Down