Thank you for your interest in contributing to the Last.fm README GitHub Action! 🎵
We welcome contributions of all kinds - whether you're reporting bugs, suggesting features, improving documentation, or submitting code changes. This guide will help you get started.
This project adheres to a code of conduct that we expect all contributors to follow. Please be respectful, inclusive, and constructive in all interactions.
- Node.js: Version 24+
- pnpm: Version 9+
- Fork this repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/lastfm-readme.git cd lastfm-readme
# Install dependencies
pnpm install
# Verify installation
pnpm run types # TypeScript check
pnpm run lint # ESLint check
pnpm test # Run testspnpm build # Build the action
pnpm test # Run all tests
pnpm test:coverage # Run tests with coverage report
pnpm lint # Lint code with ESLint
pnpm format # Format code with Prettier
pnpm types # TypeScript type checkingThis project includes a powerful local development mode that allows you to test all functionality without GitHub Actions.
-
Copy
.env.exampleto.envand fill in your Last.fm API key and username:cp .env.example .env
-
Modify the
local/DEVELOPMENT.mdfile with the desired sections:## Example <!--START_LASTFM_ARTISTS:{"period": "7day", "rows": 5}--> <!--END_LASTFM_ARTISTS--> <!--START_LASTFM_RECENT:{"rows": 5}--> <!--END_LASTFM_RECENT-->
-
Run the local development script:
pnpm dev
This project maintains a comprehensive test suite to ensure code quality and prevent regressions.
- Unit Tests: Test individual functions and modules
- Integration Tests: Test complete workflows end-to-end
- Golden File Tests: Test output formatting and generation
# Run all tests
pnpm test
# Run specific test files
pnpm test tests/unit/section.test.ts
# Run tests with coverage
pnpm test:coverage- Place unit tests in
tests/unit/ - Place integration tests in
tests/integration/ - Use descriptive test names that explain the scenario
- Mock external dependencies (GitHub API, Last.fm API)
- Aim for high coverage of new code
Golden file tests compare actual output against pre-approved reference files. This is perfect for testing README generation where we care about exact formatting.
Golden files are stored in tests/golden/fixtures/ and contain the expected output for various scenarios:
tests/golden/fixtures/
├── sample-input.json # Test input data
├── sample-lastfm-data.json # Mock Last.fm API responses
├── expected-artists-section.md # Expected artists section output
└── expected-recent-section.md # Expected recent tracks output
When you intentionally change the output format (like modifying how sections are rendered), you need to update the golden files:
# Regenerate all golden files
UPDATE_GOLDEN=true pnpm test tests/goldenUPDATE_GOLDEN=true when you've intentionally changed the output format. Always review the diff to ensure the changes are what you expect.
✅ Update golden files when:
- You modify section formatting or layout
- You change how data is rendered (e.g., number formatting)
- You add new configuration options that affect output
- You fix formatting bugs
❌ Don't update golden files when:
- Tests are failing due to logic errors
- You haven't reviewed what changed
- The output looks wrong or broken
- Make your changes to the code
- Run tests - they will fail showing the diff
- Review the diff carefully
- If the changes look correct, run
UPDATE_GOLDEN=true pnpm test tests/golden - Commit both your code changes and the updated golden files
When adding new features:
- Add types first in
src/lastfm/types.tsif needed - Write tests before implementing (TDD approach recommended)
- Update documentation in README.md if user-facing
- Add golden file tests if the feature affects output formatting
- Ensure backwards compatibility or document breaking changes
Adding a new section type:
- Add the section type to
SectionCommentinsrc/section.ts - Create a new file in
src/sections/(e.g.,nowplaying.ts) - Add the section updater to
src/index.ts - Add comprehensive tests in
tests/unit/ - Add golden file tests for the new section format
Modifying output formatting:
- Update the formatting logic in
src/section.ts - Run tests to see what changed
- Review the changes carefully
- Update golden files with
UPDATE_GOLDEN=true pnpm test tests/golden - Update documentation if needed
Happy Contributing! 🎵✨