Skip to content

Commit 8529e11

Browse files
committed
fix: ensure action runs from GitHub workspace and handle TLS build on musl
1 parent f19f728 commit 8529e11

5 files changed

Lines changed: 84 additions & 9 deletions

File tree

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ RUN apk add --no-cache ca-certificates
5454
RUN addgroup -g 1000 appuser && \
5555
adduser -D -u 1000 -G appuser appuser
5656

57-
WORKDIR /app
58-
COPY --from=builder /app/target/release/pr-checker /app/pr-checker
57+
# GitHub Actions workspace is mounted at /github/workspace
58+
WORKDIR /github/workspace
59+
COPY --from=builder /app/target/release/pr-checker /usr/local/bin/pr-checker
5960

60-
# Set ownership
61-
RUN chown -R appuser:appuser /app
6261
# Switch to non-root user
6362
USER appuser
6463

65-
ENTRYPOINT ["/app/pr-checker"]
64+
ENTRYPOINT ["/usr/local/bin/pr-checker"]

pr-checker.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
title:
2+
# Regex pattern to match against PR title
3+
# Example: Conventional Commits format
4+
pattern: "^(feat|fix|docs|chore|refactor|test|style|perf|ci|build|revert):"
5+
6+
# Minimum length of the title
7+
min_length: 10
8+
9+
# Maximum length of the title (optional)
10+
# max_length: 100
11+
12+
# Label validation rules
13+
labels:
14+
# List of required labels
15+
# All labels in this list must be present on the PR
16+
required:
17+
# Type/Kind labels - Required: at least one type label
18+
# Common types: bug, feature, enhancement, documentation, refactor, test, chore
19+
- "kind/bug" # Bug fixes
20+
- "kind/feature" # New features
21+
- "kind/docs" # Documentation changes
22+
- "kind/enhancement" # Feature enhancements/improvements
23+
- "kind/refactor" # Code refactoring
24+
- "kind/test" # Adding or updating tests
25+
- "kind/chore" # Maintenance tasks (deps, config, etc.)
26+
- "kind/ci" # CI/CD changes
27+
- "kind/performance" # Performance improvements
28+
- "kind/build" # Build system changes
29+
- "kind/security" # Security fixes
30+
- "kind/dependencies" # Dependency updates
31+
32+
33+
# Priority labels - Optional: uncomment to require priority classification
34+
# Common priorities: low, medium, high, critical
35+
# - "priority/medium" # Uncomment to require priority label
36+
37+
# Area/Component labels - Optional: uncomment to require component classification
38+
# Common areas: frontend, backend, api, database, infrastructure, tooling
39+
# - "area/backend" # Uncomment to require area label
40+
41+
# Size labels - Optional: uncomment to require size estimation
42+
# Common sizes: XS, S, M, L, XL (for effort estimation)
43+
# - "size/M" # Uncomment to require size label

src/config/schema.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,13 @@ impl Config {
4242
let config: Config = serde_yaml::from_str(&content)?;
4343
Ok(config)
4444
}
45+
46+
/// Load built-in default config bundled at compile time.
47+
pub fn from_default() -> crate::error::Result<Self> {
48+
// The default config is stored at repository path `.github/pr-checker.yml`
49+
// and embedded via include_str! to make runtime fallback possible.
50+
const DEFAULT_CONFIG_STR: &str = include_str!("../../pr-checker.yml");
51+
let config: Config = serde_yaml::from_str(DEFAULT_CONFIG_STR)?;
52+
Ok(config)
53+
}
4554
}

src/main.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ mod github;
1919
mod rules;
2020

2121
use clap::Parser;
22-
use tracing::{error, info};
22+
use std::io::ErrorKind;
23+
use tracing::{error, info, warn};
2324

2425
#[derive(Parser)]
2526
#[command(name = "pr-checker")]
@@ -59,6 +60,15 @@ async fn main() {
5960
)
6061
.init();
6162

63+
// Ensure we operate in the GitHub workspace when running as an Action
64+
if let Ok(ws) = std::env::var("GITHUB_WORKSPACE") {
65+
if let Err(e) = std::env::set_current_dir(&ws) {
66+
warn!("Failed to set current dir to GITHUB_WORKSPACE={ws}: {e}");
67+
} else {
68+
info!("Working directory set to GITHUB_WORKSPACE: {}", ws);
69+
}
70+
}
71+
6272
let args = Args::parse();
6373

6474
// Get config path from args or GitHub Actions input or default
@@ -111,9 +121,23 @@ async fn run(config_path: &str) -> error::Result<Vec<rules::Violation>> {
111121
info!("Starting PR checker...");
112122
info!("Config path: {}", config_path);
113123

114-
// Load configuration
115-
let config = config::Config::from_file(config_path)?;
116-
info!("Configuration loaded successfully");
124+
// Load configuration, fallback to built-in default if file missing
125+
let config = match config::Config::from_file(config_path) {
126+
Ok(c) => {
127+
info!("Configuration loaded successfully");
128+
c
129+
}
130+
Err(error::Error::Io(ref e)) if e.kind() == ErrorKind::NotFound => {
131+
warn!(
132+
"Config file not found at '{}', falling back to built-in default",
133+
config_path
134+
);
135+
let cfg = config::Config::from_default()?;
136+
info!("Loaded built-in default configuration");
137+
cfg
138+
}
139+
Err(e) => return Err(e),
140+
};
117141

118142
// Initialize GitHub client from environment
119143
let client = github::GitHubClient::from_env()?;

0 commit comments

Comments
 (0)