TestAddRemoteWorkflowFromURL tests adding a remote workflow via GitHub URL This test requires GitHub authentication
(t *testing.T)
| 84 | // TestAddRemoteWorkflowFromURL tests adding a remote workflow via GitHub URL |
| 85 | // This test requires GitHub authentication |
| 86 | func TestAddRemoteWorkflowFromURL(t *testing.T) { |
| 87 | // Skip if GitHub authentication is not available |
| 88 | // Check by running `gh auth status` - if it fails, skip |
| 89 | authCmd := exec.Command("gh", "auth", "status") |
| 90 | if err := authCmd.Run(); err != nil { |
| 91 | t.Skip("Skipping test: GitHub authentication not available (gh auth status failed)") |
| 92 | } |
| 93 | |
| 94 | setup := setupAddIntegrationTest(t) |
| 95 | defer setup.cleanup() |
| 96 | |
| 97 | // Add a workflow from a GitHub URL using the non-interactive flag |
| 98 | // Using a workflow from the gh-aw repo itself for reliability |
| 99 | workflowURL := "https://github.com/github/gh-aw/blob/v0.45.5/.github/workflows/github-mcp-tools-report.md" |
| 100 | |
| 101 | cmd := exec.Command(setup.binaryPath, "add", workflowURL, "--verbose") |
| 102 | cmd.Dir = setup.tempDir |
| 103 | output, err := cmd.CombinedOutput() |
| 104 | outputStr := string(output) |
| 105 | |
| 106 | // Log output for debugging |
| 107 | t.Logf("Command output:\n%s", outputStr) |
| 108 | |
| 109 | require.NoError(t, err, "add command should succeed: %s", outputStr) |
| 110 | |
| 111 | // Verify .github/workflows directory was created |
| 112 | workflowsDir := filepath.Join(setup.tempDir, ".github", "workflows") |
| 113 | info, err := os.Stat(workflowsDir) |
| 114 | require.NoError(t, err, ".github/workflows directory should exist") |
| 115 | assert.True(t, info.IsDir(), ".github/workflows should be a directory") |
| 116 | |
| 117 | // Verify the workflow file was created |
| 118 | workflowFile := filepath.Join(workflowsDir, "github-mcp-tools-report.md") |
| 119 | _, err = os.Stat(workflowFile) |
| 120 | require.NoError(t, err, "workflow file should exist: %s", workflowFile) |
| 121 | |
| 122 | // Read and verify the workflow content |
| 123 | content, err := os.ReadFile(workflowFile) |
| 124 | require.NoError(t, err, "should be able to read workflow file") |
| 125 | contentStr := string(content) |
| 126 | |
| 127 | // Verify the workflow has expected content |
| 128 | assert.Contains(t, contentStr, "---", "workflow should have frontmatter delimiters") |
| 129 | assert.Contains(t, contentStr, "on:", "workflow should have trigger definition") |
| 130 | |
| 131 | // Verify source field was added with commit pinning |
| 132 | assert.Contains(t, contentStr, "source:", "workflow should have source field added") |
| 133 | assert.Contains(t, contentStr, "github/gh-aw", "source should reference the source repo") |
| 134 | |
| 135 | // Verify the compiled .lock.yml file was created |
| 136 | lockFile := filepath.Join(workflowsDir, "github-mcp-tools-report.lock.yml") |
| 137 | _, err = os.Stat(lockFile) |
| 138 | require.NoError(t, err, "lock file should exist: %s", lockFile) |
| 139 | |
| 140 | // Verify the lock file contains expected GitHub Actions content |
| 141 | lockContent, err := os.ReadFile(lockFile) |
| 142 | require.NoError(t, err, "should be able to read lock file") |
| 143 | lockContentStr := string(lockContent) |
nothing calls this directly
no test coverage detected