From 6bd1efccd6eaefa9df25fda32bd101ebe4abd15e Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Sun, 10 Mar 2024 10:59:44 +0100 Subject: [PATCH] Update CI configuration slightly (#366) * Update CI configuration slightly --- .github/workflows/bloat.yml | 4 +- .github/workflows/ci.yml | 79 ++++++++-------------------------- .github/workflows/coverage.yml | 28 ++++-------- .github/workflows/release.yml | 26 ----------- .github/workflows/version.yml | 4 +- Cargo.toml | 4 ++ cli/Cargo.toml | 6 +-- cspell-dictionary.txt | 2 + os_info/Cargo.toml | 12 +++--- os_info/src/windows/winapi.rs | 10 ++--- 10 files changed, 50 insertions(+), 125 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/bloat.yml b/.github/workflows/bloat.yml index b8ba28af..8a86d4d0 100644 --- a/.github/workflows/bloat.yml +++ b/.github/workflows/bloat.yml @@ -1,4 +1,4 @@ -on: # rebuild any PRs and main branch changes +on: pull_request: push: branches: @@ -31,7 +31,7 @@ jobs: steps: - name: Checkout sources - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install rust uses: actions-rs/toolchain@v1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 212e1489..542ea764 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,86 +8,43 @@ jobs: name: Rustfmt runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - components: rustfmt - profile: minimal - override: true - - name: Run rustfmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - run: cargo fmt --all -- --check # Static analyzer. clippy: name: Clippy runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - components: clippy - profile: minimal - override: true - - name: Run clippy - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-targets --all-features -- -D warnings - - # Security audit. - audit: - name: Security audit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - run: cargo clippy --all-targets --all-features -- -D warnings # Check links in the documentation. deadlinks: name: Deadlinks runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - - name: Install deadlinks - run: cargo install cargo-deadlinks - - name: Cargo doc - run: cargo doc --no-deps -p os_info - - name: Run deadlinks - run: cargo deadlinks --no-build + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - run: cargo install cargo-deadlinks + - run: cargo doc --no-deps -p os_info + - run: cargo deadlinks --no-build # Check links in markdown files. mlc: name: MLC runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Markup Link Checker (mlc) - uses: becheran/mlc@v0.14.3 + - uses: actions/checkout@v3 + - uses: becheran/mlc@v0.14.3 # Spellcheck. spellcheck: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: streetsidesoftware/cspell-action@v1.0.1 with: files: "**/*.{rs,md}" @@ -97,10 +54,8 @@ jobs: name: Markdown lints runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Check md files - uses: nosborn/github-action-markdown-cli@v1.1.1 + - uses: actions/checkout@v3 + - uses: nosborn/github-action-markdown-cli@v1.1.1 with: files: . @@ -109,7 +64,7 @@ jobs: name: cargo-deny runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: EmbarkStudios/cargo-deny-action@v1 # Tests. diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f2a5ffb8..5081bfc1 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -6,30 +6,20 @@ jobs: check: name: Tarpaulin runs-on: ubuntu-latest + container: + image: xd009642/tarpaulin:develop-nightly + options: --security-opt seccomp=unconfined steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: Run cargo-tarpaulin - uses: actions-rs/tarpaulin@v0.1 - with: - version: latest - args: '-- --test-threads 1' + - name: Generate code coverage + run: | + cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out xml - name: Upload to codecov.io - uses: codecov/codecov-action@v1.0.2 + uses: codecov/codecov-action@v4 with: token: ${{secrets.CODECOV_TOKEN}} - - - name: Archive code coverage results - uses: actions/upload-artifact@v1 - with: - name: code-coverage-report - path: cobertura.xml + fail_ci_if_error: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 2266357f..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Create Release - -on: - push: - tags: - - 'v*.*.*' - -jobs: - release-build: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Extract release notes - id: extract-release-notes - uses: ffurrer2/extract-release-notes@v1 - - name: Create release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: true - prerelease: false - body: ${{ steps.extract-release-notes.outputs.release_notes }} diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index 751e3a2e..e0d168fc 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -12,14 +12,14 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install rust uses: actions-rs/toolchain@v1 with: # Feel free to bump this version if you need features of newer Rust. # Sync with badge in README.md - toolchain: 1.60.0 + toolchain: 1.72.0 profile: minimal override: true diff --git a/Cargo.toml b/Cargo.toml index ccd7a489..1b1d0f0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,9 @@ [workspace] + members = [ "os_info", "cli", ] + +[workspace.dependencies] +log = "0.4" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index d827bc2d..b568c6ad 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["cli", "os", "os_type", "os_version", "os_info"] categories = ["command-line-interface", "os"] license = "MIT" edition = "2018" -rust-version = "1.60" +rust-version = "1.76" [[bin]] name = "os_info" @@ -19,8 +19,8 @@ path = "src/main.rs" [dependencies] os_info = { version = "3.7.0", default-features = false, path = "../os_info" } -log = "0.4.5" -env_logger = "0.10" +log.workspace = true +env_logger = "0.11" clap = { version = "4", features = ["derive"] } [dev-dependencies] diff --git a/cspell-dictionary.txt b/cspell-dictionary.txt index 764deed1..8a9a66f2 100644 --- a/cspell-dictionary.txt +++ b/cspell-dictionary.txt @@ -11,6 +11,7 @@ clippy clearos concat coreos +cpus devuan earmv emscripten @@ -53,5 +54,6 @@ xenenterprise xenial xenserver ultramarine +uninit voidlinux kuma diff --git a/os_info/Cargo.toml b/os_info/Cargo.toml index 353a4d72..8bc141e7 100644 --- a/os_info/Cargo.toml +++ b/os_info/Cargo.toml @@ -17,20 +17,20 @@ rust-version = "1.60" default = ["serde"] [dependencies] -log = "0.4.5" +log.workspace = true serde = { version = "1", features = ["derive"], optional = true } [target.'cfg(windows)'.dependencies] -windows-sys = { version = "0.45", features = [ +windows-sys = { version = "0.52", features = [ "Win32_Foundation", - "Win32_System_Diagnostics_Debug", "Win32_System_LibraryLoader", - "Win32_System_SystemInformation", - "Win32_UI_WindowsAndMessaging", "Win32_System_Registry", + "Win32_System_SystemInformation", "Win32_System_SystemServices", + "Win32_System_Threading", + "Win32_UI_WindowsAndMessaging", ]} [dev-dependencies] pretty_assertions = "1" -doc-comment = "0.3.1" +doc-comment = "0.3" diff --git a/os_info/src/windows/winapi.rs b/os_info/src/windows/winapi.rs index 0a72239f..5e46127a 100644 --- a/os_info/src/windows/winapi.rs +++ b/os_info/src/windows/winapi.rs @@ -15,13 +15,13 @@ use std::{ use windows_sys::Win32::{ Foundation::{ERROR_SUCCESS, FARPROC, NTSTATUS, STATUS_SUCCESS}, System::{ - Diagnostics::Debug::{ - PROCESSOR_ARCHITECTURE_AMD64, PROCESSOR_ARCHITECTURE_ARM, PROCESSOR_ARCHITECTURE_IA64, - PROCESSOR_ARCHITECTURE_INTEL, - }, LibraryLoader::{GetModuleHandleA, GetProcAddress}, Registry::{RegOpenKeyExW, RegQueryValueExW, HKEY_LOCAL_MACHINE, KEY_READ, REG_SZ}, - SystemInformation::{GetNativeSystemInfo, GetSystemInfo, SYSTEM_INFO}, + SystemInformation::{ + GetNativeSystemInfo, GetSystemInfo, PROCESSOR_ARCHITECTURE_AMD64, + PROCESSOR_ARCHITECTURE_ARM, PROCESSOR_ARCHITECTURE_IA64, PROCESSOR_ARCHITECTURE_INTEL, + SYSTEM_INFO, + }, SystemServices::{VER_NT_WORKSTATION, VER_SUITE_WH_SERVER}, }, UI::WindowsAndMessaging::{GetSystemMetrics, SM_SERVERR2},