2026-01-29 13:19:08 +00:00
|
|
|
package publishers
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"bytes"
|
feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
"context"
|
2026-01-29 13:19:08 +00:00
|
|
|
"os"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-02-16 00:30:41 +00:00
|
|
|
"forge.lthn.ai/core/cli/pkg/io"
|
Migrate pkg/release to io.Medium abstraction (#290)
* chore(io): migrate pkg/release to io.Medium abstraction
Migrated `pkg/release` and its subpackages to use the `io.Medium` abstraction for filesystem operations. This enables better testability and support for alternative storage backends.
Changes:
- Added `FS io.Medium` field to `release.Release` and `publishers.Release` structs.
- Updated `LoadConfig`, `ConfigExists`, and `WriteConfig` in `pkg/release/config.go` to accept `io.Medium`.
- Updated `Publish`, `Run`, `findArtifacts`, and `buildArtifacts` in `pkg/release/release.go` to use `io.Medium`.
- Migrated all publishers (`aur`, `chocolatey`, `docker`, `github`, `homebrew`, `linuxkit`, `npm`, `scoop`) to use `io.Medium` for file operations.
- Implemented custom template overrides in publishers by checking for templates in `.core/templates/<publisher>/` via `io.Medium`.
- Updated all relevant tests to provide `io.Medium`.
* chore(io): fix missing callers in pkg/release migration
Updated callers of `release` package functions that had their signatures changed during the `io.Medium` migration.
Fixed files:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These changes ensure the project compiles successfully by providing `io.Local` to `LoadConfig`, `WriteConfig`, and `ConfigExists`.
* chore(io): fix build errors in pkg/release migration
Fixed compilation errors by updating all callers of `release.LoadConfig`, `release.ConfigExists`, and `release.WriteConfig` to provide the required `io.Medium` argument.
Files updated:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These entry points now correctly pass `io.Local` to the `release` package functions.
2026-02-04 15:07:13 +00:00
|
|
|
|
2026-01-29 13:19:08 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestChocolateyPublisher_Name_Good(t *testing.T) {
|
|
|
|
|
t.Run("returns chocolatey", func(t *testing.T) {
|
|
|
|
|
p := NewChocolateyPublisher()
|
|
|
|
|
assert.Equal(t, "chocolatey", p.Name())
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestChocolateyPublisher_ParseConfig_Good(t *testing.T) {
|
|
|
|
|
p := NewChocolateyPublisher()
|
|
|
|
|
|
|
|
|
|
t.Run("uses defaults when no extended config", func(t *testing.T) {
|
|
|
|
|
pubCfg := PublisherConfig{Type: "chocolatey"}
|
|
|
|
|
relCfg := &mockReleaseConfig{repository: "owner/repo"}
|
|
|
|
|
cfg := p.parseConfig(pubCfg, relCfg)
|
|
|
|
|
|
|
|
|
|
assert.Empty(t, cfg.Package)
|
|
|
|
|
assert.False(t, cfg.Push)
|
|
|
|
|
assert.Nil(t, cfg.Official)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("parses package and push from extended config", func(t *testing.T) {
|
|
|
|
|
pubCfg := PublisherConfig{
|
|
|
|
|
Type: "chocolatey",
|
|
|
|
|
Extended: map[string]any{
|
|
|
|
|
"package": "mypackage",
|
|
|
|
|
"push": true,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
relCfg := &mockReleaseConfig{repository: "owner/repo"}
|
|
|
|
|
cfg := p.parseConfig(pubCfg, relCfg)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "mypackage", cfg.Package)
|
|
|
|
|
assert.True(t, cfg.Push)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("parses official config", func(t *testing.T) {
|
|
|
|
|
pubCfg := PublisherConfig{
|
|
|
|
|
Type: "chocolatey",
|
|
|
|
|
Extended: map[string]any{
|
|
|
|
|
"official": map[string]any{
|
|
|
|
|
"enabled": true,
|
|
|
|
|
"output": "dist/choco",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
relCfg := &mockReleaseConfig{repository: "owner/repo"}
|
|
|
|
|
cfg := p.parseConfig(pubCfg, relCfg)
|
|
|
|
|
|
|
|
|
|
require.NotNil(t, cfg.Official)
|
|
|
|
|
assert.True(t, cfg.Official.Enabled)
|
|
|
|
|
assert.Equal(t, "dist/choco", cfg.Official.Output)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("handles missing official fields", func(t *testing.T) {
|
|
|
|
|
pubCfg := PublisherConfig{
|
|
|
|
|
Type: "chocolatey",
|
|
|
|
|
Extended: map[string]any{
|
|
|
|
|
"official": map[string]any{},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
relCfg := &mockReleaseConfig{repository: "owner/repo"}
|
|
|
|
|
cfg := p.parseConfig(pubCfg, relCfg)
|
|
|
|
|
|
|
|
|
|
require.NotNil(t, cfg.Official)
|
|
|
|
|
assert.False(t, cfg.Official.Enabled)
|
|
|
|
|
assert.Empty(t, cfg.Official.Output)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("handles nil extended config", func(t *testing.T) {
|
|
|
|
|
pubCfg := PublisherConfig{
|
|
|
|
|
Type: "chocolatey",
|
|
|
|
|
Extended: nil,
|
|
|
|
|
}
|
|
|
|
|
relCfg := &mockReleaseConfig{repository: "owner/repo"}
|
|
|
|
|
cfg := p.parseConfig(pubCfg, relCfg)
|
|
|
|
|
|
|
|
|
|
assert.Empty(t, cfg.Package)
|
|
|
|
|
assert.False(t, cfg.Push)
|
|
|
|
|
assert.Nil(t, cfg.Official)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("defaults push to false when not specified", func(t *testing.T) {
|
|
|
|
|
pubCfg := PublisherConfig{
|
|
|
|
|
Type: "chocolatey",
|
|
|
|
|
Extended: map[string]any{
|
|
|
|
|
"package": "mypackage",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
relCfg := &mockReleaseConfig{repository: "owner/repo"}
|
|
|
|
|
cfg := p.parseConfig(pubCfg, relCfg)
|
|
|
|
|
|
|
|
|
|
assert.False(t, cfg.Push)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestChocolateyPublisher_RenderTemplate_Good(t *testing.T) {
|
|
|
|
|
p := NewChocolateyPublisher()
|
|
|
|
|
|
|
|
|
|
t.Run("renders nuspec template with data", func(t *testing.T) {
|
|
|
|
|
data := chocolateyTemplateData{
|
|
|
|
|
PackageName: "myapp",
|
|
|
|
|
Title: "MyApp CLI",
|
|
|
|
|
Description: "My awesome CLI",
|
|
|
|
|
Repository: "owner/myapp",
|
|
|
|
|
Version: "1.2.3",
|
|
|
|
|
License: "MIT",
|
|
|
|
|
BinaryName: "myapp",
|
|
|
|
|
Authors: "owner",
|
|
|
|
|
Tags: "cli myapp",
|
|
|
|
|
Checksums: ChecksumMap{},
|
|
|
|
|
}
|
|
|
|
|
|
Migrate pkg/release to io.Medium abstraction (#290)
* chore(io): migrate pkg/release to io.Medium abstraction
Migrated `pkg/release` and its subpackages to use the `io.Medium` abstraction for filesystem operations. This enables better testability and support for alternative storage backends.
Changes:
- Added `FS io.Medium` field to `release.Release` and `publishers.Release` structs.
- Updated `LoadConfig`, `ConfigExists`, and `WriteConfig` in `pkg/release/config.go` to accept `io.Medium`.
- Updated `Publish`, `Run`, `findArtifacts`, and `buildArtifacts` in `pkg/release/release.go` to use `io.Medium`.
- Migrated all publishers (`aur`, `chocolatey`, `docker`, `github`, `homebrew`, `linuxkit`, `npm`, `scoop`) to use `io.Medium` for file operations.
- Implemented custom template overrides in publishers by checking for templates in `.core/templates/<publisher>/` via `io.Medium`.
- Updated all relevant tests to provide `io.Medium`.
* chore(io): fix missing callers in pkg/release migration
Updated callers of `release` package functions that had their signatures changed during the `io.Medium` migration.
Fixed files:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These changes ensure the project compiles successfully by providing `io.Local` to `LoadConfig`, `WriteConfig`, and `ConfigExists`.
* chore(io): fix build errors in pkg/release migration
Fixed compilation errors by updating all callers of `release.LoadConfig`, `release.ConfigExists`, and `release.WriteConfig` to provide the required `io.Medium` argument.
Files updated:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These entry points now correctly pass `io.Local` to the `release` package functions.
2026-02-04 15:07:13 +00:00
|
|
|
result, err := p.renderTemplate(io.Local, "templates/chocolatey/package.nuspec.tmpl", data)
|
2026-01-29 13:19:08 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
assert.Contains(t, result, `<id>myapp</id>`)
|
|
|
|
|
assert.Contains(t, result, `<version>1.2.3</version>`)
|
|
|
|
|
assert.Contains(t, result, `<title>MyApp CLI</title>`)
|
|
|
|
|
assert.Contains(t, result, `<authors>owner</authors>`)
|
|
|
|
|
assert.Contains(t, result, `<description>My awesome CLI</description>`)
|
|
|
|
|
assert.Contains(t, result, `<tags>cli myapp</tags>`)
|
|
|
|
|
assert.Contains(t, result, "projectUrl>https://github.com/owner/myapp")
|
|
|
|
|
assert.Contains(t, result, "releaseNotes>https://github.com/owner/myapp/releases/tag/v1.2.3")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("renders install script template with data", func(t *testing.T) {
|
|
|
|
|
data := chocolateyTemplateData{
|
|
|
|
|
PackageName: "myapp",
|
|
|
|
|
Repository: "owner/myapp",
|
|
|
|
|
Version: "1.2.3",
|
|
|
|
|
BinaryName: "myapp",
|
|
|
|
|
Checksums: ChecksumMap{
|
|
|
|
|
WindowsAmd64: "abc123def456",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
Migrate pkg/release to io.Medium abstraction (#290)
* chore(io): migrate pkg/release to io.Medium abstraction
Migrated `pkg/release` and its subpackages to use the `io.Medium` abstraction for filesystem operations. This enables better testability and support for alternative storage backends.
Changes:
- Added `FS io.Medium` field to `release.Release` and `publishers.Release` structs.
- Updated `LoadConfig`, `ConfigExists`, and `WriteConfig` in `pkg/release/config.go` to accept `io.Medium`.
- Updated `Publish`, `Run`, `findArtifacts`, and `buildArtifacts` in `pkg/release/release.go` to use `io.Medium`.
- Migrated all publishers (`aur`, `chocolatey`, `docker`, `github`, `homebrew`, `linuxkit`, `npm`, `scoop`) to use `io.Medium` for file operations.
- Implemented custom template overrides in publishers by checking for templates in `.core/templates/<publisher>/` via `io.Medium`.
- Updated all relevant tests to provide `io.Medium`.
* chore(io): fix missing callers in pkg/release migration
Updated callers of `release` package functions that had their signatures changed during the `io.Medium` migration.
Fixed files:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These changes ensure the project compiles successfully by providing `io.Local` to `LoadConfig`, `WriteConfig`, and `ConfigExists`.
* chore(io): fix build errors in pkg/release migration
Fixed compilation errors by updating all callers of `release.LoadConfig`, `release.ConfigExists`, and `release.WriteConfig` to provide the required `io.Medium` argument.
Files updated:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These entry points now correctly pass `io.Local` to the `release` package functions.
2026-02-04 15:07:13 +00:00
|
|
|
result, err := p.renderTemplate(io.Local, "templates/chocolatey/tools/chocolateyinstall.ps1.tmpl", data)
|
2026-01-29 13:19:08 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
assert.Contains(t, result, "$ErrorActionPreference = 'Stop'")
|
|
|
|
|
assert.Contains(t, result, "https://github.com/owner/myapp/releases/download/v1.2.3/myapp-windows-amd64.zip")
|
|
|
|
|
assert.Contains(t, result, "packageName = 'myapp'")
|
|
|
|
|
assert.Contains(t, result, "checksum64 = 'abc123def456'")
|
|
|
|
|
assert.Contains(t, result, "checksumType64 = 'sha256'")
|
|
|
|
|
assert.Contains(t, result, "Install-ChocolateyZipPackage")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestChocolateyPublisher_RenderTemplate_Bad(t *testing.T) {
|
|
|
|
|
p := NewChocolateyPublisher()
|
|
|
|
|
|
|
|
|
|
t.Run("returns error for non-existent template", func(t *testing.T) {
|
|
|
|
|
data := chocolateyTemplateData{}
|
Migrate pkg/release to io.Medium abstraction (#290)
* chore(io): migrate pkg/release to io.Medium abstraction
Migrated `pkg/release` and its subpackages to use the `io.Medium` abstraction for filesystem operations. This enables better testability and support for alternative storage backends.
Changes:
- Added `FS io.Medium` field to `release.Release` and `publishers.Release` structs.
- Updated `LoadConfig`, `ConfigExists`, and `WriteConfig` in `pkg/release/config.go` to accept `io.Medium`.
- Updated `Publish`, `Run`, `findArtifacts`, and `buildArtifacts` in `pkg/release/release.go` to use `io.Medium`.
- Migrated all publishers (`aur`, `chocolatey`, `docker`, `github`, `homebrew`, `linuxkit`, `npm`, `scoop`) to use `io.Medium` for file operations.
- Implemented custom template overrides in publishers by checking for templates in `.core/templates/<publisher>/` via `io.Medium`.
- Updated all relevant tests to provide `io.Medium`.
* chore(io): fix missing callers in pkg/release migration
Updated callers of `release` package functions that had their signatures changed during the `io.Medium` migration.
Fixed files:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These changes ensure the project compiles successfully by providing `io.Local` to `LoadConfig`, `WriteConfig`, and `ConfigExists`.
* chore(io): fix build errors in pkg/release migration
Fixed compilation errors by updating all callers of `release.LoadConfig`, `release.ConfigExists`, and `release.WriteConfig` to provide the required `io.Medium` argument.
Files updated:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These entry points now correctly pass `io.Local` to the `release` package functions.
2026-02-04 15:07:13 +00:00
|
|
|
_, err := p.renderTemplate(io.Local, "templates/chocolatey/nonexistent.tmpl", data)
|
2026-01-29 13:19:08 +00:00
|
|
|
assert.Error(t, err)
|
|
|
|
|
assert.Contains(t, err.Error(), "failed to read template")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestChocolateyPublisher_DryRunPublish_Good(t *testing.T) {
|
|
|
|
|
p := NewChocolateyPublisher()
|
|
|
|
|
|
|
|
|
|
t.Run("outputs expected dry run information", func(t *testing.T) {
|
|
|
|
|
oldStdout := os.Stdout
|
|
|
|
|
r, w, _ := os.Pipe()
|
|
|
|
|
os.Stdout = w
|
|
|
|
|
|
|
|
|
|
data := chocolateyTemplateData{
|
|
|
|
|
PackageName: "myapp",
|
|
|
|
|
Version: "1.0.0",
|
|
|
|
|
Repository: "owner/repo",
|
|
|
|
|
BinaryName: "myapp",
|
|
|
|
|
Authors: "owner",
|
|
|
|
|
Tags: "cli myapp",
|
|
|
|
|
Checksums: ChecksumMap{},
|
|
|
|
|
}
|
|
|
|
|
cfg := ChocolateyConfig{
|
|
|
|
|
Push: false,
|
|
|
|
|
}
|
|
|
|
|
|
Migrate pkg/release to io.Medium abstraction (#290)
* chore(io): migrate pkg/release to io.Medium abstraction
Migrated `pkg/release` and its subpackages to use the `io.Medium` abstraction for filesystem operations. This enables better testability and support for alternative storage backends.
Changes:
- Added `FS io.Medium` field to `release.Release` and `publishers.Release` structs.
- Updated `LoadConfig`, `ConfigExists`, and `WriteConfig` in `pkg/release/config.go` to accept `io.Medium`.
- Updated `Publish`, `Run`, `findArtifacts`, and `buildArtifacts` in `pkg/release/release.go` to use `io.Medium`.
- Migrated all publishers (`aur`, `chocolatey`, `docker`, `github`, `homebrew`, `linuxkit`, `npm`, `scoop`) to use `io.Medium` for file operations.
- Implemented custom template overrides in publishers by checking for templates in `.core/templates/<publisher>/` via `io.Medium`.
- Updated all relevant tests to provide `io.Medium`.
* chore(io): fix missing callers in pkg/release migration
Updated callers of `release` package functions that had their signatures changed during the `io.Medium` migration.
Fixed files:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These changes ensure the project compiles successfully by providing `io.Local` to `LoadConfig`, `WriteConfig`, and `ConfigExists`.
* chore(io): fix build errors in pkg/release migration
Fixed compilation errors by updating all callers of `release.LoadConfig`, `release.ConfigExists`, and `release.WriteConfig` to provide the required `io.Medium` argument.
Files updated:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These entry points now correctly pass `io.Local` to the `release` package functions.
2026-02-04 15:07:13 +00:00
|
|
|
err := p.dryRunPublish(io.Local, data, cfg)
|
2026-01-29 13:19:08 +00:00
|
|
|
|
feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
_ = w.Close()
|
2026-01-29 13:19:08 +00:00
|
|
|
var buf bytes.Buffer
|
|
|
|
|
_, _ = buf.ReadFrom(r)
|
|
|
|
|
os.Stdout = oldStdout
|
|
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
output := buf.String()
|
|
|
|
|
|
|
|
|
|
assert.Contains(t, output, "DRY RUN: Chocolatey Publish")
|
|
|
|
|
assert.Contains(t, output, "Package: myapp")
|
|
|
|
|
assert.Contains(t, output, "Version: 1.0.0")
|
|
|
|
|
assert.Contains(t, output, "Push: false")
|
|
|
|
|
assert.Contains(t, output, "Repository: owner/repo")
|
|
|
|
|
assert.Contains(t, output, "Generated package.nuspec:")
|
|
|
|
|
assert.Contains(t, output, "Generated chocolateyinstall.ps1:")
|
|
|
|
|
assert.Contains(t, output, "Would generate package files only (push=false)")
|
|
|
|
|
assert.Contains(t, output, "END DRY RUN")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("shows push message when push is enabled", func(t *testing.T) {
|
|
|
|
|
oldStdout := os.Stdout
|
|
|
|
|
r, w, _ := os.Pipe()
|
|
|
|
|
os.Stdout = w
|
|
|
|
|
|
|
|
|
|
data := chocolateyTemplateData{
|
|
|
|
|
PackageName: "myapp",
|
|
|
|
|
Version: "1.0.0",
|
|
|
|
|
BinaryName: "myapp",
|
|
|
|
|
Authors: "owner",
|
|
|
|
|
Tags: "cli",
|
|
|
|
|
Checksums: ChecksumMap{},
|
|
|
|
|
}
|
|
|
|
|
cfg := ChocolateyConfig{
|
|
|
|
|
Push: true,
|
|
|
|
|
}
|
|
|
|
|
|
Migrate pkg/release to io.Medium abstraction (#290)
* chore(io): migrate pkg/release to io.Medium abstraction
Migrated `pkg/release` and its subpackages to use the `io.Medium` abstraction for filesystem operations. This enables better testability and support for alternative storage backends.
Changes:
- Added `FS io.Medium` field to `release.Release` and `publishers.Release` structs.
- Updated `LoadConfig`, `ConfigExists`, and `WriteConfig` in `pkg/release/config.go` to accept `io.Medium`.
- Updated `Publish`, `Run`, `findArtifacts`, and `buildArtifacts` in `pkg/release/release.go` to use `io.Medium`.
- Migrated all publishers (`aur`, `chocolatey`, `docker`, `github`, `homebrew`, `linuxkit`, `npm`, `scoop`) to use `io.Medium` for file operations.
- Implemented custom template overrides in publishers by checking for templates in `.core/templates/<publisher>/` via `io.Medium`.
- Updated all relevant tests to provide `io.Medium`.
* chore(io): fix missing callers in pkg/release migration
Updated callers of `release` package functions that had their signatures changed during the `io.Medium` migration.
Fixed files:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These changes ensure the project compiles successfully by providing `io.Local` to `LoadConfig`, `WriteConfig`, and `ConfigExists`.
* chore(io): fix build errors in pkg/release migration
Fixed compilation errors by updating all callers of `release.LoadConfig`, `release.ConfigExists`, and `release.WriteConfig` to provide the required `io.Medium` argument.
Files updated:
- `internal/cmd/ci/cmd_init.go`
- `internal/cmd/ci/cmd_publish.go`
- `pkg/build/buildcmd/cmd_release.go`
These entry points now correctly pass `io.Local` to the `release` package functions.
2026-02-04 15:07:13 +00:00
|
|
|
err := p.dryRunPublish(io.Local, data, cfg)
|
2026-01-29 13:19:08 +00:00
|
|
|
|
feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
_ = w.Close()
|
2026-01-29 13:19:08 +00:00
|
|
|
var buf bytes.Buffer
|
|
|
|
|
_, _ = buf.ReadFrom(r)
|
|
|
|
|
os.Stdout = oldStdout
|
|
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
output := buf.String()
|
|
|
|
|
assert.Contains(t, output, "Push: true")
|
|
|
|
|
assert.Contains(t, output, "Would push to Chocolatey community repo")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestChocolateyPublisher_ExecutePublish_Bad(t *testing.T) {
|
|
|
|
|
p := NewChocolateyPublisher()
|
|
|
|
|
|
|
|
|
|
t.Run("fails when CHOCOLATEY_API_KEY not set for push", func(t *testing.T) {
|
|
|
|
|
// Ensure CHOCOLATEY_API_KEY is not set
|
|
|
|
|
oldKey := os.Getenv("CHOCOLATEY_API_KEY")
|
feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
_ = os.Unsetenv("CHOCOLATEY_API_KEY")
|
2026-01-29 13:19:08 +00:00
|
|
|
defer func() {
|
|
|
|
|
if oldKey != "" {
|
feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
_ = os.Setenv("CHOCOLATEY_API_KEY", oldKey)
|
2026-01-29 13:19:08 +00:00
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
// Create a temp directory for the test
|
|
|
|
|
tmpDir, err := os.MkdirTemp("", "choco-test-*")
|
|
|
|
|
require.NoError(t, err)
|
feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
defer func() { _ = os.RemoveAll(tmpDir) }()
|
2026-01-29 13:19:08 +00:00
|
|
|
|
|
|
|
|
data := chocolateyTemplateData{
|
|
|
|
|
PackageName: "testpkg",
|
|
|
|
|
Version: "1.0.0",
|
|
|
|
|
BinaryName: "testpkg",
|
|
|
|
|
Repository: "owner/repo",
|
|
|
|
|
Authors: "owner",
|
|
|
|
|
Tags: "cli",
|
|
|
|
|
Checksums: ChecksumMap{},
|
|
|
|
|
}
|
|
|
|
|
|
feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
err = p.pushToChocolatey(context.TODO(), tmpDir, data)
|
2026-01-29 13:19:08 +00:00
|
|
|
assert.Error(t, err)
|
|
|
|
|
assert.Contains(t, err.Error(), "CHOCOLATEY_API_KEY environment variable is required")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestChocolateyConfig_Defaults_Good(t *testing.T) {
|
|
|
|
|
t.Run("has sensible defaults", func(t *testing.T) {
|
|
|
|
|
p := NewChocolateyPublisher()
|
|
|
|
|
pubCfg := PublisherConfig{Type: "chocolatey"}
|
|
|
|
|
relCfg := &mockReleaseConfig{repository: "owner/repo"}
|
|
|
|
|
|
|
|
|
|
cfg := p.parseConfig(pubCfg, relCfg)
|
|
|
|
|
|
|
|
|
|
assert.Empty(t, cfg.Package)
|
|
|
|
|
assert.False(t, cfg.Push)
|
|
|
|
|
assert.Nil(t, cfg.Official)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestChocolateyTemplateData_Good(t *testing.T) {
|
|
|
|
|
t.Run("struct has all expected fields", func(t *testing.T) {
|
|
|
|
|
data := chocolateyTemplateData{
|
|
|
|
|
PackageName: "myapp",
|
|
|
|
|
Title: "MyApp CLI",
|
|
|
|
|
Description: "description",
|
|
|
|
|
Repository: "org/repo",
|
|
|
|
|
Version: "1.0.0",
|
|
|
|
|
License: "MIT",
|
|
|
|
|
BinaryName: "myapp",
|
|
|
|
|
Authors: "org",
|
|
|
|
|
Tags: "cli tool",
|
|
|
|
|
Checksums: ChecksumMap{
|
|
|
|
|
WindowsAmd64: "hash1",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "myapp", data.PackageName)
|
|
|
|
|
assert.Equal(t, "MyApp CLI", data.Title)
|
|
|
|
|
assert.Equal(t, "description", data.Description)
|
|
|
|
|
assert.Equal(t, "org/repo", data.Repository)
|
|
|
|
|
assert.Equal(t, "1.0.0", data.Version)
|
|
|
|
|
assert.Equal(t, "MIT", data.License)
|
|
|
|
|
assert.Equal(t, "myapp", data.BinaryName)
|
|
|
|
|
assert.Equal(t, "org", data.Authors)
|
|
|
|
|
assert.Equal(t, "cli tool", data.Tags)
|
|
|
|
|
assert.Equal(t, "hash1", data.Checksums.WindowsAmd64)
|
|
|
|
|
})
|
|
|
|
|
}
|