PR fetch when workflow is from a fork

This commit is contained in:
Luke Street
2025-04-18 18:09:42 -06:00
parent 805ebaf3a5
commit 0812b87b3b
4 changed files with 28 additions and 125 deletions
Generated
-121
View File
@@ -1447,21 +1447,6 @@ dependencies = [
"ttf-parser",
]
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.2.1"
@@ -1905,22 +1890,6 @@ dependencies = [
"tower-service",
]
[[package]]
name = "hyper-tls"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
dependencies = [
"bytes",
"http-body-util",
"hyper",
"hyper-util",
"native-tls",
"tokio",
"tokio-native-tls",
"tower-service",
]
[[package]]
name = "hyper-util"
version = "0.1.11"
@@ -2583,23 +2552,6 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03"
[[package]]
name = "native-tls"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466"
dependencies = [
"libc",
"log",
"openssl",
"openssl-probe",
"openssl-sys",
"schannel",
"security-framework",
"security-framework-sys",
"tempfile",
]
[[package]]
name = "new_debug_unreachable"
version = "1.0.6"
@@ -2830,50 +2782,12 @@ version = "1.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
[[package]]
name = "openssl"
version = "0.10.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1"
dependencies = [
"bitflags 2.9.0",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "outref"
version = "0.1.0"
@@ -3966,14 +3880,12 @@ dependencies = [
"http-body-util",
"hyper",
"hyper-rustls",
"hyper-tls",
"hyper-util",
"ipnet",
"js-sys",
"log",
"mime",
"mime_guess",
"native-tls",
"once_cell",
"percent-encoding",
"pin-project-lite",
@@ -3986,9 +3898,7 @@ dependencies = [
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"system-configuration",
"tokio",
"tokio-native-tls",
"tokio-rustls",
"tokio-util",
"tower",
@@ -4931,27 +4841,6 @@ dependencies = [
"futures-core",
]
[[package]]
name = "system-configuration"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
dependencies = [
"bitflags 2.9.0",
"core-foundation",
"system-configuration-sys",
]
[[package]]
name = "system-configuration-sys"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "system-deps"
version = "6.2.2"
@@ -5195,16 +5084,6 @@ dependencies = [
"syn 2.0.87",
]
[[package]]
name = "tokio-native-tls"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
dependencies = [
"native-tls",
"tokio",
]
[[package]]
name = "tokio-rustls"
version = "0.26.0"
+1 -1
View File
@@ -28,7 +28,7 @@ oxc = { version = "0.31", features = ["codegen", "minifier", "transformer", "sem
palette = "0.7"
prost = "0.13"
regex = "1.11"
reqwest = { version = "0.12", features = ["json", "gzip", "zstd"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "gzip", "zstd", "charset", "http2", "rustls-tls-native-roots"] }
resvg = "0.45"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
+3 -2
View File
@@ -111,8 +111,8 @@ impl Database {
let timestamp = commit.timestamp.to_offset(UtcOffset::UTC);
let report_id = sqlx::query!(
r#"
INSERT INTO reports (project_id, version, git_commit, timestamp, data, data_version)
VALUES (?, ?, ?, ?, ?, ?)
INSERT INTO reports (project_id, version, git_commit, git_commit_message, timestamp, data, data_version)
VALUES (?, ?, ?, ?, ?, ?, ?)
ON CONFLICT (project_id, version COLLATE NOCASE, git_commit COLLATE NOCASE) DO UPDATE
SET timestamp = EXCLUDED.timestamp
RETURNING id
@@ -120,6 +120,7 @@ impl Database {
project_id,
version,
commit.sha,
commit.message,
timestamp,
data,
report.version,
+24 -1
View File
@@ -165,7 +165,7 @@ async fn handle_workflow_run_completed(
_workflow: WorkFlow,
workflow_run: RunWithPullRequests,
) -> Result<()> {
let RunWithPullRequests { inner: workflow_run, pull_requests } = workflow_run;
let RunWithPullRequests { inner: workflow_run, mut pull_requests } = workflow_run;
let repository_id = workflow_run.repository.id.into_inner();
let Some(project_info) = state.db.get_project_info_by_id(repository_id, None).await? else {
tracing::warn!("No project found for repository ID {}", repository_id);
@@ -209,7 +209,30 @@ async fn handle_workflow_run_completed(
}
} else if workflow_run.event == "pull_request" {
// Fetch any associated pull requests
if pull_requests.is_empty() {
let head = if let Some(head_owner) =
workflow_run.head_repository.as_ref().and_then(|r| r.owner.as_ref())
{
format!("{}:{}", head_owner.login, workflow_run.head_branch)
} else {
workflow_run.head_branch.clone()
};
pull_requests = client
.all_pages(
client
.pulls(&project_info.project.owner, &project_info.project.repo)
.list()
.head(&head)
.send()
.await?,
)
.await?;
tracing::info!("Found {} pull requests for {}", pull_requests.len(), head);
}
for pull_request in pull_requests {
if pull_request.head.sha != workflow_run.head_sha {
continue;
}
tracing::info!("Processing pull request {}", pull_request.id);
let issues = client.issues_by_id(repository_id);
// Only fetch first page for now