CI/CD에 Lighthouse 통합
지속적 통합 및 배포 파이프라인에서 Lighthouse 검사를 자동화하여 성능 저하를 조기에 발견합니다.
CI/CD에 Lighthouse 통합은(는) CoddyKit의 무료 Web Performance Optimization & Lighthouse 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Web Performance Optimization & Lighthouse 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Web Performance Optimization & Lighthouse 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
What is CI/CD?
CI/CD stands for Continuous Integration and Continuous Delivery/Deployment. It's a modern approach to software development that focuses on automating various stages of the software lifecycle.
- Continuous Integration (CI): Developers frequently merge code into a central repository. Automated builds and tests run to detect issues early.
- Continuous Delivery (CD): After CI, code is automatically prepared for release, ensuring it's always in a deployable state.
- Continuous Deployment (CD): Takes CD a step further by automatically deploying every change to production, provided all tests pass.
CI/CD helps teams deliver updates faster and more reliably.
Why CI/CD for Performance?
Integrating performance checks into your CI/CD pipeline is crucial for maintaining a fast website. Here's why:
- Catch Regressions Early: Automatically detect performance drops with every code change, before they reach users.
- Consistent Feedback: Get objective performance scores on every build, ensuring teams stay aware of their impact.
- Enforce Standards: Use performance budgets to fail builds if metrics fall below acceptable thresholds.
- Save Time: Automate manual auditing, freeing up developer time.
Meet Lighthouse CI (LHCI)
While you can run Lighthouse manually, Lighthouse CI (LHCI) is a dedicated tool designed to make automated performance auditing in CI/CD pipelines easy and effective.
LHCI provides a set of tools to:
- Collect Lighthouse reports across different branches and commits.
- Assert performance budgets against these reports.
- Display historical performance data.
- Integrate with various CI providers like GitHub Actions, GitLab CI, and Jenkins.
LHCI: Collect & Assert
LHCI works through a command-line interface (CLI). You'll typically use two main commands:
lhci collect: Runs Lighthouse audits on specified URLs and collects the results.lhci assert: Checks the collected results against predefined performance budgets and rules.
First, you usually install it globally or as a dev dependency:
npm install -g @lhci/cliConfiguring LHCI
LHCI uses a configuration file, often named lighthouserc.js or lighthouserc.json, to define how it should run. This file lives at the root of your project.
Here's a basic structure for lighthouserc.js, specifying where to run audits:
module.exports = {
ci: {
collect: {
url: ['http://localhost:3000'],
startServerCommand: 'npm run start',
numberOfRuns: 3,
},
upload: {
target: 'temporary-public-storage',
},
},
};Enforcing Performance Budgets
A key feature of LHCI is enforcing performance budgets. These are thresholds for metrics (like score, total byte weight, or largest contentful paint) that your site must meet.
You define budgets in the assert section of your lighthouserc.js. If any budget is violated, LHCI can fail your CI build.
module.exports = {
ci: {
collect: { /* ... */ },
assert: {
assertions: {
'performance-score': ['error', { minScore: 0.90 }],
'first-contentful-paint': ['error', { maxNumericValue: 1500 }],
'total-byte-weight': ['warn', { maxNumericValue: 1000000 }], // 1MB
},
},
upload: { /* ... */ },
},
};LHCI with GitHub Actions
GitHub Actions is a popular CI/CD platform integrated directly into GitHub repositories. You can easily add LHCI to your GitHub Actions workflow.
You'll create a YAML file (e.g., .github/workflows/lighthouse.yml) that defines the steps to run LHCI when certain events occur, like a pull request or a push to the main branch.
This allows automated checks before merging code.
GitHub Actions Workflow Example
Here's a simplified GitHub Actions workflow that sets up Node.js, installs LHCI, starts a server (if needed), collects audits, and asserts against budgets.
This workflow runs on every pull request to the main branch.
name: Lighthouse CI
on: [pull_request]
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Run Lighthouse CI
run: npm install -g @lhci/cli && lhci collect && lhci assertReviewing CI/CD Results
After LHCI runs in your CI/CD pipeline, it provides output directly in the build log. If budgets are set, the build will pass or fail accordingly.
- Passed: All performance budgets and assertions were met.
- Failed: One or more budgets were exceeded, indicating a performance regression.
For more detailed historical data and trend analysis, you can configure LHCI to upload reports to an LHCI server (either self-hosted or a cloud service).
Quick Check
You've learned how Lighthouse CI helps automate performance checks. Which of the following are key benefits of integrating Lighthouse CI into your CI/CD pipeline?
Recap & Next Steps
Great job! In this lesson, we explored how to integrate Lighthouse into your CI/CD pipeline.
- We understood the importance of automating performance checks to prevent regressions.
- We learned about Lighthouse CI (LHCI) and its role in collecting audits and asserting budgets.
- We saw examples of configuring LHCI and integrating it with GitHub Actions.
By automating performance, you ensure your web projects remain fast and user-friendly over time. Keep exploring how to fine-tune your CI/CD setup for optimal results!
자주 묻는 질문
“CI/CD에 Lighthouse 통합” 강의는 무료인가요?
네 — “CI/CD에 Lighthouse 통합” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Web Performance Optimization & Lighthouse 강의 전체를 잠금 해제할 수 있습니다. Web Performance Optimization & Lighthouse 강의에는 총 4개의 강의가 포함되어 있습니다.
“CI/CD에 Lighthouse 통합”에서 뭘 배우나요?
지속적 통합 및 배포 파이프라인에서 Lighthouse 검사를 자동화하여 성능 저하를 조기에 발견합니다. 브라우저에서 직접 실행하는 실습 코드로 Web Performance Optimization & Lighthouse을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Web Performance Optimization & Lighthouse을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Web Performance Optimization & Lighthouse은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.
“CI/CD에 Lighthouse 통합” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Web Performance Optimization & Lighthouse 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Web Performance Optimization & Lighthouse 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- CLI 및 프로그래밍 방식 Lighthouse
- 맞춤 감사 및 단정
- CI/CD에 Lighthouse 통합
- Lighthouse를 활용한 성능 예산