mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
* feat: add CloudSinkEnvResolver interface with default implementation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add GitHub Actions environment resolver for cloud sink Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: populate invocation context with CI environment on cloud events Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address lint errors in cloud sink tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: use getter-based CloudSinkCIResolver with nil-when-no-CI Rename to CloudSinkCIResolver with focused CI concern. Factory returns nil when no CI is detected, removing the need for IsCI() and a default resolver. Leaves room for a separate agent resolver in the future. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add CI metadata support using updated API SDK Update SDK to include SetMetadata on EndpointCIContext. Add Metadata() to CloudSinkCIResolver interface and GitHub Actions implementation (workflow, job, run_attempt, server_url). Wire metadata into buildInvocationContext. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: address review comments on CI resolver - Inject CloudSinkCIResolver as dependency into newCloudSink for testability - Check both GITHUB_ACTIONS and GITHUB_RUN_ID for GHA environment detection - Make factory and constructor package-private (newCloudSinkCIResolver, newGithubActionsCIResolver) - Attach invocation context only to session complete events, not every event Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: fail fast on os.Getwd error instead of swallowing it Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
37 lines
907 B
Go
37 lines
907 B
Go
package audit
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewCloudSinkCIResolverReturnsNilWhenNoCI(t *testing.T) {
|
|
t.Setenv("GITHUB_ACTIONS", "")
|
|
|
|
resolver := newCloudSinkCIResolver()
|
|
assert.Nil(t, resolver)
|
|
}
|
|
|
|
func TestNewCloudSinkCIResolverReturnsNilWhenPartialEnv(t *testing.T) {
|
|
t.Setenv("GITHUB_ACTIONS", "true")
|
|
t.Setenv("GITHUB_RUN_ID", "")
|
|
|
|
resolver := newCloudSinkCIResolver()
|
|
assert.Nil(t, resolver)
|
|
}
|
|
|
|
func TestNewCloudSinkCIResolverReturnsGitHub(t *testing.T) {
|
|
t.Setenv("GITHUB_ACTIONS", "true")
|
|
t.Setenv("GITHUB_RUN_ID", "12345")
|
|
t.Setenv("GITHUB_REPOSITORY", "safedep/pmg")
|
|
t.Setenv("GITHUB_REF_NAME", "main")
|
|
t.Setenv("GITHUB_SHA", "abc123")
|
|
t.Setenv("GITHUB_ACTOR", "dependabot[bot]")
|
|
|
|
resolver := newCloudSinkCIResolver()
|
|
require.NotNil(t, resolver)
|
|
assert.Equal(t, "safedep/pmg", resolver.Repository())
|
|
}
|