Skip to content

Commit ec50f79

Browse files
committed
Remove 'target' directory from cache in CI workflows
Updated CI and publish GitHub Actions workflows to exclude the 'target' directory from cache paths, improving cache efficiency and avoiding potential issues with stale build artifacts. Also refined the version extraction regex in publish.yml for better accuracy.
1 parent cf8be12 commit ec50f79

8 files changed

Lines changed: 33 additions & 47 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
path: |
3535
~/.cargo/registry
3636
~/.cargo/git
37-
target
3837
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
3938
restore-keys: |
4039
${{ runner.os }}-cargo-test-
@@ -70,7 +69,6 @@ jobs:
7069
path: |
7170
~/.cargo/registry
7271
~/.cargo/git
73-
target
7472
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
7573
restore-keys: |
7674
${{ runner.os }}-cargo-lint-
@@ -104,7 +102,6 @@ jobs:
104102
path: |
105103
~/.cargo/registry
106104
~/.cargo/git
107-
target
108105
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
109106
restore-keys: |
110107
${{ runner.os }}-cargo-build-
@@ -141,7 +138,6 @@ jobs:
141138
path: |
142139
~/.cargo/registry
143140
~/.cargo/git
144-
target
145141
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}
146142
restore-keys: |
147143
${{ runner.os }}-cargo-docs-

.github/workflows/publish.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
path: |
3131
~/.cargo/registry
3232
~/.cargo/git
33-
target
3433
key: ${{ runner.os }}-cargo-publish-${{ hashFiles('**/Cargo.lock') }}
3534
restore-keys: |
3635
${{ runner.os }}-cargo-publish-
@@ -39,7 +38,7 @@ jobs:
3938
if: startsWith(github.ref, 'refs/tags/v')
4039
run: |
4140
TAG_VERSION=${GITHUB_REF#refs/tags/v}
42-
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
41+
CARGO_VERSION=$(grep '^\s*version\s*=' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)"/\1/')
4342
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
4443
echo "Version mismatch: tag=$TAG_VERSION, Cargo.toml=$CARGO_VERSION"
4544
exit 1

crates/rustapi-extras/src/audit/event.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,18 @@ impl std::fmt::Display for AuditAction {
107107
}
108108

109109
/// Severity level for audit events.
110-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
110+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Default)]
111111
#[serde(rename_all = "lowercase")]
112112
pub enum AuditSeverity {
113113
/// Informational - normal operations
114+
#[default]
114115
Info,
115116
/// Warning - unusual but not critical
116117
Warning,
117118
/// Critical - security or compliance concern
118119
Critical,
119120
}
120121

121-
impl Default for AuditSeverity {
122-
fn default() -> Self {
123-
Self::Info
124-
}
125-
}
126-
127122
/// Compliance-related information for GDPR/SOC2.
128123
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
129124
pub struct ComplianceInfo {

crates/rustapi-extras/src/logging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl MiddlewareLayer for LoggingLayer {
134134
let request_id = req
135135
.extensions()
136136
.get::<String>()
137-
.map(|s| s.clone())
137+
.cloned()
138138
.unwrap_or_else(|| "N/A".to_string());
139139

140140
let start = Instant::now();

crates/rustapi-extras/src/otel/config.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ pub enum OtelExporter {
2121
}
2222

2323
/// Trace sampling strategy
24-
#[derive(Clone, Debug)]
24+
#[derive(Clone, Debug, Default)]
2525
pub enum TraceSampler {
2626
/// Always sample all traces
27+
#[default]
2728
AlwaysOn,
2829
/// Never sample traces
2930
AlwaysOff,
@@ -33,12 +34,6 @@ pub enum TraceSampler {
3334
ParentBased,
3435
}
3536

36-
impl Default for TraceSampler {
37-
fn default() -> Self {
38-
Self::AlwaysOn
39-
}
40-
}
41-
4237
/// OpenTelemetry configuration
4338
#[derive(Clone, Debug)]
4439
pub struct OtelConfig {

crates/rustapi-extras/src/otel/propagation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn extract_trace_context(request: &Request) -> TraceContext {
159159
.get(TRACEPARENT_HEADER)
160160
.and_then(|v| v.to_str().ok())
161161
.and_then(TraceContext::from_traceparent)
162-
.unwrap_or_else(TraceContext::new);
162+
.unwrap_or_default();
163163

164164
// Extract tracestate if present
165165
if let Some(state) = headers.get(TRACESTATE_HEADER).and_then(|v| v.to_str().ok()) {

crates/rustapi-extras/src/retry.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -171,29 +171,29 @@ impl MiddlewareLayer for RetryLayer {
171171
let status = response.status().as_u16();
172172

173173
// Check if we should retry
174-
if attempt < config.max_attempts
175-
&& config.retryable_statuses.contains(&status)
176-
&& next_req_opt.is_some()
177-
{
178-
tracing::warn!(
179-
attempt = attempt + 1,
180-
max_attempts = config.max_attempts,
181-
status = status,
182-
"Request failed, retrying..."
183-
);
184-
185-
// Restore request for next attempt
186-
current_req = next_req_opt.unwrap();
187-
188-
// Calculate and sleep for backoff duration
189-
let backoff = self_clone.calculate_backoff(attempt);
190-
tracing::debug!(backoff_ms = backoff.as_millis(), "Waiting before retry");
191-
tokio::time::sleep(backoff).await;
192-
193-
continue;
194-
} else {
195-
// Success or no more retries
196-
if attempt > 0 {
174+
if attempt < config.max_attempts && config.retryable_statuses.contains(&status) {
175+
if let Some(req) = next_req_opt {
176+
tracing::warn!(
177+
attempt = attempt + 1,
178+
max_attempts = config.max_attempts,
179+
status = status,
180+
"Request failed, retrying..."
181+
);
182+
183+
// Restore request for next attempt
184+
current_req = req;
185+
186+
// Calculate and sleep for backoff duration
187+
let backoff = self_clone.calculate_backoff(attempt);
188+
tracing::debug!(backoff_ms = backoff.as_millis(), "Waiting before retry");
189+
tokio::time::sleep(backoff).await;
190+
191+
continue;
192+
}
193+
}
194+
195+
// Success or no more retries
196+
if attempt > 0 {
197197
tracing::info!(
198198
attempt = attempt + 1,
199199
status = status,

crates/rustapi-extras/src/structured_logging/layer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ impl StructuredLoggingLayer {
148148

149149
/// Build a log entry from request and response data
150150
#[allow(dead_code)]
151+
#[allow(clippy::too_many_arguments)]
151152
fn build_entry(
152153
&self,
153154
message: &str,
@@ -262,8 +263,8 @@ impl MiddlewareLayer for StructuredLoggingLayer {
262263
if let Some(ref sid) = span_id {
263264
entry = entry.span_id(sid);
264265
}
265-
if let Some(ref sn) = Some(&service_name) {
266-
entry = entry.service_name(*sn);
266+
if let Some(sn) = Some(&service_name) {
267+
entry = entry.service_name(sn);
267268
}
268269

269270
entry.request_headers = request_headers.clone();

0 commit comments

Comments
 (0)