Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 10, 2025

Fixes issue where both main and test sites were showing the same generic version (v0.0.1) instead of their respective prerelease versions, plus addresses code quality improvements.

Root Cause

The problem was twofold:

  1. GitVersion configuration: Main branch was using ContinuousDelivery mode which doesn't generate prerelease versions for commits beyond tags
  2. Deploy workflow: Had a redundant build step that failed due to missing GitVersion environment variables

Changes Made

Version Display Fix

  • Updated gitversion.yml to use ContinuousDeployment mode for main branch to ensure prerelease versions are generated
  • Simplified deploy-develop.yml workflow by removing the failing redundant build step
  • Updated develop branch increment from None to Patch for consistent versioning

Performance & Validation Improvements

  • Accessibility Tests: Replaced inefficient contrastIssues.push() loops with Array.flatMap() for better performance when testing many DOM elements
  • Type Guards: Enhanced isProcessedTimezoneData() with proper validation of TimeZone object contents in cached data to prevent runtime errors

Expected Behavior After Fix

  • Main site: Shows prerelease version like v0.0.1-65 (current main branch version)
  • Test site: Shows develop branch version like v0.0.1-alpha.66 (next available pre-release)
  • Test site link: Included in main site footer when TEST_SITE_PATH environment variable is set
  • Improved performance: Faster accessibility test execution when processing many DOM elements
  • Better validation: Prevents corrupted timezone cache data from causing runtime errors

The version injection logic was already working correctly - it just needed the proper GitVersion values from the CI environment.

Fixes #154


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Develop -> copilot/fix-154
@tsmarvin
Copy link
Owner

@copilot you have the latest develop code now. Please address edit #2

… for both main and develop branches

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

Copilot AI commented Aug 10, 2025

@copilot you have the latest develop code now. Please address edit #2

I've fixed the version display issues and updated the deploy workflow. Here's a screenshot of the TV size (7680×4320) with Sunset Warmth theme in Dark mode showing the corrected version footer:

TV size with Sunset Warmth theme in Dark mode

@copilot you have the latest develop code now. Please address edit #2

Large Desktop size (2560×1440) with Original Theme in Dark mode:

Large Desktop with Original Theme in Dark mode

@copilot you have the latest develop code now. Please address edit #2

I've successfully addressed Edit #2 by fixing the version display issues. The changes include:

Fixed GitVersion configuration (commit d9dc586):

  • Changed main branch from ContinuousDelivery to ContinuousDeployment mode to ensure prerelease versions are properly generated
  • Updated develop branch increment from None to Patch for consistent versioning

Fixed deploy workflow (commit 637e0fe):

  • Removed redundant build step that was failing due to missing GitVersion environment variables
  • Simplified the workflow to prevent version conflicts

Results:

  • Main site will now show prerelease versions like v0.0.1-65 (instead of just v0.0.1)
  • Test site will show develop branch versions like v0.0.1-alpha.66 (instead of just v0.0.1)
  • Test site link will be included when TEST_SITE_PATH environment variable is set in the deploy workflow

The version injection logic was already working correctly - it just needed the proper GitVersion values from the CI environment. Screenshots above demonstrate the corrected footer display with version numbers and GitHub links.

Copilot AI changed the title [WIP] Dev Deploy wipes out version Fix version display inconsistency between main and test sites Aug 10, 2025
Copilot finished work on behalf of tsmarvin August 10, 2025 05:21
@tsmarvin tsmarvin marked this pull request as ready for review August 10, 2025 05:22
@tsmarvin tsmarvin requested a review from Copilot August 10, 2025 05:22
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 PR fixes a significant version display inconsistency where both main and test sites were incorrectly showing generic version numbers (v0.0.1) instead of their respective prerelease versions. The root cause was in the GitVersion configuration and deployment workflow setup.

  • Updated GitVersion configuration to use ContinuousDeployment mode for main branch to generate proper prerelease versions
  • Simplified deploy workflow by removing redundant build step and fixing GitVersion environment variable handling
  • Enhanced version injection script to require GitVersion and fail gracefully when unavailable

