Skip to content

Commit f92f464

Browse files
authored
Merge pull request #37 from wiktor-k/cleanup-ci
Extract common rust CI infra into separate file
2 parents 4051ee2 + 3d2ac15 commit f92f464

File tree

5 files changed

+53
-35
lines changed

5 files changed

+53
-35
lines changed

.github/workflows/misc.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Misc
2+
3+
on:
4+
pull_request:
5+
push:
6+
tags:
7+
- 'v*'
8+
branches: [ main ]
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: misc-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
integration:
17+
name: Integration tests
18+
# If starting the example fails at runtime the integration test will
19+
# be stuck. Try to limit the damage. The value "10" selected arbitrarily.
20+
timeout-minutes: 10
21+
strategy:
22+
matrix:
23+
os: [ ubuntu-latest, macos-latest ]
24+
include:
25+
- os: windows-latest
26+
windows: true
27+
runs-on: ${{ matrix.os }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
# If the example doesn't compile the integration test will
31+
# be stuck. Check for compilation issues earlier to abort the job
32+
- name: Check if the example compiles
33+
run: cargo check --example key_storage
34+
- name: Run integration tests
35+
run: ./tests/sign-and-verify.sh
36+
if: ${{ ! matrix.windows }}
37+
- name: Run integration tests
38+
run: ".\\tests\\sign-and-verify-win.bat"
39+
if: ${{ matrix.windows }}

.github/workflows/ci.yml renamed to .github/workflows/rust.yml

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
workflow_dispatch:
1010

1111
concurrency:
12-
group: ${{ github.ref }}
12+
group: rust-${{ github.ref }}
1313
cancel-in-progress: true
1414

1515
jobs:
@@ -67,7 +67,7 @@ jobs:
6767
steps:
6868
- uses: actions/checkout@v4
6969
- run: cargo install --locked just cargo-deny
70-
- name: Run unit tests
70+
- name: Run dependencies check
7171
run: just dependencies
7272

7373
lints:
@@ -84,28 +84,3 @@ jobs:
8484
- run: cargo install --locked just
8585
- name: Check for lints
8686
run: just lints
87-
88-
integration:
89-
name: Integration tests
90-
# If starting the example fails at runtime the integration test will
91-
# be stuck. Try to limit the damage. The value "10" selected arbitrarily.
92-
timeout-minutes: 10
93-
strategy:
94-
matrix:
95-
os: [ ubuntu-latest, macos-latest ]
96-
include:
97-
- os: windows-latest
98-
windows: true
99-
runs-on: ${{ matrix.os }}
100-
steps:
101-
- uses: actions/checkout@v4
102-
# If the example doesn't compile the integration test will
103-
# be stuck. Check for compilation issues earlier to abort the job
104-
- name: Check if the example compiles
105-
run: cargo check --example key_storage
106-
- name: Run integration tests
107-
run: ./tests/sign-and-verify.sh
108-
if: ${{ ! matrix.windows }}
109-
- name: Run integration tests
110-
run: ".\\tests\\sign-and-verify-win.bat"
111-
if: ${{ matrix.windows }}

.justfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Faster checks need to be executed first for better UX. For example
44

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

88
# Checks common spelling mistakes
99
spelling:
@@ -13,11 +13,11 @@ spelling:
1313
formatting:
1414
just --unstable --fmt --check
1515
# We're using nightly to properly group imports, see .rustfmt.toml
16-
cargo +nightly fmt -- --check
16+
cargo +nightly fmt --all -- --check
1717

1818
# Lints the source code
1919
lints:
20-
cargo clippy --all -- -D warnings
20+
cargo clippy --workspace --no-deps --all-targets -- -D warnings
2121

2222
# Checks for issues with dependencies
2323
dependencies:
@@ -27,6 +27,10 @@ dependencies:
2727
tests:
2828
cargo test --all
2929

30+
# Build docs for this crate only
31+
docs:
32+
cargo doc --no-deps
33+
3034
# Checks for commit messages
3135
check-commits REFS='main..':
3236
#!/usr/bin/env bash
@@ -63,4 +67,4 @@ fix:
6367
cargo clippy --fix --allow-staged
6468

6569
# fmt must be last as clippy's changes may break formatting
66-
cargo +nightly fmt
70+
cargo +nightly fmt --all

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ssh-agent-lib
22

3-
[![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)
3+
[![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)
44
[![Crates.io](https://img.shields.io/crates/v/ssh-agent-lib)](https://crates.io/crates/ssh-agent-lib)
55

66
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).

examples/key_storage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct KeyStorage {
3434
}
3535

3636
impl KeyStorage {
37-
fn identity_index_from_pubkey(identities: &Vec<Identity>, pubkey: &PublicKey) -> Option<usize> {
37+
fn identity_index_from_pubkey(identities: &[Identity], pubkey: &PublicKey) -> Option<usize> {
3838
for (index, identity) in identities.iter().enumerate() {
3939
if &identity.pubkey == pubkey {
4040
return Some(index);
@@ -69,7 +69,7 @@ impl KeyStorage {
6969
}
7070

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

7474
if let Some(identity) = self.identity_from_pubkey(&pubkey) {
7575
match identity.privkey.key_data() {
@@ -121,7 +121,7 @@ impl KeyStorage {
121121
Ok(Message::IdentitiesAnswer(identities))
122122
}
123123
Message::RemoveIdentity(identity) => {
124-
let pubkey: PublicKey = identity.pubkey.try_into()?;
124+
let pubkey: PublicKey = identity.pubkey.into();
125125
self.identity_remove(&pubkey)?;
126126
Ok(Message::Success)
127127
}

0 commit comments

Comments
 (0)