Skip to content

Conversation

@igorgatis
Copy link
Owner

Summary

This PR refactors the action to enable unit testing by extracting the inline GitHub script into separate, testable JavaScript modules.

Key Changes

Refactoring:

  • Migrated from actions/github-script to JavaScript action (node20 runtime)
  • Extracted tag generation logic into src/tag-generator.js for testability
  • Created src/index.js as the main action entry point
  • Used @vercel/ncc to bundle dependencies into dist/index.js

Testing:

  • Added comprehensive unit tests (src/tag-generator.test.js)
  • 23 test cases covering all token types and edge cases
  • All tests passing ✓

CI/CD:

  • Added GitHub workflow (.github/workflows/ci.yml) to run tests on push and PRs
  • Enforces that tests pass before merging
  • Checks for uncommitted changes in dist/

Other:

  • Deleted .gitignore to allow committing dist/ (standard practice for GitHub Actions)
  • Added package.json with dependencies and scripts

Test Coverage

Tests cover:

  • Padded vs unpadded date/time tokens
  • 2-digit and 4-digit year formats
  • Full and custom-length SHA formats
  • Semver-compatible formats
  • Repeated tokens
  • Various custom formats

Breaking Changes

None. The action behavior remains identical; only the internal implementation has changed.

🤖 Generated with Claude Code

igorgatis and others added 2 commits November 12, 2025 08:43
Refactored the action to use a JavaScript action structure instead of
inline github-script, enabling unit testing of core functionality.

Changes:
- Delete .gitignore to allow committing dist/
- Extract tag generation logic to src/tag-generator.js
- Create src/index.js as main action entry point
- Add comprehensive unit tests (23 test cases)
- Add package.json with dependencies and test scripts
- Use @vercel/ncc to bundle code into dist/index.js
- Add CI workflow to run tests on push and PRs
- Update action.yml to use node20 runtime

All tests pass and the action is now fully testable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add .gitignore to exclude development artifacts (node_modules, IDE
files) while keeping dist/ committed for GitHub Actions.

Add npm run clean script using git clean to remove all untracked
and ignored files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@igorgatis igorgatis closed this Nov 12, 2025
@igorgatis igorgatis deleted the feature/add-unit-tests branch November 12, 2025 19:48
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