Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bio component #5

Merged
merged 5 commits into from
Nov 8, 2024
Merged

Add bio component #5

merged 5 commits into from
Nov 8, 2024

Conversation

5ouma
Copy link
Owner

@5ouma 5ouma commented Nov 8, 2024

⚠️ Issue

close #


✏️ Description

Show the user's icon, name, and description.
Also added a global CSS.


🔄 Type of the Change

  • 🎉 New Feature
  • 🧰 Bug
  • 🛡️ Security
  • 📖 Documentation
  • 🏎️ Performance
  • 🧹 Refactoring
  • 🧪 Testing
  • 🔧 Maintenance
  • 🎽 CI
  • 🧠 Meta

Import some fonts and declare variables.
@prlabeler prlabeler bot added the 🎉 New Feature Introduce a new feature label Nov 8, 2024
bun.lockb Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 8, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link

coderabbitai bot commented Nov 8, 2024

Walkthrough

This pull request introduces multiple changes, including the addition of a new CI job for testing in the workflow, updates to the .gitignore file, and enhancements to the Astro configuration to conditionally integrate the astrobook package. It also adds a new Bio component along with its associated tests and stories, updates the package.json for new scripts and dependencies, and introduces global font styles and CSS for the new component.

Changes

File Change Summary
.github/workflows/ci.yml Added a new job named test to run tests with coverage reporting.
.gitignore Updated to ignore coverage/ and junit.xml.
astro.config.ts Integrated astrobook conditionally based on the ASTROBOOK environment variable.
package.json Added scripts for astrobook, test, and test:cov, and new dependencies for testing.
src/components/Bio/Bio.astro Introduced a new component with props for name, description, and icon, rendering a structured bio.
src/components/Bio/Bio.stories.ts Created a story file for the Bio component with variations: Default, Japanese, and Long.
src/components/Bio/Bio.test.ts Added unit tests for the Bio component using the Vitest framework.
src/components/Bio/story.ts Introduced story variations for the Bio component with different props.
src/components/Bio/style.css Added CSS styles for the Bio component layout and typography.
src/styles/global.css Added font-face declarations for "LINE Seed JP" and defined CSS custom properties for themes.
vitest.config.ts Introduced configuration for Vitest, specifying reporters and output settings for tests.

Possibly related PRs

  • Initialize the Astro project #1: This PR introduces a new job in the CI workflow for testing, which is related to another PR that initializes the Astro project and sets up the CI configuration.

Suggested labels

🧠 Meta


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2690508 and afd6440.

