From 59d9ab4a0bf361387d32c231ab91bb5153e7b1c7 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 15:45:35 +0800 Subject: [PATCH 01/15] ci: test_crates_io_index downloading --- .github/workflows/run.yml | 61 ++++++++++++++++++++------------------- src/crates_io.rs | 17 +++++++++++ src/lib.rs | 1 + 3 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 src/crates_io.rs diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 413333f..409012b 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -49,38 +49,41 @@ jobs: chmod +x ~/.cargo/bin/os-checker os-checker layout --help + - name: Test crates.io index + run: cargo test -- test_crates_io_index --nocapture + # - name: Test os-checker layout --list-targets # run: cargo test -- test_sel4 --nocapture # # - name: Test pkg_targets # run: cargo test -- test_pkg_targets --nocapture - - name: Install plugin-cargo - run: cargo install --path . - - - name: Run plugin-cargo - run: | - os-checker-plugin-cargo #os-checker.json - tree --gitignore -h tmp - - - name: Push to database - env: - PLUGIN_PATH: plugin/cargo - run: | - git config --global user.name "zjp-CN[bot]" - git config --global user.email "zjp-CN[bot]@users.noreply.github.com" - - echo "正在 clone os-checker/database" - git clone https://x-access-token:${{ env.ACCESS_TOKEN }}@github.com/os-checker/database.git - echo "成功 clone os-checker/database" - - cd database - git switch ${{ env.DATABASE }} - - rm -rf ${{ env.PLUGIN_PATH }} - mkdir -p ${{ env.PLUGIN_PATH }} - mv ../tmp ${{ env.PLUGIN_PATH }}/info - cp ../push.sh ${{ env.PLUGIN_PATH }} - - bash ${{ env.PLUGIN_PATH }}/push.sh - + # - name: Install plugin-cargo + # run: cargo install --path . + # + # - name: Run plugin-cargo + # run: | + # os-checker-plugin-cargo os-checker.json + # tree --gitignore -h tmp + # + # - name: Push to database + # env: + # PLUGIN_PATH: plugin/cargo + # run: | + # git config --global user.name "zjp-CN[bot]" + # git config --global user.email "zjp-CN[bot]@users.noreply.github.com" + # + # echo "正在 clone os-checker/database" + # git clone https://x-access-token:${{ env.ACCESS_TOKEN }}@github.com/os-checker/database.git + # echo "成功 clone os-checker/database" + # + # cd database + # git switch ${{ env.DATABASE }} + # + # rm -rf ${{ env.PLUGIN_PATH }} + # mkdir -p ${{ env.PLUGIN_PATH }} + # mv ../tmp ${{ env.PLUGIN_PATH }}/info + # cp ../push.sh ${{ env.PLUGIN_PATH }} + # + # bash ${{ env.PLUGIN_PATH }}/push.sh + # diff --git a/src/crates_io.rs b/src/crates_io.rs new file mode 100644 index 0000000..47c80a2 --- /dev/null +++ b/src/crates_io.rs @@ -0,0 +1,17 @@ +use crate::prelude::*; + +const REPO: &str = "https://github.com/rust-lang/crates.io-index.git"; +const DIR: &str = "crates.io-index"; + +#[test] +fn test_crates_io_index() -> Result<()> { + let mut dir = crate::repo::local_base_dir().to_owned(); + duct::cmd!("git", "clone", REPO, DIR, "--depth", "1") + .dir(&dir) + .run()?; + + dir.push(DIR); + duct::cmd!("ls", "-alh", dir).run()?; + + Ok(()) +} diff --git a/src/lib.rs b/src/lib.rs index b9cffb1..6715485 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,7 @@ extern crate eyre; #[macro_use] extern crate tracing; +pub mod crates_io; pub mod database; pub mod logger; pub mod nextest; From 5a199abe13d29171c1d297134884ad3d864509f3 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 15:49:41 +0800 Subject: [PATCH 02/15] fix: create_dir for local_base_dir --- src/repo/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/repo/mod.rs b/src/repo/mod.rs index 08aed6c..49c13c7 100644 --- a/src/repo/mod.rs +++ b/src/repo/mod.rs @@ -114,8 +114,13 @@ impl Repo { } pub fn local_base_dir() -> &'static Utf8Path { - static GIT_CLONE_DIR: LazyLock = - LazyLock::new(|| Utf8PathBuf::from_iter(["/tmp", "os-checker-plugin-cargo"])); + static GIT_CLONE_DIR: LazyLock = LazyLock::new(|| { + let path = Utf8PathBuf::from_iter(["/tmp", "os-checker-plugin-cargo"]); + if let Err(err) = std::fs::create_dir_all(&path) { + error!(?err, ?path, "directory is not created"); + }; + path + }); &GIT_CLONE_DIR } From e30a9d75d2ea34942544582e4252e741a7d6e7dd Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 16:24:32 +0800 Subject: [PATCH 03/15] crates_io: define search_pkg_file and test --- .github/workflows/run.yml | 2 +- src/crates_io.rs | 48 +++++++++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 409012b..2f8bc68 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -50,7 +50,7 @@ jobs: os-checker layout --help - name: Test crates.io index - run: cargo test -- test_crates_io_index --nocapture + run: cargo test -- test_search_pkg_file --nocapture # - name: Test os-checker layout --list-targets # run: cargo test -- test_sel4 --nocapture diff --git a/src/crates_io.rs b/src/crates_io.rs index 47c80a2..ad3c932 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -1,17 +1,47 @@ use crate::prelude::*; +use std::sync::LazyLock; const REPO: &str = "https://github.com/rust-lang/crates.io-index.git"; -const DIR: &str = "crates.io-index"; -#[test] -fn test_crates_io_index() -> Result<()> { - let mut dir = crate::repo::local_base_dir().to_owned(); - duct::cmd!("git", "clone", REPO, DIR, "--depth", "1") - .dir(&dir) - .run()?; +/// Returns the pkg file path if exists +// ref: https://doc.rust-lang.org/cargo/reference/registry-index.html#index-files +fn search_pkg_file(pkg: &str, dir: &Utf8Path) -> Option { + let components = match pkg.len() { + 1 => &["1", pkg][..], + 2 => &["2", pkg], + 3 => { + let (a, b) = pkg.split_at(1); + &["3", a, b, pkg] + } + _ => { + let (a, b) = pkg.split_at(2); + &[a, b, pkg] + } + }; + let path = { + let mut path = dir.to_owned(); + path.extend(components); + path + }; + path.exists().then_some(path) +} - dir.push(DIR); - duct::cmd!("ls", "-alh", dir).run()?; +static DIR: LazyLock = LazyLock::new(|| { + let dir = { + const DIR: &str = "crates.io-index"; + let mut dir = crate::repo::local_base_dir().to_owned(); + dir.push(DIR); + dir + }; + duct::cmd!("git", "clone", REPO, &dir, "--depth", "1") + .run() + .unwrap(); + dir +}); + +#[test] +fn test_search_pkg_file() -> Result<()> { + dbg!(search_pkg_file("os-checker", &DIR).unwrap()); Ok(()) } From d3a6ec9e0a2c9740678714e329d412fb0c6a7c77 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 16:29:44 +0800 Subject: [PATCH 04/15] fix: search_pkg_file pkg path the length of which is more than 3 --- src/crates_io.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/crates_io.rs b/src/crates_io.rs index ad3c932..9819e3e 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -15,6 +15,7 @@ fn search_pkg_file(pkg: &str, dir: &Utf8Path) -> Option { } _ => { let (a, b) = pkg.split_at(2); + let (b, _) = b.split_at(2); &[a, b, pkg] } }; From 4afe873ac4b9a239274238a892690a790b63dfeb Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 16:39:41 +0800 Subject: [PATCH 05/15] crates_io: get_release_count and test --- .github/workflows/run.yml | 2 +- src/crates_io.rs | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 2f8bc68..e5ea568 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -50,7 +50,7 @@ jobs: os-checker layout --help - name: Test crates.io index - run: cargo test -- test_search_pkg_file --nocapture + run: cargo test -- test_release_count --nocapture # - name: Test os-checker layout --list-targets # run: cargo test -- test_sel4 --nocapture diff --git a/src/crates_io.rs b/src/crates_io.rs index 9819e3e..60b6e93 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -1,6 +1,8 @@ use crate::prelude::*; use std::sync::LazyLock; +// https://raw.githubusercontent.com/rust-lang/crates.io-index/refs/heads/master/os/-c/os-checker + const REPO: &str = "https://github.com/rust-lang/crates.io-index.git"; /// Returns the pkg file path if exists @@ -40,9 +42,22 @@ static DIR: LazyLock = LazyLock::new(|| { dir }); +fn count(path: &Utf8Path) -> usize { + std::fs::read_to_string(path).unwrap().lines().count() +} + +pub fn get_release_count(pkg: &str) -> Option { + search_pkg_file(pkg, &DIR).map(|path| ) +} + #[test] -fn test_search_pkg_file() -> Result<()> { - dbg!(search_pkg_file("os-checker", &DIR).unwrap()); +fn test_get_release_count() { + dbg!(get_release_count("os-checker")); +} + - Ok(()) +#[test] +fn test_search_pkg_file() { + dbg!(search_pkg_file("os-checker", &DIR).unwrap()); } + From eee6db25db17b5920e44a0b582e5b2c69bb0e156 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 16:48:33 +0800 Subject: [PATCH 06/15] =?UTF-8?q?crates=5Fio:=20=E4=B8=8B=E8=BD=BD=20crate?= =?UTF-8?q?s.io=20index=20=E4=BB=93=E5=BA=93=E9=9C=80=E8=A6=81=201=20?= =?UTF-8?q?=E5=88=86=E9=92=9F=EF=BC=8C=E6=94=B9=E7=94=A8=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/crates_io.rs | 54 ++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/src/crates_io.rs b/src/crates_io.rs index 60b6e93..90081d8 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -1,13 +1,11 @@ use crate::prelude::*; use std::sync::LazyLock; -// https://raw.githubusercontent.com/rust-lang/crates.io-index/refs/heads/master/os/-c/os-checker +fn url(pkg: &str) -> String { + const PREFIX: &str = + "https://raw.githubusercontent.com/rust-lang/crates.io-index/refs/heads/master"; -const REPO: &str = "https://github.com/rust-lang/crates.io-index.git"; - -/// Returns the pkg file path if exists -// ref: https://doc.rust-lang.org/cargo/reference/registry-index.html#index-files -fn search_pkg_file(pkg: &str, dir: &Utf8Path) -> Option { + // ref: https://doc.rust-lang.org/cargo/reference/registry-index.html#index-files let components = match pkg.len() { 1 => &["1", pkg][..], 2 => &["2", pkg], @@ -21,43 +19,27 @@ fn search_pkg_file(pkg: &str, dir: &Utf8Path) -> Option { &[a, b, pkg] } }; - let path = { - let mut path = dir.to_owned(); - path.extend(components); - path - }; - path.exists().then_some(path) -} -static DIR: LazyLock = LazyLock::new(|| { - let dir = { - const DIR: &str = "crates.io-index"; - let mut dir = crate::repo::local_base_dir().to_owned(); - dir.push(DIR); - dir - }; - duct::cmd!("git", "clone", REPO, &dir, "--depth", "1") - .run() - .unwrap(); - dir -}); + // e.g. https://raw.githubusercontent.com/rust-lang/crates.io-index/refs/heads/master/os/-c/os-checker + let mut buf = String::with_capacity(128); + buf.push_str(PREFIX); + + for c in components { + buf.push('/'); + buf.push_str(c); + } -fn count(path: &Utf8Path) -> usize { - std::fs::read_to_string(path).unwrap().lines().count() + buf } pub fn get_release_count(pkg: &str) -> Option { - search_pkg_file(pkg, &DIR).map(|path| ) + duct::cmd!("wget", url(pkg), "-O", "-") + .read() + .ok() + .map(|text| text.lines().count()) } #[test] -fn test_get_release_count() { +fn test_get_release_count() { dbg!(get_release_count("os-checker")); } - - -#[test] -fn test_search_pkg_file() { - dbg!(search_pkg_file("os-checker", &DIR).unwrap()); -} - From 215c5d6121cf4c0439c1c57037e1e610d95cf876 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 16:50:25 +0800 Subject: [PATCH 07/15] ci: fix test name --- .github/workflows/run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index e5ea568..ece5181 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -50,7 +50,7 @@ jobs: os-checker layout --help - name: Test crates.io index - run: cargo test -- test_release_count --nocapture + run: cargo test -- test_get_release_count --nocapture # - name: Test os-checker layout --list-targets # run: cargo test -- test_sel4 --nocapture From 3c248cec143e15cd712adc8556886b7d644ea9bc Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 16:57:54 +0800 Subject: [PATCH 08/15] =?UTF-8?q?crates=5Fio:=20=E4=B8=8D=E8=A6=81?= =?UTF-8?q?=E6=8A=8A=E4=B8=8B=E8=BD=BD=E5=86=85=E5=AE=B9=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=88=B0=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/run.yml | 2 +- src/crates_io.rs | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index ece5181..04fe729 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -49,7 +49,7 @@ jobs: chmod +x ~/.cargo/bin/os-checker os-checker layout --help - - name: Test crates.io index + - name: Test get_release_count run: cargo test -- test_get_release_count --nocapture # - name: Test os-checker layout --list-targets diff --git a/src/crates_io.rs b/src/crates_io.rs index 90081d8..0a1e3fd 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -32,11 +32,22 @@ fn url(pkg: &str) -> String { buf } +/// NOTE: the result might be spurious due to network failure or invalid text pub fn get_release_count(pkg: &str) -> Option { - duct::cmd!("wget", url(pkg), "-O", "-") - .read() - .ok() - .map(|text| text.lines().count()) + let output = duct::cmd!("wget", url(pkg), "-O", "-") + .stderr_capture() + .stderr_null() + .unchecked() + .run() + .ok()?; + + Some( + std::str::from_utf8(&output.stdout) + .ok()? + .trim() + .lines() + .count(), + ) } #[test] From ec4a065a6a22bb74ff2f03b835056a39c023d656 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 17:01:55 +0800 Subject: [PATCH 09/15] feat: Output add release_count --- src/repo/mod.rs | 3 ++- src/repo/output.rs | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/repo/mod.rs b/src/repo/mod.rs index 49c13c7..2172cbd 100644 --- a/src/repo/mod.rs +++ b/src/repo/mod.rs @@ -1,4 +1,4 @@ -use crate::{database::diag_total_count, prelude::*}; +use crate::{crates_io::get_release_count, database::diag_total_count, prelude::*}; use cargo_metadata::Package; use eyre::ContextCompat; use output::Output; @@ -83,6 +83,7 @@ impl Repo { let pkg_name = pkg.name.as_str(); let mut output = Output::new(pkg, test_cases.swap_remove(pkg_name)); output.diag_total_count = diag_total_count([&self.user, &self.repo, pkg_name]); + output.release_count = get_release_count(pkg_name); assert!( outputs.insert(pkg_name, output).is_none(), "os-checker can't handle duplicated package names in a repo" diff --git a/src/repo/output.rs b/src/repo/output.rs index 04da7ac..f317bf0 100644 --- a/src/repo/output.rs +++ b/src/repo/output.rs @@ -21,6 +21,8 @@ pub struct Output { pub categories: Vec, pub os_categories: Vec, pub diag_total_count: Option, + /// crates.io 发版次数 + pub release_count: Option, } impl Output { @@ -55,6 +57,7 @@ impl Output { }) .unwrap_or_default(), diag_total_count: None, + release_count: None, } } } From 7e8093212e527f81b3042b7d6833d2ce70124739 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 17:02:45 +0800 Subject: [PATCH 10/15] ci: test release_count --- .github/workflows/run.yml | 64 +++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 04fe729..20ccc06 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -49,41 +49,41 @@ jobs: chmod +x ~/.cargo/bin/os-checker os-checker layout --help - - name: Test get_release_count - run: cargo test -- test_get_release_count --nocapture - + # - name: Test get_release_count + # run: cargo test -- test_get_release_count --nocapture + # # - name: Test os-checker layout --list-targets # run: cargo test -- test_sel4 --nocapture # # - name: Test pkg_targets # run: cargo test -- test_pkg_targets --nocapture - # - name: Install plugin-cargo - # run: cargo install --path . - # - # - name: Run plugin-cargo - # run: | - # os-checker-plugin-cargo os-checker.json - # tree --gitignore -h tmp - # - # - name: Push to database - # env: - # PLUGIN_PATH: plugin/cargo - # run: | - # git config --global user.name "zjp-CN[bot]" - # git config --global user.email "zjp-CN[bot]@users.noreply.github.com" - # - # echo "正在 clone os-checker/database" - # git clone https://x-access-token:${{ env.ACCESS_TOKEN }}@github.com/os-checker/database.git - # echo "成功 clone os-checker/database" - # - # cd database - # git switch ${{ env.DATABASE }} - # - # rm -rf ${{ env.PLUGIN_PATH }} - # mkdir -p ${{ env.PLUGIN_PATH }} - # mv ../tmp ${{ env.PLUGIN_PATH }}/info - # cp ../push.sh ${{ env.PLUGIN_PATH }} - # - # bash ${{ env.PLUGIN_PATH }}/push.sh - # + - name: Install plugin-cargo + run: cargo install --path . + + - name: Run plugin-cargo + run: | + os-checker-plugin-cargo os-checker.json + tree --gitignore -h tmp + + - name: Push to database + env: + PLUGIN_PATH: plugin/cargo + run: | + git config --global user.name "zjp-CN[bot]" + git config --global user.email "zjp-CN[bot]@users.noreply.github.com" + + echo "正在 clone os-checker/database" + git clone https://x-access-token:${{ env.ACCESS_TOKEN }}@github.com/os-checker/database.git + echo "成功 clone os-checker/database" + + cd database + git switch ${{ env.DATABASE }} + + rm -rf ${{ env.PLUGIN_PATH }} + mkdir -p ${{ env.PLUGIN_PATH }} + mv ../tmp ${{ env.PLUGIN_PATH }}/info + cp ../push.sh ${{ env.PLUGIN_PATH }} + + bash ${{ env.PLUGIN_PATH }}/push.sh + From 3cb3eaac29d3d838bde101c581409e32c4a79973 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 17:04:55 +0800 Subject: [PATCH 11/15] fix: stdout_capture in get_release_count --- src/crates_io.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crates_io.rs b/src/crates_io.rs index 0a1e3fd..0cb5d8e 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -35,7 +35,7 @@ fn url(pkg: &str) -> String { /// NOTE: the result might be spurious due to network failure or invalid text pub fn get_release_count(pkg: &str) -> Option { let output = duct::cmd!("wget", url(pkg), "-O", "-") - .stderr_capture() + .stdout_capture() .stderr_null() .unchecked() .run() From bf977292c79cdf05433feb910041e532c2afd033 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 17:10:36 +0800 Subject: [PATCH 12/15] crates_io: 0 is an invalid value for get_release_count --- src/crates_io.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/crates_io.rs b/src/crates_io.rs index 0cb5d8e..9e8d8fb 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -32,7 +32,10 @@ fn url(pkg: &str) -> String { buf } -/// NOTE: the result might be spurious due to network failure or invalid text +/// NOTE: the result might be spurious due to network failure or invalid text; +/// +/// None means no release found; 0 is an invalid value because there at least one +/// release if found. pub fn get_release_count(pkg: &str) -> Option { let output = duct::cmd!("wget", url(pkg), "-O", "-") .stdout_capture() @@ -41,13 +44,12 @@ pub fn get_release_count(pkg: &str) -> Option { .run() .ok()?; - Some( - std::str::from_utf8(&output.stdout) - .ok()? - .trim() - .lines() - .count(), - ) + let text = std::str::from_utf8(&output.stdout).ok()?.trim(); + let count = text.lines().count(); + if count == 0 { + error!(pkg, text, "count is an invalid value 0") + } + Some(count) } #[test] From bc26610837866c0f879736ef0ef1b2cf00bc9d30 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 17:13:56 +0800 Subject: [PATCH 13/15] crates_io: print url if error --- src/crates_io.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/crates_io.rs b/src/crates_io.rs index 9e8d8fb..31a3321 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -1,6 +1,3 @@ -use crate::prelude::*; -use std::sync::LazyLock; - fn url(pkg: &str) -> String { const PREFIX: &str = "https://raw.githubusercontent.com/rust-lang/crates.io-index/refs/heads/master"; @@ -37,7 +34,8 @@ fn url(pkg: &str) -> String { /// None means no release found; 0 is an invalid value because there at least one /// release if found. pub fn get_release_count(pkg: &str) -> Option { - let output = duct::cmd!("wget", url(pkg), "-O", "-") + let url = url(pkg); + let output = duct::cmd!("wget", &url, "-O", "-") .stdout_capture() .stderr_null() .unchecked() @@ -47,7 +45,7 @@ pub fn get_release_count(pkg: &str) -> Option { let text = std::str::from_utf8(&output.stdout).ok()?.trim(); let count = text.lines().count(); if count == 0 { - error!(pkg, text, "count is an invalid value 0") + error!(pkg, url, text, "count is an invalid value 0") } Some(count) } From 44eca102c017cc2bb51cdbe30917bc826431680b Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 17:19:51 +0800 Subject: [PATCH 14/15] fix: get_release_count should respect the network error --- src/crates_io.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/crates_io.rs b/src/crates_io.rs index 31a3321..8e89824 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -38,7 +38,6 @@ pub fn get_release_count(pkg: &str) -> Option { let output = duct::cmd!("wget", &url, "-O", "-") .stdout_capture() .stderr_null() - .unchecked() .run() .ok()?; From 5a39ad4a797b4bc2971c68e951da76c979e36293 Mon Sep 17 00:00:00 2001 From: zjp Date: Tue, 19 Nov 2024 17:22:55 +0800 Subject: [PATCH 15/15] ci: run for all repos --- .github/workflows/run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 20ccc06..78f9be6 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -63,7 +63,7 @@ jobs: - name: Run plugin-cargo run: | - os-checker-plugin-cargo os-checker.json + os-checker-plugin-cargo #os-checker.json tree --gitignore -h tmp - name: Push to database