Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A CLI tool for managing GitHub Actions workflows. It helps lint workflows for be
- **style**: Naming conventions and style best practices
- **Auto-fix Issues**: Automatically fix formatting issues and replace version tags with commit hashes
- **Upgrade Actions**: Discover and upgrade GitHub Actions to their latest versions based on semantic versioning patterns
- **Config Management**: Configure linters and version update patterns via `.github-ci.yaml`
- **Config Management**: Configure linters and version patterns via `.github-ci.yaml`

## Quick Start

Expand Down Expand Up @@ -136,10 +136,10 @@ linters:
max-line-length: 120

upgrade:
version: tag # or 'major', 'hash'
format: tag # or 'major', 'hash'
actions:
actions/checkout:
version: ^1.0.0
constraint: ^1.0.0
```

See the [Configuration Guide](https://reugn.github.io/github-ci/configuration/) for all options.
Expand Down
10 changes: 5 additions & 5 deletions docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ linters:
max-line-length: 120

upgrade:
version: tag # 'tag', 'major', or 'hash'
format: tag # 'tag', 'major', or 'hash'
actions:
actions/checkout:
version: ^1.0.0
constraint: ^1.0.0
actions/setup-go:
version: ~1.0.0
constraint: ~1.0.0
```

## Sections
Expand All @@ -56,14 +56,14 @@ upgrade:
|---------|-------------|
| [run](run) | Runtime settings (timeout, exit codes) |
| [linters](linters) | Which linters to enable and their settings |
| [upgrade](upgrade) | Version patterns for action upgrades |
| [upgrade](upgrade) | Version constraints for action upgrades |

## Defaults

If no configuration file exists:

- All linters are enabled
- Actions use `^1.0.0` version pattern (allow minor/patch updates)
- Actions use `^1.0.0` version constraint (allow minor/patch updates)
- Timeout is 5 minutes
- Exit code for issues is 1
- Version format is `tag`
Expand Down
48 changes: 24 additions & 24 deletions docs/configuration/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ The `upgrade` section controls how actions are upgraded.

```yaml
upgrade:
version: tag
format: tag
actions:
actions/checkout:
version: ^1.0.0
constraint: ^1.0.0
actions/setup-go:
version: ~1.0.0
constraint: ~1.0.0
```

### version
### format

Controls the format of action references after upgrade.

Expand All @@ -33,19 +33,19 @@ Controls the format of action references after upgrade.

### actions

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

## Version Patterns
## Version Constraints

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

```yaml
actions:
actions/checkout:
version: ^1.0.0 # Allows 1.x.x but not 2.x.x
constraint: ^1.0.0 # Allows 1.x.x but not 2.x.x
```

| Pattern | Allowed | Not Allowed |
| Constraint | Allowed | Not Allowed |
|---------|---------|-------------|
| `^1.0.0` | `1.0.1`, `1.2.0`, `1.99.0` | `2.0.0` |
| `^2.0.0` | `2.0.1`, `2.5.0` | `3.0.0` |
Expand All @@ -58,10 +58,10 @@ actions:
```yaml
actions:
actions/checkout:
version: ~1.2.0 # Allows 1.2.x but not 1.3.x
constraint: ~1.2.0 # Allows 1.2.x but not 1.3.x
```

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

```yaml
upgrade:
version: tag
format: tag
actions:
actions/checkout:
version: ~4.0.0
constraint: ~4.0.0
actions/setup-go:
version: ~5.0.0
constraint: ~5.0.0
```

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

```yaml
upgrade:
version: major
format: major
actions:
actions/checkout:
version: ^1.0.0
constraint: ^1.0.0
```

Result:
Expand All @@ -109,10 +109,10 @@ Pin to exact commits for maximum security:

```yaml
upgrade:
version: hash
format: hash
actions:
actions/checkout:
version: ^1.0.0
constraint: ^1.0.0
```

Result:
Expand All @@ -122,32 +122,32 @@ Result:

### Mixed Strategies

Different patterns for different actions:
Different constraints for different actions:

```yaml
upgrade:
version: tag
format: tag
actions:
# Critical actions - patch updates only
actions/checkout:
version: ~4.0.0
constraint: ~4.0.0

# Less critical - minor updates allowed
actions/cache:
version: ^4.0.0
constraint: ^4.0.0

# Third-party - more conservative
docker/build-push-action:
version: ~5.0.0
constraint: ~5.0.0
```

## Upgrade Process

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