📒 Files selected for processing (1)
  • src/components/Bio/Bio.astro (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Bio/Bio.astro

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (8)
src/components/Bio/Bio.stories.ts (1)

4-7: Consider using a hierarchical title structure.

While the current title works, consider using a hierarchical structure like "Components/Bio" or "UI/Bio" to better organize stories as the component library grows.

 export default {
-  title: "Bio",
+  title: "Components/Bio",
   component: Bio,
 };
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 4-7: src/components/Bio/Bio.stories.ts#L4-L7
Added lines #L4 - L7 were not covered by tests

astro.config.ts (1)

1-3: LGTM! Consider documenting the astrobook integration.

The imports are well-structured and maintain type safety. Since astrobook is a development tool, it would be helpful to document its purpose in the README.

Would you like me to help draft documentation explaining the purpose and usage of astrobook in this project?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 3-3: astro.config.ts#L3
Added line #L3 was not covered by tests

src/components/Bio/Bio.astro (1)

5-10: Add type safety to props extraction.

While the Props type is well-defined, consider adding type safety to the props extraction.

-const props = Astro.props;
+const props = Astro.props as Props;
src/components/Bio/Bio.test.ts (2)

5-5: Consider removing the file extension from the story import.

-import * as stories from "./story.ts";
+import * as stories from "./story";

7-8: Enhance test case identification for better debugging.

While generating tests from stories is efficient, consider adding more descriptive test names that include the tested props for easier debugging.

-    test(name, async () => {
+    test(`${name} - name: ${props.name}, has description: ${Boolean(props.description)}`, async () => {
src/components/Bio/story.ts (1)

3-7: Consider using a more representative test image URL.

While the current implementation works, using withastro's GitHub avatar might not be the best practice for test data.

Consider using a stable, project-specific test image URL or a local test asset:

-  icon: "https://github.com/withastro.png",
+  icon: "/test-assets/avatar-placeholder.png",
.github/workflows/ci.yml (2)

59-72: Enhance test and coverage reporting robustness.

While the implementation is good, consider these improvements:

  1. Add timeout to prevent long-running tests
  2. Add verification for test results file existence
  3. Add error handling for invalid token scenarios

Apply this diff to enhance robustness:

       - name: 🧪 Run Tests
+        timeout-minutes: 10
         run: bun run test:cov

       - name: ☂️ Upload Coverage
         uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
         with:
           token: ${{ secrets.CODECOV_TOKEN }}
+          fail_ci_if_error: true

+      - name: Check Test Results
+        id: check_results
+        run: |
+          if [ ! -f junit.xml ]; then
+            echo "::error::Test results file (junit.xml) not found"
+            exit 1
+          fi

       - name: ☂️ Upload Test Results
-        if: ${{ !cancelled() }}
+        if: ${{ !cancelled() && steps.check_results.outcome == 'success' }}
         uses: codecov/test-results-action@9739113ad922ea0a9abb4b2c0f8bf6a4aa8ef820 # v1.0.1
         with:
           token: ${{ secrets.CODECOV_TOKEN }}
+          fail_ci_if_error: true

Line range hint 6-14: Update path filters to include test files.

The current path filters might miss changes to test files. Consider adding test file patterns to ensure the test job runs appropriately.

Add these patterns to both push and pull_request paths:

     paths:
       - "**.astro"
       - "**.ts"
+      - "**/*.test.ts"
+      - "**/*.spec.ts"
       - bun.lockb
       - .github/workflows/ci.yml
🛑 Comments failed to post (2)
src/components/Bio/Bio.astro (1)

13-19: 🛠️ Refactor suggestion

Improve accessibility and prevent layout shifts.

The component structure could be enhanced for better accessibility and performance:

 <div id="bio">
   <div id="profile">
-    <img src={props.icon} alt="icon" loading="lazy" decoding="async" />
-    <span id="name">{props.name}</span>
+    <img 
+      src={props.icon} 
+      alt={`Profile picture of ${props.name}`}
+      loading="lazy" 
+      decoding="async"
+      width="64"
+      height="64"
+    />
+    <h1 id="name">{props.name}</h1>
   </div>
-  <span id="description">{props.description}</span>
+  <p id="description">{props.description}</p>
 </div>

Changes suggested:

  1. More descriptive alt text for better screen reader support
  2. Added width/height attributes to prevent Cumulative Layout Shift (CLS)
  3. Used semantic HTML elements (h1 for name, p for description)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

<div id="bio">
  <div id="profile">
    <img 
      src={props.icon} 
      alt={`Profile picture of ${props.name}`}
      loading="lazy" 
      decoding="async"
      width="64"
      height="64"
    />
    <h1 id="name">{props.name}</h1>
  </div>
  <p id="description">{props.description}</p>
</div>
src/components/Bio/Bio.test.ts (1)

9-16: 🛠️ Refactor suggestion

Consider adding more comprehensive test coverage.

The current tests verify the presence of content, but consider adding:

  1. Error case tests (missing required props)
  2. Accessibility checks (ARIA attributes, semantic HTML)
  3. HTML structure validation

Here's an example of additional test cases:

test(`${name} - validates required props`, async () => {
  const container = await AstroContainer.create();
  const invalidProps = { ...props, name: undefined };
  
  await expect(container.renderToString(Bio, { props: invalidProps }))
    .rejects.toThrow();
});

test(`${name} - validates accessibility`, async () => {
  const container = await AstroContainer.create();
  const result = await container.renderToString(Bio, { props });
  
  expect(result).toContain('role="article"');
  expect(result).toContain('alt=');
});

5ouma added 3 commits November 8, 2024 18:30
Show its icon, name and description.
Preview component per-component design.
Check whether the component is rendered as expected.
@5ouma 5ouma force-pushed the feat-component-bio branch from 10dcad1 to 2690508 Compare November 8, 2024 09:33
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
src/components/Bio/Bio.stories.ts (2)

4-7: Enhance story configuration with metadata

Consider adding more metadata to improve documentation and developer experience:

 export default {
   title: "Bio",
   component: Bio,
+  parameters: {
+    docs: {
+      description: {
+        component: 'Bio component displays user\'s icon, name, and description'
+      }
+    }
+  },
+  tags: ['autodocs'],
+  argTypes: {
+    name: { control: 'text' },
+    description: { control: 'text' },
+    icon: { control: 'text' }
+  }
 };
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 4-7: src/components/Bio/Bio.stories.ts#L4-L7
Added lines #L4 - L7 were not covered by tests


9-11: Document story variations

Consider adding descriptions for each story variation to clarify their purpose:

-export const Default = { args: stories.Default };
-export const Japanese = { args: stories.Japanese };
-export const Long = { args: stories.Long };
+export const Default = {
+  args: stories.Default,
+  parameters: {
+    docs: {
+      description: {
+        story: 'Default bio with standard English content'
+      }
+    }
+  }
+};
+
+export const Japanese = {
+  args: stories.Japanese,
+  parameters: {
+    docs: {
+      description: {
+        story: 'Bio with Japanese content to verify multi-language support'
+      }
+    }
+  }
+};
+
+export const Long = {
+  args: stories.Long,
+  parameters: {
+    docs: {
+      description: {
+        story: 'Bio with extended description to test layout with longer content'
+      }
+    }
+  }
+};
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 9-11: src/components/Bio/Bio.stories.ts#L9-L11
Added lines #L9 - L11 were not covered by tests

astro.config.ts (1)

1-11: Document the ASTROBOOK environment variable usage.

Consider adding a comment or updating the README to document:

  • Purpose of the ASTROBOOK environment variable
  • When and how to use it (e.g., during development)
  • Its relationship with component development workflow
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 3-3: astro.config.ts#L3
Added line #L3 was not covered by tests


[warning] 5-5: astro.config.ts#L5
Added line #L5 was not covered by tests


[warning] 7-9: astro.config.ts#L7-L9
Added lines #L7 - L9 were not covered by tests


[warning] 11-11: astro.config.ts#L11
Added line #L11 was not covered by tests

.github/workflows/ci.yml (1)

67-71: Consider adding test result annotations.

The test results upload is properly configured, but consider enabling GitHub annotations for better visibility of test failures directly in PR discussions.

       uses: codecov/test-results-action@9739113ad922ea0a9abb4b2c0f8bf6a4aa8ef820 # v1.0.1
       with:
         token: ${{ secrets.CODECOV_TOKEN }}
+        create_annotations: true
🛑 Comments failed to post (1)
.github/workflows/ci.yml (1)

59-71: 💡 Codebase verification

Add Codecov configuration file to define coverage settings

The Codecov integration is partially set up with GitHub Actions, but lacks configuration:

  • No codecov.yml file exists to define coverage thresholds and settings
  • Test coverage is being generated via vitest run --coverage
  • Test results are properly configured with JUnit reporter

Action items:

  • Create a codecov.yml file in the root directory to:
    • Set coverage thresholds
    • Configure coverage reporting rules
    • Define any project-specific settings
🔗 Analysis chain

Verify Codecov integration setup.

The coverage reporting setup looks good, but let's ensure all prerequisites are in place:

  1. Codecov token is properly set in repository secrets
  2. Codecov integration is enabled for the repository
  3. Coverage thresholds are configured (if required)

Let me verify the test configuration to get a complete picture before making the final response.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Codecov configuration exists and coverage settings are defined

# Check for codecov.yml configuration
echo "Checking for Codecov configuration..."
if [ -f "codecov.yml" ] || [ -f ".codecov.yml" ]; then
    echo "Found Codecov configuration"
    cat codecov.yml .codecov.yml 2>/dev/null
else
    echo "Warning: No Codecov configuration found. Consider adding codecov.yml to configure coverage thresholds and other settings."
fi

# Check for coverage configuration in package.json
echo -e "\nChecking for coverage configuration in package.json..."
if [ -f "package.json" ]; then
    jq '.vitest?.coverage' package.json
fi

Length of output: 582


Script:

#!/bin/bash
# Check test configuration in package.json and any coverage settings
echo "Checking test configuration in package.json..."
jq '.scripts | with_entries(select(.key | contains("test")))' package.json

echo -e "\nChecking vitest configuration..."
fd "vitest.config" --exec cat {}

Length of output: 594

Alt text should express more information.
@5ouma 5ouma merged commit 1b2f93e into main Nov 8, 2024
11 checks passed
@5ouma 5ouma deleted the feat-component-bio branch November 8, 2024 09:57
@github-actions github-actions bot mentioned this pull request Nov 7, 2024
@github-actions github-actions bot mentioned this pull request Nov 9, 2024
5ouma pushed a commit that referenced this pull request Nov 9, 2024
<!-- Release notes generated using configuration in .github/release.yml at main -->

* Add bio component by @5ouma in #5
* Add homepage component by @5ouma in #7
* Add contact component by @5ouma in #9
* Add index page and default layout template by @5ouma in #13
* Astro requires in-file CSS for scoping by @5ouma in #6
* Add README and license by @5ouma in #11
* Exclude Astro and Astrobook related by @5ouma in #8
* Add more test cases for anomalous conditions by @5ouma in #10
* Allow commenting on commits by @5ouma in #3
* Deploy and analyze performance by @5ouma in #12
* Quote meta file variable by @5ouma in #14
* Change the environment variable for repository name by @5ouma in #15
* Don't treat the input as JSON by @5ouma in #16
* chore(deps): pin koki-develop/bun-diff-action action to 22bcd25 by @renovate in #4

* @5ouma made their first contribution in #1
* @renovate made their first contribution in #4
* @github-actions made their first contribution in #2

**Full Changelog**: https://github.com/5ouma/mobicard/commits/v0.1.0
github-actions bot added a commit that referenced this pull request Nov 9, 2024
<!-- Release notes generated using configuration in .github/release.yml at main -->

* Add bio component by @5ouma in #5
* Add homepage component by @5ouma in #7
* Add contact component by @5ouma in #9
* Add index page and default layout template by @5ouma in #13
* Astro requires in-file CSS for scoping by @5ouma in #6
* Add README and license by @5ouma in #11
* Exclude Astro and Astrobook related by @5ouma in #8
* Add more test cases for anomalous conditions by @5ouma in #10
* Allow commenting on commits by @5ouma in #3
* Deploy and analyze performance by @5ouma in #12
* Quote meta file variable by @5ouma in #14
* Change the environment variable for repository name by @5ouma in #15
* Don't treat the input as JSON by @5ouma in #16
* chore(deps): pin koki-develop/bun-diff-action action to 22bcd25 by @renovate in #4

* @5ouma made their first contribution in #1
* @renovate made their first contribution in #4
* @github-actions made their first contribution in #2

**Full Changelog**: https://github.com/5ouma/mobicard/commits/v0.1.0
github-actions bot added a commit that referenced this pull request Nov 9, 2024
<!-- Release notes generated using configuration in .github/release.yml at main -->

* Add bio component by @5ouma in #5
* Add homepage component by @5ouma in #7
* Add contact component by @5ouma in #9
* Add index page and default layout template by @5ouma in #13
* Astro requires in-file CSS for scoping by @5ouma in #6
* Add README and license by @5ouma in #11
* Exclude Astro and Astrobook related by @5ouma in #8
* Add more test cases for anomalous conditions by @5ouma in #10
* Allow commenting on commits by @5ouma in #3
* Deploy and analyze performance by @5ouma in #12
* Quote meta file variable by @5ouma in #14
* Change the environment variable for repository name by @5ouma in #15
* Don't treat the input as JSON by @5ouma in #16
* chore(deps): pin koki-develop/bun-diff-action action to 22bcd25 by @renovate in #4

* @5ouma made their first contribution in #1
* @renovate made their first contribution in #4
* @github-actions made their first contribution in #2

**Full Changelog**: https://github.com/5ouma/mobicard/commits/v0.1.0
@coderabbitai coderabbitai bot mentioned this pull request Nov 22, 2024
11 tasks
@coderabbitai coderabbitai bot mentioned this pull request Nov 22, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 New Feature Introduce a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant