Skip to content
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
28 changes: 13 additions & 15 deletions .github/workflows/code_style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@ on:
jobs:
code_style:
runs-on: ubuntu-latest

steps:
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install libarchive-dev protobuf-compiler
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
# rustfmt.toml uses nightly-only options, so the dev shell pairs a nightly
# rustfmt with the MSRV toolchain the rest of the shell provides. Clippy
# therefore runs at the MSRV, which is what the code has to build with.
- uses: ossystems/nix-actions@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
install-nix: true
export-devshell: true

- name: Cache build contents
uses: Swatinem/rust-cache@v2

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: cargo fmt --all -- --check

- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all --tests -- -D clippy::all
- name: Run cargo clippy
run: cargo clippy --locked --all-features --all --tests -- -D clippy::all
83 changes: 23 additions & 60 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,73 +8,47 @@ on:
pull_request:

jobs:
build_and_test:
strategy:
fail-fast: false
matrix:
name: [MSRV, stable, nightly]
include:
- name: MSRV
version: 1.82.0
- name: stable
version: stable
- name: nightly
version: nightly

name: Test ${{ matrix.name }} - x86_64-unknown-linux-gnu
# Evaluates the flake and builds the dev shell, so a broken flake is reported
# on its own instead of as a confusing failure inside the test job. It also
# warms the Nix store cache the test job restores.
nix:
name: Flake check
runs-on: ubuntu-latest

steps:
- name: Install Dependencies
run: sudo apt-get update -y; sudo apt-get install -y libarchive-dev libclang-dev protobuf-compiler socat

- name: Checkout sources
uses: actions/checkout@v4

- name: Install ${{ matrix.version }}
uses: actions-rs/toolchain@v1
- uses: ossystems/nix-actions@v1
with:
toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu
profile: minimal
override: true
install-nix: true

- name: Install cargo tree tool
if: matrix.name == 'MSRV'
uses: actions-rs/install@v0.1
build_and_test:
name: Test - x86_64-unknown-linux-gnu
runs-on: ubuntu-latest

steps:
# Loads the flake's dev shell into the job, so every step below runs with
# the toolchain and the native dependencies (libarchive, protobuf, socat,
# ...) the flake pins. The dev shell is pinned to the MSRV, so the whole
# job doubles as the MSRV check.
- uses: ossystems/nix-actions@v1
with:
crate: cargo-tree
use-tool-cache: true
install-nix: true
export-devshell: true

- name: Cache build contents
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
uses: Swatinem/rust-cache@v2

# Every other step below enables all the features, which leaves the
# default feature set never being built. Check it on its own so a change
# guarded by a feature flag cannot break the plain `cargo build`.
- name: Check build with the default features
uses: actions-rs/cargo@v1
with:
command: check
args: --locked --release --all --bins --examples --tests
run: cargo check --locked --release --all --bins --examples --tests

- name: Check build
uses: actions-rs/cargo@v1
with:
command: check
args: --locked --release --all --bins --examples --tests --all-features
run: cargo check --locked --release --all --bins --examples --tests --all-features

- name: Tests
uses: actions-rs/cargo@v1
timeout-minutes: 10
with:
command: test
args: --locked --release --all --all-features --no-fail-fast -- --nocapture
run: cargo test --locked --release --all --all-features --no-fail-fast -- --nocapture

- name: Run listener test
run: |
Expand Down Expand Up @@ -102,22 +76,11 @@ jobs:
exit 4
fi

- name: Install cargo-llvm-cov
if: matrix.name == 'nightly'
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate code coverage
if: matrix.name == 'nightly'
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info

- name: Upload coverage to Coveralls
if: matrix.name == 'nightly'
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: lcov.info

- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.pending-snap
*.yaml
/.direnv/
/lcov.info
49 changes: 34 additions & 15 deletions flake.lock

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

18 changes: 13 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "UpdateHub Development Environment";

inputs = {
nixpkgs.url = "nixpkgs/release-22.11";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
flake-utils.url = "github:numtide/flake-utils";

rust = {
Expand All @@ -16,20 +16,24 @@
let
pkgs = nixpkgs.legacyPackages.${system};

# The MSRV. CI builds and tests with this exact toolchain, so bumping
# it here is what bumps the minimum supported Rust version.
rust-toolchain = with rust.packages.${system};
let
msrv = toolchainOf {
channel = "1.65.0";
sha256 = "sha256-DzNEaW724O8/B8844tt5AVHmSjSQ3cmzlU4BP90oRlY=";
channel = "1.82.0";
sha256 = "sha256-yMuSb5eQPO/bHv+Bcf/US8LVMbf/G/0MSfiPwBhiPpk=";
};
in
combine [
(msrv.withComponents [ "rustc" "cargo" "rust-src" "clippy" ])
(msrv.withComponents [ "rustc" "cargo" "rust-src" "clippy" "llvm-tools" ])
# rustfmt.toml uses nightly-only options, so rustfmt comes from
# nightly regardless of the MSRV used to build.
(latest.withComponents [ "rustfmt" "rust-analyzer" ])
];
in
{
devShell = pkgs.mkShell {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
libarchive
linuxHeaders
Expand All @@ -40,11 +44,15 @@

cargo-insta
cargo-limit
cargo-llvm-cov
cargo-outdated
cargo-release
cargo-watch
rust-toolchain

# used by the listener example test
socat

# used by excluded tests
mtdutils
];
Expand Down
2 changes: 1 addition & 1 deletion updatehub/src/runtime_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl RuntimeSettings {
.map(|s| RuntimeSettings { inner: s, v1_content: Some(content.to_string()) })
});

Ok(runtime_settings?)
runtime_settings.map_err(Into::into)
}

fn save(&self) -> Result<()> {
Expand Down