Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Validates JavaScript and Go frontmatter hash implementations produce identical outputs when fetching workflows via GitHub's repos.getContent API. Includes tests with both mocked and live GitHub API calls, plus automated CI integration.

Changes

  • New test file: actions/setup/js/frontmatter_hash_github_api.test.cjs with 10 tests
  • Tests createGitHubFileReader wrapper for GitHub API
  • Validates against real workflows: audit-workflows.md (with imports), archie.md (without imports)
  • Confirms cross-language hash parity: JS hash === Go hash for identical inputs
  • Live API test: Uses real GitHub API (no mocks) to fetch workflow data from the repository
  • Standalone test script: test-live-github-api.cjs for manual testing with detailed output
  • Documentation: TESTING_LIVE_API.md with instructions for running live API tests
  • CI Integration: Dedicated js-integration-live-api job in .github/workflows/ci.yml that runs the live API test automatically

Example

const { computeFrontmatterHash, createGitHubFileReader } = require("./frontmatter_hash_pure.cjs");
const { getOctokit } = require("@actions/github");

// Create GitHub API file reader (works with real API)
const octokit = getOctokit(process.env.GITHUB_TOKEN);
const fileReader = createGitHubFileReader(octokit, "githubnext", "gh-aw", "main");

// Compute hash via API
const jsHash = await computeFrontmatterHash(".github/workflows/audit-workflows.md", {
  fileReader,
});

// JS: db7af18719075a860ef7e08bb6f49573ac35fbd88190db4f21da3499d3604971
// Go: db7af18719075a860ef7e08bb6f49573ac35fbd88190db4f21da3499d3604971

Test Coverage

  • GitHub API file reader creation and error handling
  • Hash computation with/without imports
  • Import resolution from subdirectories
  • Template expression handling
  • Deterministic hash generation across multiple calls
  • Cross-language validation with filesystem baseline
  • Live GitHub API integration - fetches real workflow data using actual API calls (skips when token unavailable)

CI Integration

The live API test runs automatically in CI via the js-integration-live-api job:

  • Uses secrets.GITHUB_TOKEN to fetch real workflow data
  • Gracefully skips live test if token is unavailable (e.g., in forks)
  • Provides clear summary output in GitHub Actions
  • Runs on all PRs and pushes to main

Running Live API Tests

# Via npm test
GITHUB_TOKEN=ghp_xxx npm test -- frontmatter_hash_github_api.test.cjs

# Via standalone script (more detailed output)
GITHUB_TOKEN=ghp_xxx node actions/setup/js/test-live-github-api.cjs

See actions/setup/js/TESTING_LIVE_API.md for complete documentation on running tests with live GitHub API data.

Original prompt

A test for the JavaScript frontmatter hash algorithm using the GitHub APIs to match the go hash algorithm . Use at least one real api call on a public agentic workflow


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add test for JavaScript frontmatter hash algorithm Add GitHub API integration tests for JavaScript frontmatter hash algorithm Feb 2, 2026
Copilot AI requested a review from pelikhan February 2, 2026 01:43
@pelikhan pelikhan marked this pull request as ready for review February 2, 2026 01:44
@pelikhan
Copy link
Contributor

pelikhan commented Feb 2, 2026

@copilot run at least one test with live data, no locks

- Add test that uses real GitHub API (getOctokit) to fetch workflows
- Test skips gracefully when GITHUB_TOKEN/GH_TOKEN not available
- Add standalone test script (test-live-github-api.cjs) for manual testing
- Add TESTING_LIVE_API.md documentation with usage instructions
- Fetches real workflow with imports from githubnext/gh-aw
- Verifies hash computation is deterministic with live API calls

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot run at least one test with live data, no locks

Added live GitHub API test in commit b4da6e8.

The test uses @actions/github with real API calls (no mocks) to fetch audit-workflows.md and its imports from the repository. It skips gracefully when GITHUB_TOKEN/GH_TOKEN is not set.

To run:

GITHUB_TOKEN=ghp_xxx npm test -- frontmatter_hash_github_api.test.cjs

Also added:

  • Standalone test script: actions/setup/js/test-live-github-api.cjs (more detailed output)
  • Documentation: actions/setup/js/TESTING_LIVE_API.md

Copilot AI changed the title Add GitHub API integration tests for JavaScript frontmatter hash algorithm Add GitHub API integration tests for JavaScript frontmatter hash algorithm (including live API tests) Feb 2, 2026
@pelikhan
Copy link
Contributor

pelikhan commented Feb 2, 2026

@copilot run the test in a dedicated job in ci.yml as an integration test. Skip if GitHub token env var is not set.

- Add js-integration-live-api job to ci.yml
- Runs frontmatter_hash_github_api.test.cjs with real GitHub API
- Gracefully handles missing GITHUB_TOKEN (skips live test)
- Provides clear summary output in GitHub Actions
- Runs after validate-yaml job for faster feedback
- Uses same Node.js setup as main js job

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot run the test in a dedicated job in ci.yml as an integration test. Skip if GitHub token env var is not set.

Added dedicated CI job in commit ec0316f.

The js-integration-live-api job:

  • Runs the live API test (frontmatter_hash_github_api.test.cjs)
  • Uses secrets.GITHUB_TOKEN to fetch real workflow data from the repository
  • Gracefully skips the live test if token is not available (e.g., in forks)
  • Provides clear summary output showing whether the token was available
  • Runs after validate-yaml job for fast feedback

The test will run automatically on all PRs and pushes to main.

Copilot AI changed the title Add GitHub API integration tests for JavaScript frontmatter hash algorithm (including live API tests) Add GitHub API integration tests for JavaScript frontmatter hash algorithm with CI integration Feb 2, 2026
@pelikhan pelikhan merged commit a7c1a95 into main Feb 2, 2026
51 checks passed
@pelikhan pelikhan deleted the copilot/add-js-frontmatter-hash-test branch February 2, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants