ci: add utility functions for file management and RPMs#13154
Open
danudey wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new release tooling utilities under release/internal/utils to support (1) linking/copying directory trees with flexible inclusion filters and (2) signing + verifying RPMs using GPG/RPM tooling, along with unit/integration-style tests.
Changes:
- Add RPM signing (
rpmsign) and signature verification (rpmkeys --checksig) helpers ingpg.go. - Add directory/file helpers (
LinkOrCopyDir,FindRecursiveFiles,Match*include-func builders,LinkOrCopyFile,PathExists) infiles.go. - Add tests covering the new utilities.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| release/internal/utils/gpg.go | Adds helpers to sign RPMs and validate RPM signatures using external tooling. |
| release/internal/utils/gpg_test.go | Adds sandboxed tests that generate a temporary GPG key and validate RPM signing/verification behavior. |
| release/internal/utils/files.go | Adds directory traversal + inclusion utilities, hardlink/copy fallback, and a path existence helper. |
| release/internal/utils/files_test.go | Adds unit tests for file/directory utilities and include-function helpers. |
Comment on lines
+44
to
+58
| func SignRPMFiles(gpgKeyID string, rpmFiles []string) error { | ||
| logrus.Infof("Signing RPM files with GPG key %s", gpgKeyID) | ||
| cmdArgs := []string{ | ||
| "-D", fmt.Sprintf("%%_openpgp_sign_id %s", gpgKeyID), | ||
| "--resign", | ||
| "--rpmv4", | ||
| } | ||
| cmdArgs = append(cmdArgs, rpmFiles...) | ||
| logrus.Debugf("Running rpmsign with args %s", strings.Join(cmdArgs, " ")) | ||
| _, err := command.Run("rpmsign", cmdArgs) | ||
| if err != nil { | ||
| return fmt.Errorf("unable to sign RPM files: %w", err) | ||
| } | ||
| return nil | ||
| } |
Comment on lines
+68
to
+81
| rpmOut, err := command.Run("rpmkeys", cmdArgs) | ||
| if err != nil { | ||
| return fmt.Errorf("unable to check RPM signature: %w", err) | ||
| } | ||
| rpmOutFields := strings.Fields(rpmOut) | ||
| if len(rpmOutFields) == 0 { | ||
| return fmt.Errorf("rpmkeys --checksig returned no output") | ||
| } | ||
| if strings.Contains(rpmOut, "NOT OK") { | ||
| logrus.Errorf("RPM signature/digest check failed: %s", rpmOut) | ||
| return fmt.Errorf("RPM signature/digest check failed: %s", rpmOut) | ||
| } | ||
| return nil | ||
| } |
Comment on lines
+114
to
+130
| err := filepath.WalkDir(srcDir, func(path string, d fs.DirEntry, err error) error { | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if d.IsDir() { | ||
| return nil | ||
| } | ||
| relPath, err := filepath.Rel(srcDir, path) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to determine relative path for %s: %w", path, err) | ||
| } | ||
| if !include(srcDir, "", relPath) { | ||
| return nil | ||
| } | ||
| matches = append(matches, filepath.Join(srcDir, relPath)) | ||
| return nil | ||
| }) |
radTuti
reviewed
Jul 8, 2026
radTuti
left a comment
Contributor
There was a problem hiding this comment.
the copilot comment also deserve a looking
| // RPM files. We use --rpmv4 here to ensure that, even on newer | ||
| // RPM versions, we're using backwards-compatible RPM signatures. | ||
| func SignRPMFiles(gpgKeyID string, rpmFiles []string) error { | ||
| logrus.Infof("Signing RPM files with GPG key %s", gpgKeyID) |
Contributor
There was a problem hiding this comment.
what if rpmFIles is empty?
Suggested change
| logrus.Infof("Signing RPM files with GPG key %s", gpgKeyID) | |
| if len(rpmFiles) == 0 { return ... } | |
| logrus.Infof("Signing RPM files with GPG key %s", gpgKeyID) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.