Skip to content

Commit 7902602

Browse files
committed
refactor(config): rename version fields in upgrade config
1 parent 9ba49b3 commit 7902602

19 files changed

Lines changed: 196 additions & 196 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A CLI tool for managing GitHub Actions workflows. It helps lint workflows for be
2626
- **style**: Naming conventions and style best practices
2727
- **Auto-fix Issues**: Automatically fix formatting issues and replace version tags with commit hashes
2828
- **Upgrade Actions**: Discover and upgrade GitHub Actions to their latest versions based on semantic versioning patterns
29-
- **Config Management**: Configure linters and version update patterns via `.github-ci.yaml`
29+
- **Config Management**: Configure linters and version patterns via `.github-ci.yaml`
3030

3131
## Quick Start
3232

@@ -136,10 +136,10 @@ linters:
136136
max-line-length: 120
137137

138138
upgrade:
139-
version: tag # or 'major', 'hash'
139+
format: tag # or 'major', 'hash'
140140
actions:
141141
actions/checkout:
142-
version: ^1.0.0
142+
constraint: ^1.0.0
143143
```
144144
145145
See the [Configuration Guide](https://reugn.github.io/github-ci/configuration/) for all options.

docs/configuration/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ linters:
4242
max-line-length: 120
4343

4444
upgrade:
45-
version: tag # 'tag', 'major', or 'hash'
45+
format: tag # 'tag', 'major', or 'hash'
4646
actions:
4747
actions/checkout:
48-
version: ^1.0.0
48+
constraint: ^1.0.0
4949
actions/setup-go:
50-
version: ~1.0.0
50+
constraint: ~1.0.0
5151
```
5252
5353
## Sections
@@ -56,14 +56,14 @@ upgrade:
5656
|---------|-------------|
5757
| [run](run) | Runtime settings (timeout, exit codes) |
5858
| [linters](linters) | Which linters to enable and their settings |
59-
| [upgrade](upgrade) | Version patterns for action upgrades |
59+
| [upgrade](upgrade) | Version constraints for action upgrades |
6060
6161
## Defaults
6262
6363
If no configuration file exists:
6464
6565
- All linters are enabled
66-
- Actions use `^1.0.0` version pattern (allow minor/patch updates)
66+
- Actions use `^1.0.0` version constraint (allow minor/patch updates)
6767
- Timeout is 5 minutes
6868
- Exit code for issues is 1
6969
- Version format is `tag`

docs/configuration/upgrade.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ The `upgrade` section controls how actions are upgraded.
1313

1414
```yaml
1515
upgrade:
16-
version: tag
16+
format: tag
1717
actions:
1818
actions/checkout:
19-
version: ^1.0.0
19+
constraint: ^1.0.0
2020
actions/setup-go:
21-
version: ~1.0.0
21+
constraint: ~1.0.0
2222
```
2323
24-
### version
24+
### format
2525
2626
Controls the format of action references after upgrade.
2727
@@ -33,19 +33,19 @@ Controls the format of action references after upgrade.
3333

3434
### actions
3535

36-
Per-action version patterns controlling which versions are allowed.
36+
Per-action version constraints controlling which versions are allowed.
3737

38-
## Version Patterns
38+
## Version Constraints
3939

4040
### Caret (`^`) - Allow Minor Updates
4141

4242
```yaml
4343
actions:
4444
actions/checkout:
45-
version: ^1.0.0 # Allows 1.x.x but not 2.x.x
45+
constraint: ^1.0.0 # Allows 1.x.x but not 2.x.x
4646
```
4747

48-
| Pattern | Allowed | Not Allowed |
48+
| Constraint | Allowed | Not Allowed |
4949
|---------|---------|-------------|
5050
| `^1.0.0` | `1.0.1`, `1.2.0`, `1.99.0` | `2.0.0` |
5151
| `^2.0.0` | `2.0.1`, `2.5.0` | `3.0.0` |
@@ -58,10 +58,10 @@ actions:
5858
```yaml
5959
actions:
6060
actions/checkout:
61-
version: ~1.2.0 # Allows 1.2.x but not 1.3.x
61+
constraint: ~1.2.0 # Allows 1.2.x but not 1.3.x
6262
```
6363

