-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathrun.go
More file actions
94 lines (78 loc) · 2.08 KB
/
Copy pathrun.go
File metadata and controls
94 lines (78 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
"context"
"fmt"
"os"
"path/filepath"
"dagger.io/dagger"
"github.com/open-feature/cli/test/integration"
)
type Test struct {
projectDir string
TestDir string
}
func New(projectDir, testDir string) *Test {
return &Test{
projectDir: projectDir,
TestDir: testDir,
}
}
func (t *Test) Run(ctx context.Context, client *dagger.Client, cli *dagger.Container) (*dagger.Container, error) {
// Mount the test files
testFiles := client.Host().Directory(t.TestDir, dagger.HostDirectoryOpts{
Include: []string{
"package.json",
"tsconfig.json",
"vitest.config.ts",
"setup.ts",
"specs/**/*.ts",
},
})
// Generate the Angular code using the pre-built CLI
generated := cli.WithExec([]string{
"./cli", "generate", "angular",
"--manifest=/src/sample/sample_manifest.json",
"--output=/tmp/generated",
})
// Get the generated files
generatedFiles := generated.Directory("/tmp/generated")
// Create the Angular test container
nodeContainer := client.Container().
From("node:22-alpine").
// Install necessary build tools for native modules
WithExec([]string{"apk", "add", "--no-cache", "python3", "make", "g++"}).
// Copy test files
WithDirectory("/app", testFiles).
// Copy generated files
WithDirectory("/app/generated", generatedFiles).
WithWorkdir("/app").
// Install dependencies
WithExec([]string{"npm", "install"}).
// Run the tests
WithExec([]string{"npm", "test"})
return nodeContainer, nil
}
func (t *Test) Name() string {
return "angular"
}
func (t *Test) ProjectDir() string {
return t.projectDir
}
func main() {
ctx := context.Background()
projectDir, err := filepath.Abs(os.Getenv("PWD"))
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to get project dir: %v\n", err)
os.Exit(1)
}
testDir, err := filepath.Abs(filepath.Join(projectDir, "test/angular-integration"))
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to get test dir: %v\n", err)
os.Exit(1)
}
test := New(projectDir, testDir)
if err := integration.RunTest(ctx, test); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}