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
22 changes: 11 additions & 11 deletions actions/setup/js/frontmatter_hash_github_api.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

describe("createGitHubFileReader", () => {
it("should create a file reader that fetches from GitHub API", async () => {
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand All @@ -68,7 +68,7 @@
});

it("should handle file not found errors", async () => {
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand All @@ -80,7 +80,7 @@

describe("computeFrontmatterHash with real workflow", () => {
it("should compute hash for audit-workflows.md using GitHub API", async () => {
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand All @@ -106,7 +106,7 @@
});

it("should handle workflows with imports using GitHub API", async () => {
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand All @@ -133,7 +133,7 @@
});

it("should compute hash for a workflow without imports", async () => {
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand Down Expand Up @@ -170,7 +170,7 @@
const goHash = "db7af18719075a860ef7e08bb6f49573ac35fbd88190db4f21da3499d3604971";

// Verify JavaScript hash matches Go hash
expect(jsHash).toBe(goHash);

Check failure on line 173 in actions/setup/js/frontmatter_hash_github_api.test.cjs

View workflow job for this annotation

GitHub Actions / js-integration-live-api

frontmatter_hash_github_api.test.cjs > frontmatter_hash with GitHub API > cross-language validation > should compute same hash as Go implementation when using file system

AssertionError: expected '2ea961432ad9fd4b99074489b7db5668f2485…' to be 'db7af18719075a860ef7e08bb6f49573ac35f…' // Object.is equality Expected: "db7af18719075a860ef7e08bb6f49573ac35fbd88190db4f21da3499d3604971" Received: "2ea961432ad9fd4b99074489b7db5668f2485e1b1139772c6c375e2032d22134" ❯ frontmatter_hash_github_api.test.cjs:173:22

Check failure on line 173 in actions/setup/js/frontmatter_hash_github_api.test.cjs

View workflow job for this annotation

GitHub Actions / js

frontmatter_hash_github_api.test.cjs > frontmatter_hash with GitHub API > cross-language validation > should compute same hash as Go implementation when using file system

AssertionError: expected '2ea961432ad9fd4b99074489b7db5668f2485…' to be 'db7af18719075a860ef7e08bb6f49573ac35f…' // Object.is equality Expected: "db7af18719075a860ef7e08bb6f49573ac35fbd88190db4f21da3499d3604971" Received: "2ea961432ad9fd4b99074489b7db5668f2485e1b1139772c6c375e2032d22134" ❯ frontmatter_hash_github_api.test.cjs:173:22

// Log the hash for reference
console.log(`JavaScript hash for audit-workflows.md: ${jsHash}`);
Expand All @@ -178,7 +178,7 @@
});

it("should produce deterministic hashes across multiple calls", async () => {
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand All @@ -203,7 +203,7 @@

describe("GitHub API edge cases", () => {
it("should handle workflows in subdirectories", async () => {
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand All @@ -224,7 +224,7 @@
});

it("should handle workflows with template expressions", async () => {
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand All @@ -249,7 +249,7 @@
it("should use repository-relative paths for imports (not absolute filesystem paths)", async () => {
// This test validates the fix for issue where path.resolve() created absolute paths
// that broke GitHub API calls
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand Down Expand Up @@ -312,7 +312,7 @@
});

it("should compute same hash with GitHub API reader as with filesystem reader", async () => {
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand Down Expand Up @@ -346,7 +346,7 @@

// Use real GitHub API client
const octokit = getOctokit(token);
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";

Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/repo_helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function getDefaultTargetRepo(config) {
* Validate that a repo is allowed for operations
* If repo is a bare name (no slash), it is automatically qualified with the
* default repo's organization (e.g., "gh-aw" becomes "github/gh-aw" if
* the default repo is "githubnext/something").
* the default repo is "github/something").
* @param {string} repo - Repository slug to validate (can be "owner/repo" or just "repo")
* @param {string} defaultRepo - Default target repository
* @param {Set<string>} allowedRepos - Set of explicitly allowed repos
Expand Down
14 changes: 7 additions & 7 deletions actions/setup/js/repo_helpers.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe("repo_helpers", () => {
it("should qualify bare repo name with default repo's org", async () => {
const { validateRepo } = await import("./repo_helpers.cjs");
const allowedRepos = new Set(["github/gh-aw"]);
const result = validateRepo("gh-aw", "githubnext/other-repo", allowedRepos);
const result = validateRepo("gh-aw", "github/other-repo", allowedRepos);
expect(result.valid).toBe(true);
expect(result.error).toBe(null);
});
Expand All @@ -149,16 +149,16 @@ describe("repo_helpers", () => {

it("should reject bare repo name not in allowed list", async () => {
const { validateRepo } = await import("./repo_helpers.cjs");
const allowedRepos = new Set(["githubnext/other-repo"]);
const result = validateRepo("gh-aw", "githubnext/default-repo", allowedRepos);
const allowedRepos = new Set(["github/other-repo"]);
const result = validateRepo("gh-aw", "github/default-repo", allowedRepos);
expect(result.valid).toBe(false);
expect(result.error).toContain("not in the allowed-repos list");
});

it("should not qualify repo name that already has org", async () => {
const { validateRepo } = await import("./repo_helpers.cjs");
const allowedRepos = new Set(["github/gh-aw"]);
const result = validateRepo("other-org/gh-aw", "githubnext/default-repo", allowedRepos);
const result = validateRepo("other-org/gh-aw", "github/default-repo", allowedRepos);
expect(result.valid).toBe(false);
expect(result.error).toContain("not in the allowed-repos list");
});
Expand Down Expand Up @@ -264,14 +264,14 @@ describe("repo_helpers", () => {
it("should qualify bare repo name and return qualified version", async () => {
const { resolveAndValidateRepo } = await import("./repo_helpers.cjs");
const item = { repo: "gh-aw" };
const defaultRepo = "githubnext/other-repo";
const defaultRepo = "github/other-repo";
const allowedRepos = new Set(["github/gh-aw"]);

const result = resolveAndValidateRepo(item, defaultRepo, allowedRepos, "test");

expect(result.success).toBe(true);
expect(result.repo).toBe("github/gh-aw");
expect(result.repoParts).toEqual({ owner: "githubnext", repo: "gh-aw" });
expect(result.repoParts).toEqual({ owner: "github", repo: "gh-aw" });
});

it("should qualify bare repo name matching default repo", async () => {
Expand All @@ -284,7 +284,7 @@ describe("repo_helpers", () => {

expect(result.success).toBe(true);
expect(result.repo).toBe("github/gh-aw");
expect(result.repoParts).toEqual({ owner: "githubnext", repo: "gh-aw" });
expect(result.repoParts).toEqual({ owner: "github", repo: "gh-aw" });
});
});

Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/test-live-github-api.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function testLiveGitHubAPI() {
console.log("🔍 Testing frontmatter hash with live GitHub API\n");

// Configuration
const owner = "githubnext";
const owner = "github";
const repo = "gh-aw";
const ref = "main";
const workflowPath = ".github/workflows/audit-workflows.md";
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/update_project.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe("update_project token guardrails", () => {
it("fails fast with a clear error when authenticated as github-actions[bot]", async () => {
delete process.env.GH_AW_PROJECT_GITHUB_TOKEN;

const projectUrl = "https://github.com/orgs/githubnext/projects/146";
const projectUrl = "https://github.com/orgs/github/projects/146";

mockGithub.graphql.mockImplementation(async (query, vars) => {
const q = String(query);
Expand Down
Loading