From 5c8b8220e0451cc7ad12d42b864384b132ed020b Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Fri, 4 Jul 2025 07:39:10 -0600 Subject: [PATCH 1/9] fix: correct typo "dependences" to "dependencies" in CLI description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- tools/swift_deps_index/cmd/root.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/swift_deps_index/cmd/root.go b/tools/swift_deps_index/cmd/root.go index 289dfa960..879629352 100644 --- a/tools/swift_deps_index/cmd/root.go +++ b/tools/swift_deps_index/cmd/root.go @@ -9,8 +9,8 @@ import ( // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "swift_deps_index", - Short: "Manage a Swift dependences index file.", - Long: `Manage a Swift dependences index file.`, + Short: "Manage a Swift dependencies index file.", + Long: `Manage a Swift dependencies index file.`, } // Execute adds all child commands to the root command and sets flags appropriately. From 05e0e14e729a41715f40576e9d4ac4499d631605 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Fri, 4 Jul 2025 07:49:26 -0600 Subject: [PATCH 2/9] fix: improve file permissions security from 0666 to 0644 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes file permissions for dependency index files to be more secure by restricting write access to owner only while maintaining read access. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- tools/swift_deps_index/cmd/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/swift_deps_index/cmd/create.go b/tools/swift_deps_index/cmd/create.go index 9513d9130..17a3b5cda 100644 --- a/tools/swift_deps_index/cmd/create.go +++ b/tools/swift_deps_index/cmd/create.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -const dependencyIndexPerms = 0666 +const dependencyIndexPerms = 0644 var outputPath string From 381e337bb93c85a3e3861384430b7913f5e684af Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Fri, 4 Jul 2025 08:23:11 -0600 Subject: [PATCH 3/9] feat: enhance error messages with actionable context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improve error messages in target and build declaration lookup functions to provide clear context and available alternatives: - Target lookup by name: Show available target names when not found - Target lookup by label: Show available target labels when not found - Build declaration lookup: Show available declaration names when not found - Duplicate detection: Show conflicting declaration types for duplicates This helps developers quickly identify typos and understand available options when debugging Swift package configuration issues. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- swiftpkg/internal/build_decls.bzl | 12 ++++++++++-- swiftpkg/internal/pkginfo_targets.bzl | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/swiftpkg/internal/build_decls.bzl b/swiftpkg/internal/build_decls.bzl index ca9d9cb95..59501990f 100644 --- a/swiftpkg/internal/build_decls.bzl +++ b/swiftpkg/internal/build_decls.bzl @@ -75,7 +75,11 @@ def _uniq(decls): for decl in results: name = decl.name if sets.contains(names, name): - fail("A duplicate decl name was found. name: {}".format(name)) + existing_decls = [d for d in results if d.name == name] + fail("Duplicate declaration name '{}' found. Declaration types: [{}]".format( + name, + ", ".join([d.kind for d in existing_decls]), + )) sets.insert(names, name) return results @@ -97,7 +101,11 @@ def _get(decls, name, fail_if_not_found = True): if decl.name == name: return decl if fail_if_not_found: - fail("Failed to find build declaration. name:", name) + available_names = [d.name for d in decls if d.name] + fail("Failed to find build declaration '{}'. Available declarations: [{}]".format( + name, + ", ".join(available_names), + )) return None build_decls = struct( diff --git a/swiftpkg/internal/pkginfo_targets.bzl b/swiftpkg/internal/pkginfo_targets.bzl index 40faa9f7b..f5513a8a5 100644 --- a/swiftpkg/internal/pkginfo_targets.bzl +++ b/swiftpkg/internal/pkginfo_targets.bzl @@ -29,7 +29,11 @@ def _get(targets, name, fail_if_not_found = True): if target.name == name: return target if fail_if_not_found: - fail("Failed to find target. name:", name) + available_names = [t.name for t in targets] + fail("Failed to find target '{}'. Available targets: [{}]".format( + name, + ", ".join(available_names), + )) return None def _get_by_label(targets, label, fail_if_not_found = True): @@ -50,7 +54,11 @@ def _get_by_label(targets, label, fail_if_not_found = True): if target.label == label: return target if fail_if_not_found: - fail("Failed to find target. label:", label) + available_labels = [t.label for t in targets] + fail("Failed to find target with label '{}'. Available target labels: [{}]".format( + label, + ", ".join(available_labels), + )) return None def _srcs(target): From 04705acd38b60c583f9396d3eb23fd8672998943 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Fri, 4 Jul 2025 08:34:39 -0600 Subject: [PATCH 4/9] Enable claude code review workflow. --- .github/workflows/claude-code-review.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 26f383f00..ca51492f7 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -1,14 +1,14 @@ name: Claude Code Review -# on: -# pull_request: -# types: [opened, synchronize] -# # Optional: Only run on specific file changes -# # paths: -# # - "src/**/*.ts" -# # - "src/**/*.tsx" -# # - "src/**/*.js" -# # - "src/**/*.jsx" +on: + pull_request: + types: [opened, synchronize] + # Optional: Only run on specific file changes + # paths: + # - "src/**/*.ts" + # - "src/**/*.tsx" + # - "src/**/*.js" + # - "src/**/*.jsx" jobs: claude-review: From 4e19da9fb355f498d497b8f904e73e9a9d3588b7 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Fri, 4 Jul 2025 08:49:43 -0600 Subject: [PATCH 5/9] feat: enhance Swift package Git configuration error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improve error message for Git reference validation to show what was actually provided vs what's required. Replaces complex boolean logic with clearer list-based validation. Before: "Exactly one of commit, tag, or branch must be provided" After: "Exactly one of commit, tag, or branch must be provided. Found: [commit, tag]" This helps developers quickly identify configuration errors when setting up Swift package Git dependencies. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- swiftpkg/internal/swift_package.bzl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/swiftpkg/internal/swift_package.bzl b/swiftpkg/internal/swift_package.bzl index 2cae8d596..af90915e1 100644 --- a/swiftpkg/internal/swift_package.bzl +++ b/swiftpkg/internal/swift_package.bzl @@ -16,11 +16,19 @@ load(":repo_rules.bzl", "repo_rules") # MARK: - Environment Variables def _clone_or_update_repo(repository_ctx, directory): - if ((not repository_ctx.attr.tag and not repository_ctx.attr.commit and not repository_ctx.attr.branch) or - (repository_ctx.attr.tag and repository_ctx.attr.commit) or - (repository_ctx.attr.tag and repository_ctx.attr.branch) or - (repository_ctx.attr.commit and repository_ctx.attr.branch)): - fail("Exactly one of commit, tag, or branch must be provided") + # Validate that exactly one of commit, tag, or branch is provided + provided = [] + if repository_ctx.attr.commit: + provided.append("commit") + if repository_ctx.attr.tag: + provided.append("tag") + if repository_ctx.attr.branch: + provided.append("branch") + + if len(provided) != 1: + fail("Exactly one of commit, tag, or branch must be provided. Found: [{}]".format( + ", ".join(provided) if provided else "none", + )) git_ = git_repo(repository_ctx, directory) From 8d78269f40a86751cb87f881d3d7626f91855fef Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Fri, 4 Jul 2025 09:00:56 -0600 Subject: [PATCH 6/9] ci: exclude Renovate PRs from Claude Code Review workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the Claude Code Review GitHub workflow to skip dependency update PRs created by app/cgrindel-self-hosted-renovate. This prevents unnecessary code reviews on automated dependency updates while preserving reviews for actual code changes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/claude-code-review.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index ca51492f7..1a770c71d 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -12,8 +12,8 @@ on: jobs: claude-review: - # Skip draft PRs - if: github.event.pull_request.draft == false + # Skip draft PRs and Renovate PRs + if: github.event.pull_request.draft == false && github.event.pull_request.user.login != 'app/cgrindel-self-hosted-renovate' # Optional: Filter by PR author # if: | From e687b7872cf2d45d8e24f9184548c483075592ec Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 6 Jul 2025 13:29:21 -0600 Subject: [PATCH 7/9] About to remove auto_include_paths. --- swiftpkg/internal/clang_files.bzl | 5 ++- swiftpkg/internal/pkginfos.bzl | 52 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/swiftpkg/internal/clang_files.bzl b/swiftpkg/internal/clang_files.bzl index 8bf14b3ba..def5f9516 100644 --- a/swiftpkg/internal/clang_files.bzl +++ b/swiftpkg/internal/clang_files.bzl @@ -315,7 +315,9 @@ def _collect_files( # directory that holds a public header file and add any magical public # header directories that we find. if len(public_includes) == 0: - public_includes = [paths.dirname(hdr) for hdr in sets.to_list(hdrs_set)] + public_includes = sets.to_list(sets.make( + [paths.dirname(hdr) for hdr in sets.to_list(hdrs_set)], + )) magical_public_hdr_dirs = [] for pi in public_includes: magical_public_hdr_dir = clang_files.find_magical_public_hdr_dir(pi) @@ -401,4 +403,5 @@ clang_files = struct( organize_srcs = _organize_srcs, reduce_paths = _reduce_paths, relativize = _relativize, + PUBLIC_HDR_DIRNAMES = _PUBLIC_HDR_DIRNAMES, ) diff --git a/swiftpkg/internal/pkginfos.bzl b/swiftpkg/internal/pkginfos.bzl index 9d33a666c..877abad68 100644 --- a/swiftpkg/internal/pkginfos.bzl +++ b/swiftpkg/internal/pkginfos.bzl @@ -1184,6 +1184,18 @@ def _new_clang_src_info_from_sources( for ep in exclude_paths ] + # DEBUG BEGIN + print("*** CHUCK ============") + print("*** CHUCK c99name: ", c99name) + print("*** CHUCK src_paths: ") + for idx, item in enumerate(src_paths): + print("*** CHUCK", idx, ":", item) + print("*** CHUCK abs_exclude_paths: ") + for idx, item in enumerate(abs_exclude_paths): + print("*** CHUCK", idx, ":", item) + + # DEBUG END + # Get a list of all of the source files all_srcs = [] for sp in src_paths: @@ -1193,6 +1205,29 @@ def _new_clang_src_info_from_sources( exclude_paths = abs_exclude_paths, )) + # TODO(chuck): Document why we are doing this! + auto_include_paths = [] + for public_hdr_dirname in clang_files.PUBLIC_HDR_DIRNAMES: + path = paths.join( + pkg_path, + target_path, + public_hdr_dirname, + ) + if repository_files.is_directory(repository_ctx, path): + all_srcs.extend(repository_files.list_files_under( + repository_ctx, + path, + exclude_paths = abs_exclude_paths, + )) + auto_include_paths.append(path) + + # DEBUG BEGIN + print("*** CHUCK all_srcs: ") + for idx, item in enumerate(all_srcs): + print("*** CHUCK", idx, ":", item) + + # DEBUG END + # Organize the source files # Be sure that the all_srcs and the public_includes that are passed to # `collect_files` are all absolute paths. The relative_to option will @@ -1208,6 +1243,16 @@ def _new_clang_src_info_from_sources( relative_to = pkg_path, ) + # DEBUG BEGIN + print("*** CHUCK auto_include_paths: ") + for idx, item in enumerate(auto_include_paths): + print("*** CHUCK", idx, ":", item) + print("*** CHUCK organized_files.public_includes: ") + for idx, item in enumerate(organized_files.public_includes): + print("*** CHUCK", idx, ":", item) + + # DEBUG END + # The `cc_library` rule compiles each source file (.c, .cc) separately only providing the # headers. There are some clang modules (e.g., # https://github.com/soto-project/soto-core/tree/main/Sources/CSotoExpat) that include @@ -1219,6 +1264,13 @@ def _new_clang_src_info_from_sources( srcs = [] explicit_srcs = [] public_includes = organized_files.public_includes + + # DEBUG BEGIN + print("*** CHUCK organized_files.hdrs: ") + for idx, item in enumerate(organized_files.hdrs): + print("*** CHUCK", idx, ":", item) + + # DEBUG END private_includes = organized_files.private_includes if len(organized_files.srcs) > 0: explicit_srcs.extend(organized_files.srcs) From 481243dfceb40758bb3ff424aa559f8a2b911281 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 6 Jul 2025 13:32:29 -0600 Subject: [PATCH 8/9] Built Clibuv. Multiple modulemap error. --- swiftpkg/internal/pkginfos.bzl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/swiftpkg/internal/pkginfos.bzl b/swiftpkg/internal/pkginfos.bzl index 877abad68..2302b8904 100644 --- a/swiftpkg/internal/pkginfos.bzl +++ b/swiftpkg/internal/pkginfos.bzl @@ -1206,7 +1206,6 @@ def _new_clang_src_info_from_sources( )) # TODO(chuck): Document why we are doing this! - auto_include_paths = [] for public_hdr_dirname in clang_files.PUBLIC_HDR_DIRNAMES: path = paths.join( pkg_path, @@ -1219,7 +1218,7 @@ def _new_clang_src_info_from_sources( path, exclude_paths = abs_exclude_paths, )) - auto_include_paths.append(path) + public_includes.append(path) # DEBUG BEGIN print("*** CHUCK all_srcs: ") @@ -1244,9 +1243,6 @@ def _new_clang_src_info_from_sources( ) # DEBUG BEGIN - print("*** CHUCK auto_include_paths: ") - for idx, item in enumerate(auto_include_paths): - print("*** CHUCK", idx, ":", item) print("*** CHUCK organized_files.public_includes: ") for idx, item in enumerate(organized_files.public_includes): print("*** CHUCK", idx, ":", item) From f5c0787a0d41829de441b12168837b162d8a3a52 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 6 Jul 2025 13:36:47 -0600 Subject: [PATCH 9/9] Fixed multiple modulemap error. Can't find sparsehash/dense_hash_set. --- swiftpkg/internal/pkginfos.bzl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swiftpkg/internal/pkginfos.bzl b/swiftpkg/internal/pkginfos.bzl index 2302b8904..562316e20 100644 --- a/swiftpkg/internal/pkginfos.bzl +++ b/swiftpkg/internal/pkginfos.bzl @@ -1227,6 +1227,10 @@ def _new_clang_src_info_from_sources( # DEBUG END + # At this point, we might have duplicates in all_srcs. We need to remove + # them. + all_srcs = sets.to_list(sets.make(all_srcs)) + # Organize the source files # Be sure that the all_srcs and the public_includes that are passed to # `collect_files` are all absolute paths. The relative_to option will