## See Also

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A CLI tool for managing GitHub Actions workflows. It helps you lint workflows fo
- **Lint Workflows**: Check workflows for best practices with multiple configurable linters
- **Auto-fix Issues**: Automatically fix formatting issues and replace version tags with commit hashes
- **Upgrade Actions**: Discover and upgrade GitHub Actions to their latest versions based on semantic versioning patterns
- **Config Management**: Configure linters and version update patterns via `.github-ci.yaml`
- **Config Management**: Configure linters and version patterns via `.github-ci.yaml`

## Available Linters

Expand Down
8 changes: 4 additions & 4 deletions docs/usage/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ linters:
disable: []
upgrade:
actions: {}
version: tag
format: tag
```

With `--defaults`, all linter settings and discovered actions are included:
Expand Down Expand Up @@ -116,12 +116,12 @@ linters:
max-run-lines: 0

upgrade:
version: tag
format: tag
actions:
actions/checkout:
version: ^1.0.0
constraint: ^1.0.0
actions/setup-go:
version: ^1.0.0
constraint: ^1.0.0
```

See [Configuration](../configuration/) for details on customizing the config.
12 changes: 6 additions & 6 deletions docs/usage/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ github-ci upgrade [flags]

## Description

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

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

## Flags

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

## Version Format

The `upgrade.version` config option controls how actions are referenced after upgrade:
The `upgrade.format` config option controls how actions are referenced after upgrade:

| Format | Example | Description |
|--------|---------|-------------|
Expand All @@ -89,11 +89,11 @@ The `upgrade.version` config option controls how actions are referenced after up
- uses: actions/checkout@8f4b7f84856dbbe3f95729c4cd48d901b28810a # v4.1.1
```

## Version Patterns
## Version Constraints

Control which versions are allowed for each action:

| Pattern | Behavior | Example |
| Constraint | Behavior | Example |
|---------|----------|---------|
| `^1.0.0` | Same major, any minor/patch | `1.x.x` |
| `~1.2.0` | Same major.minor, any patch | `1.2.x` |
Expand All @@ -116,5 +116,5 @@ This appears when:

## See Also

- [Configuration](../configuration/) - Configure version patterns
- [Configuration](../configuration/) - Configure version constraints
- [init](init) - Create configuration file
2 changes: 1 addition & 1 deletion internal/actions/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type CacheStats struct {
// when the same action appears in multiple workflows.
type Cache struct {
mu sync.Mutex
constrained map[string]VersionResult // Results for configured actions with version patterns
constrained map[string]VersionResult // Results for configured actions with version constraints
unconstrained map[string]VersionResult // Results for unconfigured actions (absolute latest)
hits int64
misses int64
Expand Down
22 changes: 11 additions & 11 deletions internal/actions/cache_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import "fmt"

// VersionKey represents a cache key for version lookups.
type VersionKey struct {
Owner string
Repo string
Ref string // Current version reference (e.g., "v1.2.0"); empty for unconstrained
Pattern string // Version constraint (e.g., "^1.0.0"); empty for unconstrained
Owner string
Repo string
Ref string // Current version reference (e.g., "v1.2.0"); empty for unconstrained
Constraint string // Version constraint (e.g., "^1.0.0"); empty for unconstrained
}

// NewConstrainedKey creates a key for constrained version lookups.
func NewConstrainedKey(owner, repo, ref, pattern string) VersionKey {
func NewConstrainedKey(owner, repo, ref, constraint string) VersionKey {
return VersionKey{
Owner: owner,
Repo: repo,
Ref: ref,
Pattern: pattern,
Owner: owner,
Repo: repo,
Ref: ref,
Constraint: constraint,
}
}

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

// IsConstrained returns true if this is a constrained key.
func (k VersionKey) IsConstrained() bool {
return k.Ref != "" || k.Pattern != ""
return k.Ref != "" || k.Constraint != ""
}
4 changes: 2 additions & 2 deletions internal/actions/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestCache_ConstrainedGetSet(t *testing.T) {
differentKey := NewConstrainedKey("owner", "repo", "v1.0.0", "^2.0.0")
_, ok = cache.GetConstrained(differentKey)
if ok {
t.Error("GetConstrained returned ok=true for different pattern")
t.Error("GetConstrained returned ok=true for different constraint")
}
}

Expand Down Expand Up @@ -228,7 +228,7 @@ func TestVersionKey_IsConstrained(t *testing.T) {
expected: true,
},
{
name: "constrained with pattern only",
name: "constrained with constraint only",
key: NewConstrainedKey("owner", "repo", "", "^1.0.0"),
expected: true,
},
Expand Down
Loading
Loading