Keepfast is a performance analysis tool recommended in this issue, which can analyze the resource construction performance and page performance of the website, generate performance reports and provide optimization suggestions, so as to make performance monitoring more convenient.
KeepFast Introduction
Main features:
- Analyze and generate build performance reports, which can visually compare the build performance of two versions, so as to identify build performance problems as early as possible
- Conduct performance test on the website based on Lighthouse, and give performance indicators and relevant suggestions
- Preset Gitee API support to generate a performance report for new commits in the Gitee repository, tracking performance metrics and scores at any time
Installation
npm install -g lighthouse @gitee/keepfast
Use
Create a configuration file for your project first:
# Go to your project directory
cd /path/to/your/repo
# Initial configuration file
keepfast init
Then modify the keepfast.config.js configuration file to complete the repository field information, if your project is created and managed by the Vue CLI, leave the rest of the configuration as is.
Generate report
Run the performance test and output the report to the./report.json file:
keepfast report ./report.json
Upload report
Uploading a report calls the Gitee API. In order for keepfast to have permission to manipulate your repository, you need to provide a private token, which is available in Settings > After the private token is generated in the page, run the following command to add the environment variable:
export GITEE_API_ACCESS_TOKEN= Your private token
Then run the following command to upload the report:
keepfast upload ./report.json
The report is uploaded to the comment on the Pull Request if the current branch already has the corresponding Pull Request, otherwise to the comment on the current Commit details page.
Using
in Gitee Go
Gitee Go is a CI/CD(Continuous Build and Integration) service launched by Gitee. Users can automate the build integration by customizing the build process.
Create a new pipeline file on the master branch of your warehouse with the following configuration:
name: keepfast
displayName: keepfast
triggers:
push:
branches:
- master
- develop
steps:
- step: npmbuild@1
name: npm-build
displayName: npm-build
inputs:
nodeVersion: 12.7
goals: >-
yum clean all
yum install -y epel-release
yum -y update
yum install -y chromium
npm config set registry https://registry.npm.taobao.org
export GITEE_API_ACCESS_TOKEN=$KEEPFAST_API_TOKEN
export SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/
npm install
npm install -g lighthouse @gitee/keepfast
keepfast report ./report.json
keepfast upload ./report.json
Then set the value of the KEEPFAST_API_TOKEN environment variable to your access token in the repository’s environment variable management page.