64-
| Pattern | Allowed | Not Allowed |
64+
| Constraint | Allowed | Not Allowed |
6565
|---------|---------|-------------|
6666
| `~1.2.0` | `1.2.1`, `1.2.5` | `1.3.0`, `2.0.0` |
6767
| `~2.5.0` | `2.5.1`, `2.5.99` | `2.6.0` |
@@ -78,12 +78,12 @@ Only allow patch updates for stability:
7878

7979
```yaml
8080
upgrade:
81-
version: tag
81+
format: tag
8282
actions:
8383
actions/checkout:
84-
version: ~4.0.0
84+
constraint: ~4.0.0
8585
actions/setup-go:
86-
version: ~5.0.0
86+
constraint: ~5.0.0
8787
```
8888

8989
### Major Version Pinning
@@ -92,10 +92,10 @@ Use major version tags for cleaner workflow files:
9292

9393
```yaml
9494
upgrade:
95-
version: major
95+
format: major
9696
actions:
9797
actions/checkout:
98-
version: ^1.0.0
98+
constraint: ^1.0.0
9999
```
100100

101101
Result:
@@ -109,10 +109,10 @@ Pin to exact commits for maximum security:
109109

110110
```yaml
111111
upgrade:
112-
version: hash
112+
format: hash
113113
actions:
114114
actions/checkout:
115-
version: ^1.0.0
115+
constraint: ^1.0.0
116116
```
117117

118118
Result:
@@ -122,32 +122,32 @@ Result:
122122

123123
### Mixed Strategies
124124

125-
Different patterns for different actions:
125+
Different constraints for different actions:
126126

127127
```yaml
128128
upgrade:
129-
version: tag
129+
format: tag
130130
actions:
131131
# Critical actions - patch updates only
132132
actions/checkout:
133-
version: ~4.0.0
133+
constraint: ~4.0.0
134134
135135
# Less critical - minor updates allowed
136136
actions/cache:
137-
version: ^4.0.0
137+
constraint: ^4.0.0
138138
139139
# Third-party - more conservative
140140
docker/build-push-action:
141-
version: ~5.0.0
141+
constraint: ~5.0.0
142142
```
143143

144144
## Upgrade Process
145145

146146
1. **Discover**: Scan workflows for action usages
147147
2. **Resolve**: Get current version (resolve hash to tag if needed)
148148
3. **Fetch**: Get latest version from GitHub API
149-
4. **Compare**: Check if update matches version pattern
150-
5. **Update**: Apply update based on `version` format setting
149+
4. **Compare**: Check if update matches version constraint
150+
5. **Update**: Apply update based on `format` setting
151151

152152
## See Also
153153

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A CLI tool for managing GitHub Actions workflows. It helps you lint workflows fo
1313
- **Lint Workflows**: Check workflows for best practices with multiple configurable linters
1414
- **Auto-fix Issues**: Automatically fix formatting issues and replace version tags with commit hashes
1515
- **Upgrade Actions**: Discover and upgrade GitHub Actions to their latest versions based on semantic versioning patterns
16-
- **Config Management**: Configure linters and version update patterns via `.github-ci.yaml`
16+
- **Config Management**: Configure linters and version patterns via `.github-ci.yaml`
1717

1818
## Available Linters
1919

docs/usage/init.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ linters:
8787
disable: []
8888
upgrade:
8989
actions: {}
90-
version: tag
90+
format: tag
9191
```
9292
9393
With `--defaults`, all linter settings and discovered actions are included:
@@ -116,12 +116,12 @@ linters:
116116
max-run-lines: 0
117117
118118
upgrade:
119-
version: tag
119+
format: tag
120120
actions:
121121
actions/checkout:
122-
version: ^1.0.0
122+
constraint: ^1.0.0
123123
actions/setup-go:
124-
version: ^1.0.0
124+
constraint: ^1.0.0
125125
```
126126

127127
See [Configuration](../configuration/) for details on customizing the config.

docs/usage/upgrade.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ github-ci upgrade [flags]
1717

1818
## Description
1919

20-
The `upgrade` command checks for newer versions of actions in all workflows and updates them based on configured version patterns.
20+
The `upgrade` command checks for newer versions of actions in all workflows and updates them based on configured version constraints.
2121

2222
This command:
2323
1. Scans all workflows to discover actions
2424
2. Updates `.github-ci.yaml` if it exists (use `init` command to create one)
2525
3. Checks for newer versions of each action
26-
4. Updates actions based on version patterns defined in the config
26+
4. Updates actions based on version constraints defined in the config
2727

2828
## Flags
2929