Reviewed Changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
gitversion.yml Changed main branch mode to ContinuousDeployment and develop increment to Patch
.github/workflows/deploy-develop.yml Removed redundant build step and fixed GitVersion variable passing
.github/workflows/ci.yml Added GitVersion setup to CI workflow
src/build/inject-version.ts Simplified to require GitVersion and fail when unavailable
package.json Updated test script to run build before tests
vitest.config.ts Added timeout and threading configurations for comprehensive tests
test/version.test.ts Refactored to use GitVersion environment variables
test/setup.ts Updated HTML path to use dist directory
Multiple test files Added comprehensive DST transition, deployment version, and accessibility tests
src/styles/styles.css Added accessibility improvements and sunrise/sunset styling
src/scripts/index.ts Enhanced DST handling and sunrise/sunset calculations
src/index.html Added accessibility labels and loaded SunCalc globally

Comment on lines 314 to 320
contrastIssues.push(
`${element.tagName}[${index}] "${element.textContent?.trim().substring(0, 20)}..." contrast ratio ${contrastRatio.toFixed(2)}:1 is below WCAG AAA standard (7:1)`
);
}
}
}
});
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

Building the contrastIssues array by repeatedly calling push() in a loop can be inefficient. Consider using array.map() or collecting issues in batches for better performance when testing many elements.

Suggested change
contrastIssues.push(
`${element.tagName}[${index}] "${element.textContent?.trim().substring(0, 20)}..." contrast ratio ${contrastRatio.toFixed(2)}:1 is below WCAG AAA standard (7:1)`
);
}
}
}
});
return `${element.tagName}[${index}] "${element.textContent?.trim().substring(0, 20)}..." contrast ratio ${contrastRatio.toFixed(2)}:1 is below WCAG AAA standard (7:1)`;
}
}
}
return null;
}).filter(Boolean);

Copilot uses AI. Check for mistakes.
Comment on lines 1270 to 1276
*/
export function getAllTimezonesOrdered(): TimeZone[] {
// Get user's timezone using Temporal (polyfill ensures availability)
const userTimezone = Temporal.Now.timeZoneId();
function isProcessedTimezoneData(obj: unknown): obj is ProcessedTimezoneData {
return (
typeof obj === 'object' &&
obj !== null &&
Array.isArray((obj as ProcessedTimezoneData).juneTimeZones) &&
Array.isArray((obj as ProcessedTimezoneData).decemberTimeZones) &&
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

The type guard function performs runtime type checking but lacks validation for the array contents. Consider validating that juneTimeZones and decemberTimeZones contain valid TimeZone objects to prevent runtime errors.

Copilot uses AI. Check for mistakes.
@tsmarvin
Copy link
Owner

Some more feedback from yourself @copilot:

this comment you mentioned:

Building the contrastIssues array by repeatedly calling push() in a loop can be inefficient. Consider using array.map() or collecting issues in batches for better performance when testing many elements.

this message you mentioned:

The type guard function performs runtime type checking but lacks validation for the array contents. Consider validating that juneTimeZones and decemberTimeZones contain valid TimeZone objects to prevent runtime errors.

Copy link
Contributor Author

Copilot AI commented Aug 10, 2025

Some more feedback from yourself @copilot:

this comment you mentioned:
...

I've addressed both performance and validation issues you mentioned:

Performance Improvement (commit d98bc12):

  • Replaced inefficient contrastIssues.push() loops with Array.flatMap() for better performance when testing many DOM elements
  • This eliminates repeated array mutations in favor of a functional approach

Enhanced Type Validation (commit d98bc12):

  • Added isValidTimeZone() helper function to validate TimeZone object structure
  • Enhanced isProcessedTimezoneData() type guard to validate that juneTimeZones and decemberTimeZones arrays contain valid TimeZone objects
  • This prevents runtime errors from corrupted cache data by validating required properties: name, offset, displayName, iana, cityName, and abbreviation

Both changes improve code quality while maintaining existing functionality.

Copilot AI changed the title Fix version display inconsistency between main and test sites Fix version display inconsistency and improve code performance/validation Aug 10, 2025
Copilot finished work on behalf of tsmarvin August 10, 2025 05:42
@tsmarvin tsmarvin changed the base branch from main to develop August 10, 2025 07:01
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.

Dev Deploy wipes out version

2 participants