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

336-feat: configure workflow for lighthouse to run on deployments #351

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

Wystov
Copy link
Collaborator

@Wystov Wystov commented Jun 28, 2024

What type of PR is this? (select all that apply)

  • 🍕 Feature

Description

  • Integrate Lighthouse tests into the current CI/CD pipeline using GitHub Actions.
  • Configure tests to run on PR deployment.
  • Save Lighthouse reports as CI/CD build artifacts.
  • Set up notifications for test results in PR comments.

As github docs says, repository_dispatch works only for files in main branch, so seems like i can't trigger it without merging pr.

image

Related Tickets & Documents

Screenshots, Recordings

image
image

Added/updated tests?

  • 🙅‍♂️ No, because they aren't needed

[optional] What gif best describes this PR or how it makes you feel?

cat-cats

Summary by CodeRabbit

  • Chores
    • Introduced a workflow for running Lighthouse tests to ensure better performance and accessibility in future releases.

@Wystov Wystov added the preview label Jun 28, 2024
@Wystov Wystov self-assigned this Jun 28, 2024
@Wystov Wystov requested review from apalchys and SpaNb4 as code owners June 28, 2024 08:51
Copy link
Contributor

coderabbitai bot commented Jun 28, 2024

Walkthrough

The changes introduce automated Lighthouse testing in the CI/CD pipeline for PR deployments. This is achieved through the addition of a GitHub Actions workflow (lighthouse.yml) and a Lighthouse configuration file (lighthouserc.json). The workflow sets up Node, installs dependencies, runs Lighthouse tests on a specified URL, generates a report, and posts results to pull requests. This automation aims to continuously monitor key performance and quality metrics.

Changes

Files Change Summary
.github/workflows/lighthouse.yml Introduced a workflow for running Lighthouse tests on a specified URL during a repository dispatch event.
lighthouserc.json Introduced configuration settings for CI, specifying parameters for collecting data and uploading to temporary public storage.

Assessment against linked issues

Objective Addressed Explanation
Automate Testing (#336)
Monitor and Improve Quality (#336)
CI/CD Configuration (#336)
Result Collection and Display (#336)

Poem

The rabbits code, they hop and sprint,
To automate and leave no hint.
With Lighthouse tests, they check with care,
Ensuring quality, performance rare.
In pull requests, results will show,
In metrics true, our progress glow.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

github-actions bot commented Jun 28, 2024

Qodana for JS

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

Copy link
Contributor

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3051056 and 07dc33d.

Files selected for processing (2)
  • .github/workflows/lighthouse.yml (1 hunks)
  • lighthouserc.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • lighthouserc.json
Additional comments not posted (5)
.github/workflows/lighthouse.yml (5)

3-6: Workflow Trigger Configuration Approved

The configuration to trigger the workflow on a repository_dispatch event with type preview-created aligns well with the objectives to run tests on PR deployments.


10-20: Approve Node Setup and Dependency Installation

Using Node.js version 20 and installing Lighthouse CLI are appropriate for running the tests. Consider pinning the exact version of Node.js and Lighthouse CLI for more stable and predictable builds.


22-24: Dynamic URL Construction for Lighthouse Tests Approved

Constructing the URL dynamically to target the specific PR deployment is a smart approach and aligns perfectly with the PR objectives.


48-59: Posting Lighthouse Results to PR Approved

Automating the posting of Lighthouse test results directly in the PR comments enhances visibility and aligns with the objectives. This is a good use of GitHub Actions to automate communication.


25-47: Artifact Upload and Report Generation Steps Approved

Uploading Lighthouse artifacts and generating a detailed report summary are well-implemented. Verify the paths and JSON structure used in the jq commands to ensure they are correct and will not lead to runtime errors.

@dzmitry-varabei dzmitry-varabei removed the request for review from apalchys June 28, 2024 09:28
Copy link
Contributor

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 07dc33d and ac26d1c.

Files selected for processing (1)
  • .github/workflows/lighthouse.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/lighthouse.yml

@Wystov Wystov merged commit c4b753d into main Jun 28, 2024
6 checks passed
@Wystov Wystov deleted the feat/336-lighthouse-testing-for-pr-deployments branch June 28, 2024 12:05
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use the NODE_VERSION env variable as in other workflows

node-version: '20.x'

- name: Install dependencies
run: npm install && npm install -g @lhci/[email protected]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd use bahmutov/npm-install@v1 github action

run: npm install && npm install -g @lhci/[email protected]

- name: Run Lighthouse
run: lhci autorun --collect.url=https://pr${{ github.event.client_payload.number }}.rs.school
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can I use npx lhci here and remove npm install -g @lhci/[email protected] from the previos step?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried and there is no benefits, workflow execution time becomes even longer. Same with npm-install action.
And the method used here is recommended from lighthouse docs.

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.

Implement Automated Lighthouse Testing for PR Deployments
5 participants