Skip to content

Commit 3557773

Browse files
fix: qualify generic Python against an attached source fixture
1 parent 8cdecbf commit 3557773

10 files changed

Lines changed: 80 additions & 2 deletions

File tree

‎agent.codefly.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ version: 0.0.63
55
release:
66
owner: workflow
77
workflow: releaser.yml
8+
conformance:
9+
mode: attach-existing-source
10+
fixture: testdata/conformance

‎conformance_test.go‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"os/exec"
6+
"path/filepath"
7+
"testing"
8+
9+
"github.com/codefly-dev/core/resources"
10+
"github.com/stretchr/testify/require"
11+
"gopkg.in/yaml.v3"
12+
)
13+
14+
func TestConformanceUsesExistingPythonSource(t *testing.T) {
15+
data, err := os.ReadFile("agent.codefly.yaml")
16+
require.NoError(t, err)
17+
var manifest struct {
18+
Conformance struct {
19+
Mode string `yaml:"mode"`
20+
Fixture string `yaml:"fixture"`
21+
} `yaml:"conformance"`
22+
}
23+
require.NoError(t, yaml.Unmarshal(data, &manifest))
24+
require.Equal(t, "attach-existing-source", manifest.Conformance.Mode)
25+
require.True(t, filepath.IsLocal(manifest.Conformance.Fixture))
26+
workspace, err := resources.LoadWorkspaceFromDir(t.Context(), manifest.Conformance.Fixture)
27+
require.NoError(t, err)
28+
module, err := workspace.RootModule(t.Context())
29+
require.NoError(t, err)
30+
service, err := module.LoadServiceFromName(t.Context(), "subject")
31+
require.NoError(t, err)
32+
require.Equal(t, "codefly.dev", service.Agent.Publisher)
33+
require.Equal(t, "python", service.Agent.Name)
34+
require.Equal(t, "latest", service.Agent.Version, "the isolated release gate must exercise its candidate")
35+
command := exec.CommandContext(t.Context(), "uv", "run", "--frozen", "python", "-m", "unittest", "discover")
36+
command.Dir = filepath.Join(manifest.Conformance.Fixture, "services", "subject", "code")
37+
command.Env = append(os.Environ(), "UV_PROJECT_ENVIRONMENT="+filepath.Join(t.TempDir(), "venv"), "PYTHONDONTWRITEBYTECODE=1")
38+
output, err := command.CombinedOutput()
39+
require.NoError(t, err, string(output))
40+
require.Contains(t, string(output), "Ran 1 test")
41+
}

‎go.mod‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.27.0
55
require (
66
github.com/codefly-dev/core v0.4.0
77
github.com/scagogogo/python-requirements-parser v0.0.0-20250717025652-6ca77234c827
8+
github.com/stretchr/testify v1.12.1
89
gopkg.in/yaml.v3 v3.0.1
910
)
1011

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC4
250250
github.com/skeema/knownhosts v1.3.2 h1:EDL9mgf4NzwMXCTfaxSD/o/a5fxDw/xL9nkU28JjdBg=
251251
github.com/skeema/knownhosts v1.3.2/go.mod h1:bEg3iQAuw+jyiw+484wwFJoKSLwcfd7fqRy+N0QTiow=
252252
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
253-
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
254-
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
253+
github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4=
254+
github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0=
255255
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
256256
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
257257
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[project]
2+
name = "python-conformance"
3+
version = "0.0.0"
4+
requires-python = ">=3.12"
5+
dependencies = []
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import unittest
2+
3+
4+
class CalculationTests(unittest.TestCase):
5+
def test_calculation(self):
6+
self.assertEqual(sum([1, 2, 3]), 6)

‎testdata/conformance/services/subject/code/uv.lock‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: subject
2+
version: 0.0.0
3+
agent:
4+
kind: codefly:service
5+
publisher: codefly.dev
6+
name: python
7+
version: latest
8+
spec:
9+
source-dir: code
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: python-conformance
2+
layout: flat
3+
services:
4+
- name: subject

0 commit comments

Comments
 (0)