Skip to content

Commit

Permalink
Merge pull request #37 from wiktor-k/cleanup-ci
Browse files Browse the repository at this point in the history
Extract common rust CI infra into separate file
  • Loading branch information
wiktor-k authored Apr 5, 2024
2 parents 4051ee2 + 3d2ac15 commit f92f464
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 35 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/misc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Misc

on:
pull_request:
push:
tags:
- 'v*'
branches: [ main ]
workflow_dispatch:

concurrency:
group: misc-${{ github.ref }}
cancel-in-progress: true

jobs:
integration:
name: Integration tests
# If starting the example fails at runtime the integration test will
# be stuck. Try to limit the damage. The value "10" selected arbitrarily.
timeout-minutes: 10
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
include:
- os: windows-latest
windows: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
# If the example doesn't compile the integration test will
# be stuck. Check for compilation issues earlier to abort the job
- name: Check if the example compiles
run: cargo check --example key_storage
- name: Run integration tests
run: ./tests/sign-and-verify.sh
if: ${{ ! matrix.windows }}
- name: Run integration tests
run: ".\\tests\\sign-and-verify-win.bat"
if: ${{ matrix.windows }}
29 changes: 2 additions & 27 deletions .github/workflows/ci.yml → .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
workflow_dispatch:

concurrency:
group: ${{ github.ref }}
group: rust-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: cargo install --locked just cargo-deny
- name: Run unit tests
- name: Run dependencies check
run: just dependencies

lints:
Expand All @@ -84,28 +84,3 @@ jobs:
- run: cargo install --locked just
- name: Check for lints
run: just lints

integration:
name: Integration tests
# If starting the example fails at runtime the integration test will
# be stuck. Try to limit the damage. The value "10" selected arbitrarily.
timeout-minutes: 10
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
include:
- os: windows-latest
windows: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
# If the example doesn't compile the integration test will
# be stuck. Check for compilation issues earlier to abort the job
- name: Check if the example compiles
run: cargo check --example key_storage
- name: Run integration tests
run: ./tests/sign-and-verify.sh
if: ${{ ! matrix.windows }}
- name: Run integration tests
run: ".\\tests\\sign-and-verify-win.bat"
if: ${{ matrix.windows }}
12 changes: 8 additions & 4 deletions .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Faster checks need to be executed first for better UX. For example

# codespell is very fast. cargo fmt does not need to download crates etc.
check: spelling formatting lints dependencies tests
check: spelling formatting docs lints dependencies tests

# Checks common spelling mistakes
spelling:
Expand All @@ -13,11 +13,11 @@ spelling:
formatting:
just --unstable --fmt --check
# We're using nightly to properly group imports, see .rustfmt.toml
cargo +nightly fmt -- --check
cargo +nightly fmt --all -- --check

# Lints the source code
lints:
cargo clippy --all -- -D warnings
cargo clippy --workspace --no-deps --all-targets -- -D warnings

# Checks for issues with dependencies
dependencies:
Expand All @@ -27,6 +27,10 @@ dependencies:
tests:
cargo test --all

# Build docs for this crate only
docs:
cargo doc --no-deps

# Checks for commit messages
check-commits REFS='main..':
#!/usr/bin/env bash
Expand Down Expand Up @@ -63,4 +67,4 @@ fix:
cargo clippy --fix --allow-staged

# fmt must be last as clippy's changes may break formatting
cargo +nightly fmt
cargo +nightly fmt --all
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ssh-agent-lib

[![CI](https://github.com/wiktor-k/ssh-agent-lib/actions/workflows/ci.yml/badge.svg)](https://github.com/wiktor-k/ssh-agent-lib/actions/workflows/ci.yml)
[![CI](https://github.com/wiktor-k/ssh-agent-lib/actions/workflows/rust.yml/badge.svg)](https://github.com/wiktor-k/ssh-agent-lib/actions/workflows/rust.yml)
[![Crates.io](https://img.shields.io/crates/v/ssh-agent-lib)](https://crates.io/crates/ssh-agent-lib)

A collection of types for writing custom SSH agents as specified by the [SSH Agent Protocol Internet Draft](https://datatracker.ietf.org/doc/html/draft-miller-ssh-agent).
Expand Down
6 changes: 3 additions & 3 deletions examples/key_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct KeyStorage {
}

impl KeyStorage {
fn identity_index_from_pubkey(identities: &Vec<Identity>, pubkey: &PublicKey) -> Option<usize> {
fn identity_index_from_pubkey(identities: &[Identity], pubkey: &PublicKey) -> Option<usize> {
for (index, identity) in identities.iter().enumerate() {
if &identity.pubkey == pubkey {
return Some(index);
Expand Down Expand Up @@ -69,7 +69,7 @@ impl KeyStorage {
}

fn sign(&self, sign_request: &SignRequest) -> Result<Signature, Box<dyn Error>> {
let pubkey: PublicKey = sign_request.pubkey.clone().try_into()?;
let pubkey: PublicKey = sign_request.pubkey.clone().into();

if let Some(identity) = self.identity_from_pubkey(&pubkey) {
match identity.privkey.key_data() {
Expand Down Expand Up @@ -121,7 +121,7 @@ impl KeyStorage {
Ok(Message::IdentitiesAnswer(identities))
}
Message::RemoveIdentity(identity) => {
let pubkey: PublicKey = identity.pubkey.try_into()?;
let pubkey: PublicKey = identity.pubkey.into();
self.identity_remove(&pubkey)?;
Ok(Message::Success)
}
Expand Down

0 comments on commit f92f464

Please sign in to comment.