Skip to content

Conversation

@RyosukeDTomita
Copy link
Owner

  • feat: just run using fp-ts

  • feat: Add GitHub Actions workflow for Deno tests

  • feat: add unit test

  • chore: fix main.yml to e2e

  • using fp-ts

  • add unit test

Copilot AI review requested due to automatic review settings January 3, 2026 04:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the codebase to use the fp-ts functional programming library, restructures the code into modular files, and adds comprehensive unit testing with GitHub Actions CI/CD integration.

Key Changes

  • Refactored monolithic main.ts into separate modules (src/main.ts, src/streak.ts, src/githubApi.ts, src/config.ts, src/type.ts)
  • Integrated fp-ts library for functional programming patterns, particularly using Option types instead of null values
  • Added unit tests for the streak calculation logic with multiple test cases covering edge scenarios
  • Added GitHub Actions workflow for automated Deno testing using Nix environment

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/streak_test.ts New unit tests for calculateStreak function with 4 test cases covering different streak scenarios
src/type.ts New type definitions module extracting ContributionDay and Week types
src/streak.ts New streak calculation and SVG generation module using fp-ts, with JST timezone support
src/main.ts New main entry point with refactored logic using fp-ts Option types
src/githubApi.ts New GitHub API client module for fetching contribution data
src/config.ts New configuration module for constants and environment variables
main.ts Removed monolithic file in favor of modular structure
deno.lock Added lock file with [email protected] and @std/assert@1 dependencies
deno.jsonc Updated with import maps for fp-ts modules and new test task
README.md Formatting improvements to code block indentation
.github/workflows/main.yml Added push trigger for E2E testing
.github/workflows/deno_test.yml New CI workflow for running Deno tests via Nix
.github/copilot-instructions.md New instructions for using fp-ts Option and Nix Flakes in the project

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- cron: "0 0 * * *"
workflow_dispatch:
#push
pull_request:
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "fix main.yml to e2e" but actually adds a "push" trigger with a comment "for E2E". However, enabling push triggers on every push is typically not intended for E2E testing in production workflows. This might cause unnecessary workflow runs. Consider using a more specific branch pattern or removing this after E2E testing is complete.

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +13
const today = new Date().toISOString().slice(0, 10);
const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000)
.toISOString()
.slice(0, 10);
const twoDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000)
.toISOString()
.slice(0, 10);
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are using UTC date strings (via new Date().toISOString()) but the actual calculateStreak function uses JST dates (via getJSTDateString). This creates a timezone mismatch that could cause the tests to fail or behave unexpectedly, especially when run near midnight. The test dates should be converted to JST to match the implementation.

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +36
const today = new Date().toISOString().slice(0, 10);
const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000)
.toISOString()
.slice(0, 10);
const twoDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000)
.toISOString()
.slice(0, 10);
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are using UTC date strings (via new Date().toISOString()) but the actual calculateStreak function uses JST dates (via getJSTDateString). This creates a timezone mismatch that could cause the tests to fail or behave unexpectedly, especially when run near midnight. The test dates should be converted to JST to match the implementation.

Copilot uses AI. Check for mistakes.
Comment on lines +53 to +59
const today = new Date().toISOString().slice(0, 10);
const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000)
.toISOString()
.slice(0, 10);
const twoDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000)
.toISOString()
.slice(0, 10);
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are using UTC date strings (via new Date().toISOString()) but the actual calculateStreak function uses JST dates (via getJSTDateString). This creates a timezone mismatch that could cause the tests to fail or behave unexpectedly, especially when run near midnight. The test dates should be converted to JST to match the implementation.

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +82
const today = new Date().toISOString().slice(0, 10);
const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000)
.toISOString()
.slice(0, 10);
const twoDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000)
.toISOString()
.slice(0, 10);
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are using UTC date strings (via new Date().toISOString()) but the actual calculateStreak function uses JST dates (via getJSTDateString). This creates a timezone mismatch that could cause the tests to fail or behave unexpectedly, especially when run near midnight. The test dates should be converted to JST to match the implementation.

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +27
/**
* @param weeks
* @returns
*/
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc comment is incomplete. The @param tag describes the parameter but the @returns tag is empty. Consider documenting what the function returns, for example: "@returns StreakInfo object containing the streak count and optional start/end dates".

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +95
/**
* @param streakInfo
* @returns
*/
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc comment is incomplete. Both @param and @returns tags are present but empty. Consider documenting the parameters and return value, for example: "@param streakInfo The streak information containing streak count and dates" and "@returns SVG string representation of the streak badge".

Copilot uses AI. Check for mistakes.
@RyosukeDTomita RyosukeDTomita merged commit a534451 into main Jan 3, 2026
3 checks passed
@RyosukeDTomita RyosukeDTomita deleted the feature/fp-ts branch January 3, 2026 04:11
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