diff --git a/CHANGELOG.md b/CHANGELOG.md index 53e1ed9..bdb882d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.6.0] - 2026-02-14 + +### Added +- Optional `TARGETS` env var to filter output by target name (comma-delimited, supports `*` wildcard globs) + ## [0.5.1] - 2026-02-14 ### Fixed @@ -78,6 +83,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Multi-stage Docker build - Automated vendor upgrade workflow +[0.6.0]: https://github.com/gooddata/gooddata-goodchanges/compare/v0.5.1...v0.6.0 [0.5.1]: https://github.com/gooddata/gooddata-goodchanges/compare/v0.5.0...v0.5.1 [0.5.0]: https://github.com/gooddata/gooddata-goodchanges/compare/v0.4.0...v0.5.0 [0.4.0]: https://github.com/gooddata/gooddata-goodchanges/compare/v0.3.0...v0.4.0 diff --git a/README.md b/README.md index 777bf98..b832339 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,14 @@ JSON array of target objects: ## Environment variables -| Variable | Description | Default | -|---|---|---| -| `LOG_LEVEL` | Logging verbosity. `BASIC` for standard logging, `DEBUG` for verbose AST/taint tracing to stderr | _(no logging)_ | -| `INCLUDE_TYPES` | When set to any non-empty value, includes type-only changes (interfaces, type aliases, type annotations) in taint propagation | _(disabled)_ | -| `INCLUDE_CSS` | When set to any non-empty value, enables CSS/SCSS change detection and taint propagation through `@use`/`@import` chains | _(disabled)_ | -| `COMPARE_COMMIT` | Specific git commit hash to compare against (overrides branch-based comparison) | _(empty)_ | -| `COMPARE_BRANCH` | Git branch to compute merge base against | `origin/master` | +| Variable | Description | Default | +|------------------|-------------------------------------------------------------------------------------------------------------------------------|-----------------| +| `LOG_LEVEL` | Logging verbosity. `BASIC` for standard logging, `DEBUG` for verbose AST/taint tracing to stderr | _(no logging)_ | +| `INCLUDE_TYPES` | When set to any non-empty value, includes type-only changes (interfaces, type aliases, type annotations) in taint propagation | _(disabled)_ | +| `INCLUDE_CSS` | When set to any non-empty value, enables CSS/SCSS change detection and taint propagation through `@use`/`@import` chains | _(disabled)_ | +| `COMPARE_COMMIT` | Specific git commit hash to compare against (overrides branch-based comparison) | _(empty)_ | +| `COMPARE_BRANCH` | Git branch to compute merge base against | `origin/master` | +| `TARGETS` | Comma-delimited list of target names to include in output. Supports `*` wildcard (e.g. `*backstop*,@gooddata/sdk-*`). | _(all targets)_ | ## Library vs app detection @@ -127,13 +128,13 @@ Each `changeDirs` entry is an object with: ### Fields reference -| Field | Type | Used by | Description | -|---|---|---|---| -| `type` | `"target"` \| `"virtual-target"` | Both | Declares what kind of target this project is | -| `app` | `string` | Target | Package name of the corresponding app this e2e package tests | -| `targetName` | `string` | Virtual target | Output name emitted when the virtual target is triggered | -| `changeDirs` | `ChangeDir[]` | Virtual target | Directories to watch. Each entry: `{"path": "...", "type?": "fine-grained"}` | -| `ignores` | `string[]` | Both | Glob patterns for files to exclude from change detection | +| Field | Type | Used by | Description | +|--------------|----------------------------------|----------------|------------------------------------------------------------------------------| +| `type` | `"target"` \| `"virtual-target"` | Both | Declares what kind of target this project is | +| `app` | `string` | Target | Package name of the corresponding app this e2e package tests | +| `targetName` | `string` | Virtual target | Output name emitted when the virtual target is triggered | +| `changeDirs` | `ChangeDir[]` | Virtual target | Directories to watch. Each entry: `{"path": "...", "type?": "fine-grained"}` | +| `ignores` | `string[]` | Both | Glob patterns for files to exclude from change detection | The `.goodchangesrc.json` file itself is always ignored. diff --git a/VERSION b/VERSION index 5d4294b..09a3acf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.1 \ No newline at end of file +0.6.0 \ No newline at end of file diff --git a/main.go b/main.go index 6d67220..e3232e5 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "regexp" "sort" "strings" "sync" @@ -364,6 +365,18 @@ func main() { return e2eList[i].Name < e2eList[j].Name }) + // Filter targets if TARGETS env is set (comma-delimited, supports * globs) + if targetsEnv := os.Getenv("TARGETS"); targetsEnv != "" { + patterns := strings.Split(targetsEnv, ",") + var filtered []*TargetResult + for _, result := range e2eList { + if matchesTargetFilter(result.Name, patterns) { + filtered = append(filtered, result) + } + } + e2eList = filtered + } + if flagLog { logf("Affected e2e packages (%d):\n", len(e2eList)) for _, result := range e2eList { @@ -417,3 +430,29 @@ func findLockfileAffectedProjects(config *rush.Config, mergeBase string) map[str } return result } + +// matchesTargetFilter checks if a target name matches any of the given patterns. +// Patterns support * as a wildcard matching any characters (including /). +func matchesTargetFilter(name string, patterns []string) bool { + for _, p := range patterns { + p = strings.TrimSpace(p) + if p == "" { + continue + } + // Convert glob pattern to regex: * -> .*, escape the rest + var re strings.Builder + re.WriteString("^") + for _, ch := range p { + if ch == '*' { + re.WriteString(".*") + } else { + re.WriteString(regexp.QuoteMeta(string(ch))) + } + } + re.WriteString("$") + if matched, _ := regexp.MatchString(re.String(), name); matched { + return true + } + } + return false +}