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
3 changes: 3 additions & 0 deletions agent.codefly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ version: 0.0.63
release:
owner: workflow
workflow: releaser.yml
conformance:
mode: attach-existing-source
fixture: testdata/conformance
41 changes: 41 additions & 0 deletions conformance_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"os"
"os/exec"
"path/filepath"
"testing"

"github.com/codefly-dev/core/resources"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
)

func TestConformanceUsesExistingPythonSource(t *testing.T) {
data, err := os.ReadFile("agent.codefly.yaml")
require.NoError(t, err)
var manifest struct {
Conformance struct {
Mode string `yaml:"mode"`
Fixture string `yaml:"fixture"`
} `yaml:"conformance"`
}
require.NoError(t, yaml.Unmarshal(data, &manifest))
require.Equal(t, "attach-existing-source", manifest.Conformance.Mode)
require.True(t, filepath.IsLocal(manifest.Conformance.Fixture))
workspace, err := resources.LoadWorkspaceFromDir(t.Context(), manifest.Conformance.Fixture)
require.NoError(t, err)
module, err := workspace.RootModule(t.Context())
require.NoError(t, err)
service, err := module.LoadServiceFromName(t.Context(), "subject")
require.NoError(t, err)
require.Equal(t, "codefly.dev", service.Agent.Publisher)
require.Equal(t, "python", service.Agent.Name)
require.Equal(t, "latest", service.Agent.Version, "the isolated release gate must exercise its candidate")
command := exec.CommandContext(t.Context(), "uv", "run", "--frozen", "python", "-m", "unittest", "discover")
command.Dir = filepath.Join(manifest.Conformance.Fixture, "services", "subject", "code")
command.Env = append(os.Environ(), "UV_PROJECT_ENVIRONMENT="+filepath.Join(t.TempDir(), "venv"), "PYTHONDONTWRITEBYTECODE=1")
output, err := command.CombinedOutput()
require.NoError(t, err, string(output))
require.Contains(t, string(output), "Ran 1 test")
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.27.0
require (
github.com/codefly-dev/core v0.4.0
github.com/scagogogo/python-requirements-parser v0.0.0-20250717025652-6ca77234c827
github.com/stretchr/testify v1.12.1
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC4
github.com/skeema/knownhosts v1.3.2 h1:EDL9mgf4NzwMXCTfaxSD/o/a5fxDw/xL9nkU28JjdBg=
github.com/skeema/knownhosts v1.3.2/go.mod h1:bEg3iQAuw+jyiw+484wwFJoKSLwcfd7fqRy+N0QTiow=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4=
github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down
1 change: 1 addition & 0 deletions testdata/conformance/services/subject/code/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
5 changes: 5 additions & 0 deletions testdata/conformance/services/subject/code/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[project]
name = "python-conformance"
version = "0.0.0"
requires-python = ">=3.12"
dependencies = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import unittest


class CalculationTests(unittest.TestCase):
def test_calculation(self):
self.assertEqual(sum([1, 2, 3]), 6)
8 changes: 8 additions & 0 deletions testdata/conformance/services/subject/code/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions testdata/conformance/services/subject/service.codefly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: subject
version: 0.0.0
agent:
kind: codefly:service
publisher: codefly.dev
name: python
version: latest
spec:
source-dir: code
4 changes: 4 additions & 0 deletions testdata/conformance/workspace.codefly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: python-conformance
layout: flat
services:
- name: subject
Loading