File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 22 pull_request :
33
44jobs :
5- validate-servers :
5+ validate :
6+ name : " Code and Server Validation"
67 runs-on : ubuntu-latest
78 steps :
89 - uses : actions/checkout@v4
2122 version : 3.x
2223 repo-token : ${{ secrets.GITHUB_TOKEN }}
2324
25+ - name : Run unit tests
26+ run : task unittest
27+
2428 - name : Get changed servers
2529 shell : bash
2630 run : |
Original file line number Diff line number Diff line change 3434 cmds :
3535 - docker mcp catalog reset
3636 - docker mcp catalog init
37+
38+ unittest :
39+ desc : Run Go unit tests
40+ cmd : go test ./...
Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "fmt"
5+ "os"
6+ "path/filepath"
7+ "runtime"
48 "testing"
59)
610
11+ func TestMain (m * testing.M ) {
12+ // Compute the path to this source code file.
13+ _ , thisFile , _ , ok := runtime .Caller (0 )
14+ if ! ok {
15+ fmt .Fprintln (os .Stderr , "mcp-registry/cmd/validate: unable to resolve caller path" )
16+ os .Exit (1 )
17+ }
18+
19+ // Switch to the repository root so that readServerYaml calls from tests can
20+ // access YAML files.
21+ repoRoot := filepath .Clean (filepath .Join (filepath .Dir (thisFile ), ".." , ".." ))
22+ if err := os .Chdir (repoRoot ); err != nil {
23+ fmt .Fprintln (os .Stderr , "mcp-registry/cmd/validate: chdir:" , err )
24+ os .Exit (1 )
25+ }
26+
27+ // Run the tests in this package.
28+ code := m .Run ()
29+
30+ // Restore the working directory.
31+ originalWD := filepath .Clean (filepath .Join (repoRoot , "cmd" , "validate" ))
32+ if err := os .Chdir (originalWD ); err != nil {
33+ fmt .Fprintln (os .Stderr , "mcp-registry/cmd/validate: restore chdir:" , err )
34+ os .Exit (1 )
35+ }
36+
37+ os .Exit (code )
38+ }
39+
740func Test_isNameValid (t * testing.T ) {
841 type args struct {
942 name string
You can’t perform that action at this time.
0 commit comments