@@ -63,7 +63,7 @@ GitHub API: 4 call(s), 2 from cache
6363

6464
## Version Format
6565

66-
The `upgrade.version` config option controls how actions are referenced after upgrade:
66+
The `upgrade.format` config option controls how actions are referenced after upgrade:
6767

6868
| Format | Example | Description |
6969
|--------|---------|-------------|
@@ -89,11 +89,11 @@ The `upgrade.version` config option controls how actions are referenced after up
8989
- uses: actions/checkout@8f4b7f84856dbbe3f95729c4cd48d901b28810a # v4.1.1
9090
```
9191
92-
## Version Patterns
92+
## Version Constraints
9393
9494
Control which versions are allowed for each action:
9595
96-
| Pattern | Behavior | Example |
96+
| Constraint | Behavior | Example |
9797
|---------|----------|---------|
9898
| `^1.0.0` | Same major, any minor/patch | `1.x.x` |
9999
| `~1.2.0` | Same major.minor, any patch | `1.2.x` |
@@ -116,5 +116,5 @@ This appears when:
116116
117117
## See Also
118118
119-
- [Configuration](../configuration/) - Configure version patterns
119+
- [Configuration](../configuration/) - Configure version constraints
120120
- [init](init) - Create configuration file

internal/actions/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type CacheStats struct {
1212
// when the same action appears in multiple workflows.
1313
type Cache struct {
1414
mu sync.Mutex
15-
constrained map[string]VersionResult // Results for configured actions with version patterns
15+
constrained map[string]VersionResult // Results for configured actions with version constraints
1616
unconstrained map[string]VersionResult // Results for unconfigured actions (absolute latest)
1717
hits int64
1818
misses int64

internal/actions/cache_key.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import "fmt"
44

55
// VersionKey represents a cache key for version lookups.
66
type VersionKey struct {
7-
Owner string
8-
Repo string
9-
Ref string // Current version reference (e.g., "v1.2.0"); empty for unconstrained
10-
Pattern string // Version constraint (e.g., "^1.0.0"); empty for unconstrained
7+
Owner string
8+
Repo string
9+
Ref string // Current version reference (e.g., "v1.2.0"); empty for unconstrained
10+
Constraint string // Version constraint (e.g., "^1.0.0"); empty for unconstrained
1111
}
1212

1313
// NewConstrainedKey creates a key for constrained version lookups.
14-
func NewConstrainedKey(owner, repo, ref, pattern string) VersionKey {
14+
func NewConstrainedKey(owner, repo, ref, constraint string) VersionKey {
1515
return VersionKey{
16-
Owner: owner,
17-
Repo: repo,
18-
Ref: ref,
19-
Pattern: pattern,
16+
Owner: owner,
17+
Repo: repo,
18+
Ref: ref,
19+
Constraint: constraint,
2020
}
2121
}
2222

@@ -34,10 +34,10 @@ func (k VersionKey) String() string {
3434
if !k.IsConstrained() {
3535
return fmt.Sprintf("%s/%s", k.Owner, k.Repo)
3636
}
37-
return fmt.Sprintf("%s/%s:%s:%s", k.Owner, k.Repo, k.Ref, k.Pattern)
37+
return fmt.Sprintf("%s/%s:%s:%s", k.Owner, k.Repo, k.Ref, k.Constraint)
3838
}
3939

4040
// IsConstrained returns true if this is a constrained key.
4141
func (k VersionKey) IsConstrained() bool {
42-
return k.Ref != "" || k.Pattern != ""
42+
return k.Ref != "" || k.Constraint != ""
4343
}

internal/actions/cache_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestCache_ConstrainedGetSet(t *testing.T) {
5050
differentKey := NewConstrainedKey("owner", "repo", "v1.0.0", "^2.0.0")
5151
_, ok = cache.GetConstrained(differentKey)
5252
if ok {
53-
t.Error("GetConstrained returned ok=true for different pattern")
53+
t.Error("GetConstrained returned ok=true for different constraint")
5454
}
5555
}
5656

@@ -228,7 +228,7 @@ func TestVersionKey_IsConstrained(t *testing.T) {
228228
expected: true,
229229
},
230230
{
231-
name: "constrained with pattern only",
231+
name: "constrained with constraint only",
232232
key: NewConstrainedKey("owner", "repo", "", "^1.0.0"),
233233
expected: true,
234234
},

0 commit comments

Comments
 (0)