Dự án này triển khai mẫu GitLab CI/CD để xây dựng, kiểm tra và phân tích JavaScript/TypeScript/Node của bạn. dự án js
Chính xác hơn, nó có thể được sử dụng bởi tất cả các dự án dựa trên npm hoặc trình quản lý gói sợi
Cách sử dụng
Để đưa mẫu này vào dự án của bạn, hãy thêm phần sau vào
reporters: [
"default",
// 'jest-junit' to enable GitLab unit test report integration
[
"jest-junit",
{
outputDirectory: "reports",
outputName: "node-test.xunit.xml",
},
],
// [OPTIONAL] only if using SonarQube
// 'jest-sonar' to enable SonarQube unit test report integration
[
"jest-sonar",
{
outputDirectory: "reports",
outputName: "node-test.sonar.xml",
},
],
],
coverageDirectory: "reports",
coverageReporters: [
// 'text' to let GitLab grab coverage from stdout
"text",
// 'cobertura' to enable GitLab test coverage visualization
"cobertura",
// [OPTIONAL] only if using SonarQube
// 'lcovonly' to enable SonarQube test coverage reporting
"lcovonly",
],
2 của bạninclude:
- project: 'to-be-continuous/node'
ref: '3.5.2'
file: '/templates/gitlab-ci-node.yml'
Cấu hình Toàn cầu
nút. js sử dụng một số cấu hình chung được sử dụng trong tất cả các công việc
Tênmô tảgiá trị mặc định reporters: [
"default",
// 'jest-junit' to enable GitLab unit test report integration
[
"jest-junit",
{
outputDirectory: "reports",
outputName: "node-test.xunit.xml",
},
],
// [OPTIONAL] only if using SonarQube
// 'jest-sonar' to enable SonarQube unit test report integration
[
"jest-sonar",
{
outputDirectory: "reports",
outputName: "node-test.sonar.xml",
},
],
],
coverageDirectory: "reports",
coverageReporters: [
// 'text' to let GitLab grab coverage from stdout
"text",
// 'cobertura' to enable GitLab test coverage visualization
"cobertura",
// [OPTIONAL] only if using SonarQube
// 'lcovonly' to enable SonarQube test coverage reporting
"lcovonly",
],
3Hình ảnh Docker được sử dụng để chạy Node. jsđặt phiên bản mà dự án của bạn yêu cầu_______0_______4
reporters: [
"default",
// 'jest-junit' to enable GitLab unit test report integration
[
"jest-junit",
{
outputDirectory: "reports",
outputName: "node-test.xunit.xml",
},
],
// [OPTIONAL] only if using SonarQube
// 'jest-sonar' to enable SonarQube unit test report integration
[
"jest-sonar",
{
outputDirectory: "reports",
outputName: "node-test.sonar.xml",
},
],
],
coverageDirectory: "reports",
coverageReporters: [
// 'text' to let GitLab grab coverage from stdout
"text",
// 'cobertura' to enable GitLab test coverage visualization
"cobertura",
// [OPTIONAL] only if using SonarQube
// 'lcovonly' to enable SonarQube test coverage reporting
"lcovonly",
],
5Trình quản lý gói được dự án của bạn sử dụng [npm hoặc yarn]Nếu không xác định, tự động phát hiệnnone
reporters: [
"default",
// 'jest-junit' to enable GitLab unit test report integration
[
"jest-junit",
{
outputDirectory: "reports",
outputName: "node-test.xunit.xml",
},
],
// [OPTIONAL] only if using SonarQube
// 'jest-sonar' to enable SonarQube unit test report integration
[
"jest-sonar",
{
outputDirectory: "reports",
outputName: "node-test.sonar.xml",
},
],
],
coverageDirectory: "reports",
coverageReporters: [
// 'text' to let GitLab grab coverage from stdout
"text",
// 'cobertura' to enable GitLab test coverage visualization
"cobertura",
// [OPTIONAL] only if using SonarQube
// 'lcovonly' to enable SonarQube test coverage reporting
"lcovonly",
],
6npm registrynone reporters: [
"default",
// 'jest-junit' to enable GitLab unit test report integration
[
"jest-junit",
{
outputDirectory: "reports",
outputName: "node-test.xunit.xml",
},
],
// [OPTIONAL] only if using SonarQube
// 'jest-sonar' to enable SonarQube unit test report integration
[
"jest-sonar",
{
outputDirectory: "reports",
outputName: "node-test.sonar.xml",
},
],
],
coverageDirectory: "reports",
coverageReporters: [
// 'text' to let GitLab grab coverage from stdout
"text",
// 'cobertura' to enable GitLab test coverage visualization
"cobertura",
// [OPTIONAL] only if using SonarQube
// 'lcovonly' to enable SonarQube test coverage reporting
"lcovonly",
],
7Thư mục gốc của dự án nút reporters: [
"default",
// 'jest-junit' to enable GitLab unit test report integration
[
"jest-junit",
{
outputDirectory: "reports",
outputName: "node-test.xunit.xml",
},
],
// [OPTIONAL] only if using SonarQube
// 'jest-sonar' to enable SonarQube unit test report integration
[
"jest-sonar",
{
outputDirectory: "reports",
outputName: "node-test.sonar.xml",
},
],
],
coverageDirectory: "reports",
coverageReporters: [
// 'text' to let GitLab grab coverage from stdout
"text",
// 'cobertura' to enable GitLab test coverage visualization
"cobertura",
// [OPTIONAL] only if using SonarQube
// 'lcovonly' to enable SonarQube test coverage reporting
"lcovonly",
],
8 reporters: [
"default",
// 'jest-junit' to enable GitLab unit test report integration
[
"jest-junit",
{
outputDirectory: "reports",
outputName: "node-test.xunit.xml",
},
],
// [OPTIONAL] only if using SonarQube
// 'jest-sonar' to enable SonarQube unit test report integration
[
"jest-sonar",
{
outputDirectory: "reports",
outputName: "node-test.sonar.xml",
},
],
],
coverageDirectory: "reports",
coverageReporters: [
// 'text' to let GitLab grab coverage from stdout
"text",
// 'cobertura' to enable GitLab test coverage visualization
"cobertura",
// [OPTIONAL] only if using SonarQube
// 'lcovonly' to enable SonarQube test coverage reporting
"lcovonly",
],
9Thư mục nguồnnpm install --save-dev nyc
0npm install --save-dev nyc
1Các tùy chọn bổ sung để cài đặt các phần phụ thuộc của dự án [hoặc là npm install --save-dev nyc
2 hoặc npm install --save-dev nyc
3]không cócông việc
npm install --save-dev nyc
4 công việc
npm install --save-dev nyc
Mẫu Node có công việc
{
"reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "reports/node-test.xunit.xml"
},
"mochaSonarqubeReporterReporterOptions": {
"output": "reports/node-test.sonar.xml"
}
}
1 thực hiện phân tích lỗi thời [npm lỗi thời hoặc sợi lỗi thời] để tìm các phụ thuộc có thể được cập nhật