Skip to content

Commit 2adaa2d

Browse files
authored
Merge pull request #9 from Carabryx/ci/codecov-org-setup
ci: standardize Codecov org token setup and add Dependabot
2 parents de18cd3 + c90d97f commit 2adaa2d

24 files changed

Lines changed: 205 additions & 120 deletions

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Enforce LF line endings for all text files
2+
* text=auto eol=lf

.github/dependabot.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
commit-message:
8+
prefix: deps
9+
labels:
10+
- dependencies
11+
open-pull-requests-limit: 10
12+
13+
- package-ecosystem: github-actions
14+
directory: "/"
15+
schedule:
16+
interval: weekly
17+
commit-message:
18+
prefix: ci
19+
labels:
20+
- dependencies
21+
- github-actions
22+
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,26 @@ jobs:
8989
coverage:
9090
name: Code Coverage
9191
runs-on: ubuntu-latest
92+
permissions:
93+
contents: read
9294
steps:
9395
- uses: actions/checkout@v4
9496
- uses: dtolnay/rust-toolchain@stable
9597
- uses: Swatinem/rust-cache@v2
9698
with:
9799
cache-on-failure: true
98100
- name: Install tarpaulin
99-
run: cargo install cargo-tarpaulin
101+
run: cargo install cargo-tarpaulin --locked
100102
- name: Generate coverage
101103
run: cargo tarpaulin --all-features --out Xml --timeout 300
102104
- name: Upload coverage
103-
uses: codecov/codecov-action@v3
105+
uses: codecov/codecov-action@v6
104106
with:
105107
files: ./cobertura.xml
106-
fail_ci_if_error: false
108+
token: ${{ secrets.CODECOV_TOKEN }}
109+
slug: ${{ github.repository }}
110+
fail_ci_if_error: true
111+
verbose: true
107112

108113
docs:
109114
name: Documentation
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Dependabot Auto Merge
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- ready_for_review
10+
11+
concurrency:
12+
group: dependabot-auto-merge-${{ github.event.pull_request.number }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
auto-merge:
17+
if: >
18+
github.event.pull_request.user.login == 'dependabot[bot]' &&
19+
github.event.pull_request.draft == false
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
steps:
25+
- name: Wait for PR checks
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: gh pr checks ${{ github.event.pull_request.number }} --watch --interval 10
29+
30+
- name: Merge Dependabot PR
31+
env:
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: gh pr merge ${{ github.event.pull_request.number }} --squash --delete-branch

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "crabgraph"
33
version = "0.4.0-pre"
4-
authors = ["Raj Sarkar <ariajsarkar@gmail.com>"]
4+
authors = ["Ariaj Sarkar <ariajsarkar@gmail.com>"]
55
edition = "2021"
66
rust-version = "1.70"
77
description = "A safe, ergonomic, high-performance cryptographic library for Rust built on audited primitives"

codecov.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
codecov:
2+
require_ci_to_pass: true
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "70...100"
8+
9+
comment:
10+
layout: "reach,diff,flags,tree"
11+
behavior: default
12+
require_changes: true
13+
14+
ignore:
15+
- "benches/**"
16+
- "examples/**"
17+
- "fuzz/**"

examples/key_wrapping_example.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ fn demo_multiple_sizes() -> CrabResult<()> {
108108
let kek256 = Kw256::generate_kek()?;
109109
let wrapper256 = Kw256::new(&kek256)?;
110110
let wrapped256 = wrapper256.wrap_key(&test_key)?;
111-
println!(
112-
"Kw256: Wrapped {} bytes → {} bytes (RECOMMENDED)",
113-
test_key.len(),
114-
wrapped256.len()
115-
);
111+
println!("Kw256: Wrapped {} bytes → {} bytes (RECOMMENDED)", test_key.len(), wrapped256.len());
116112

117113
// Verify all unwrap correctly
118114
assert_eq!(wrapper128.unwrap_key(&wrapped128)?, test_key);

rustfmt.toml

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,26 @@
1-
# CrabGraph Rustfmt Configuration
1+
# CrabGraph — rustfmt (stable `cargo fmt` compatible)
2+
# Run: cargo fmt --all
23

3-
# Edition
44
edition = "2021"
55

6-
# Formatting
6+
# Primary line length.
77
max_width = 100
8-
hard_tabs = false
9-
tab_spaces = 4
10-
newline_style = "Auto"
11-
12-
# Imports
13-
imports_granularity = "Crate"
14-
group_imports = "StdExternalCrate"
15-
16-
# Function calls
17-
use_small_heuristics = "Default"
18-
fn_call_width = 80
19-
fn_single_line = false
20-
21-
# Chains
8+
# Break method / builder chains sooner (sub-limit of max_width).
229
chain_width = 80
2310

24-
# Comments
25-
comment_width = 100
26-
wrap_comments = true
27-
normalize_comments = true
28-
normalize_doc_attributes = true
11+
# "Off" = stricter wrapping at max_width (fewer very long lines than "Default").
12+
use_small_heuristics = "Off"
2913

30-
# Attributes
31-
reorder_impl_items = false
32-
33-
# Match
34-
match_block_trailing_comma = false
35-
match_arm_blocks = true
36-
match_arm_leading_pipes = "Never"
37-
38-
# Spacing
39-
spaces_around_ranges = false
40-
type_punctuation_density = "Wide"
14+
hard_tabs = false
15+
tab_spaces = 4
16+
newline_style = "Auto"
4117

42-
# Misc
4318
reorder_imports = true
4419
reorder_modules = true
45-
remove_nested_parens = true
46-
format_code_in_doc_comments = true
47-
format_macro_matchers = true
48-
format_macro_bodies = true
20+
21+
# --- Nightly rustfmt only (ignored on stable; use `cargo +nightly fmt --all`) ---
22+
# imports_granularity = "Module"
23+
# group_imports = "StdExternalCrate"
24+
# wrap_comments = true
25+
# comment_width = 80
26+
# format_code_in_doc_comments = true

src/aead/aes_gcm.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ impl AesGcm128 {
4242
let cipher = Aes128Gcm::new_from_slice(key)
4343
.map_err(|e| CrabError::key_error(format!("Invalid AES-128 key: {}", e)))?;
4444

45-
Ok(Self { cipher })
45+
Ok(Self {
46+
cipher,
47+
})
4648
}
4749

4850
/// Generates a random 16-byte key suitable for AES-128-GCM.
@@ -172,7 +174,9 @@ impl AesGcm256 {
172174
let cipher = Aes256Gcm::new_from_slice(key)
173175
.map_err(|e| CrabError::key_error(format!("Invalid AES-256 key: {}", e)))?;
174176

175-
Ok(Self { cipher })
177+
Ok(Self {
178+
cipher,
179+
})
176180
}
177181

178182
/// Generates a random 32-byte key suitable for AES-256-GCM.

src/aead/chacha20poly1305.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ impl ChaCha20Poly1305 {
5858
let cipher = ChaCha20Poly1305Cipher::new_from_slice(key)
5959
.map_err(|e| CrabError::key_error(format!("Invalid ChaCha20-Poly1305 key: {}", e)))?;
6060

61-
Ok(Self { cipher })
61+
Ok(Self {
62+
cipher,
63+
})
6264
}
6365

6466
/// Generates a random 32-byte key suitable for ChaCha20-Poly1305.

0 commit comments

Comments
 (0)