Skip to content

remove config.yaml and replace it with github variable - #2

Open
goku-kamehameha wants to merge 4 commits into
ircfspace:mainfrom
UnboundTechCo:main
Open

remove config.yaml and replace it with github variable#2
goku-kamehameha wants to merge 4 commits into
ircfspace:mainfrom
UnboundTechCo:main

Conversation

@goku-kamehameha

Copy link
Copy Markdown
Collaborator

Create the github variable first

Copilot AI lite review requested due to automatic review settings August 9, 2026 13:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the repository-shipped config.yaml and updates the CLI + GitHub Actions workflow to load configuration from a GitHub Actions variable (XRAY_SUBREFINER_CONFIG) or an explicitly provided -config path, aligning CI runs with repo/environment configuration management.

Changes:

  • Removed config.yaml from the repository and updated documentation to reflect externalized configuration.
  • Updated cmd/xraysubrefiner to resolve config from -config and/or XRAY_SUBREFINER_CONFIG, with parsing support for inline YAML.
  • Updated the normalize workflow to pass XRAY_SUBREFINER_CONFIG via vars and removed the -config config.yaml invocation; added unit tests for config loading behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
README.md Documents the move to XRAY_SUBREFINER_CONFIG and the lack of a default config.yaml.
config.yaml Removes the previously committed default configuration file.
cmd/xraysubrefiner/main.go Adds env/flag-based config resolution and supports inline YAML config sources.
cmd/xraysubrefiner/main_test.go Adds tests covering config source resolution and parsing/file loading.
.github/workflows/normalize.yml Runs without config.yaml, injects XRAY_SUBREFINER_CONFIG from GitHub variables, and updates push remote URL.
Suppressed comments (2)

cmd/xraysubrefiner/main.go:147

  • resolveConfigSource currently falls back to the env var when -config was explicitly provided but left empty (e.g. -config ""). That makes an explicit flag value not reliably take precedence and can silently load the wrong config. Consider treating an explicit -config as authoritative (even if empty), letting loadConfig return a clear error for the empty case.
func resolveConfigSource(explicitConfig bool, flagValue, envValue string) string {
	flagValue = strings.TrimSpace(flagValue)
	if explicitConfig && flagValue != "" {
		return flagValue
	}

cmd/xraysubrefiner/main.go:198

  • looksLikeInlineYAML treats any string containing : as inline YAML. That is very broad and will flag many path-like values (e.g. Windows drive paths or other colon-containing filenames) as YAML. Tightening the heuristic reduces false positives while still supporting common single-line YAML like key: value.
func looksLikeInlineYAML(source string) bool {
	if strings.Contains(source, "\n") || strings.Contains(source, "\r") {
		return true
	}
	if strings.Contains(source, ":") || strings.Contains(source, "{") || strings.Contains(source, "[") {

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +154 to +178
func loadConfig(source string) (*Config, error) {
source = strings.TrimSpace(source)
if source == "" {
return nil, fmt.Errorf("config source is empty")
}

if looksLikeInlineYAML(source) {
return parseConfig([]byte(source))
}

if info, err := os.Stat(source); err == nil {
if info.IsDir() {
return nil, fmt.Errorf("config path %q is a directory", source)
}
b, err := os.ReadFile(source)
if err != nil {
return nil, err
}
return parseConfig(b)
} else if err != nil && !os.IsNotExist(err) {
return nil, err
}

return nil, fmt.Errorf("config source %q not found", source)
}
Comment on lines +68 to 72
configSource := resolveConfigSource(explicitConfig, *cfgPath, os.Getenv(configEnvVar))
cfg, err := loadConfig(configSource)
must(err)

client := &http.Client{Timeout: *timeout}
Comment thread README.md
@@ -80,6 +80,11 @@ A ready-to-use workflow is included at `.github/workflows/normalize.yml`:
- Triggers every hour (`cron: "0 * * * *"`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants