Skip to content

test external contribution #71

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
20 changes: 20 additions & 0 deletions .coderabbit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: "en-US"
early_access: false
reviews:
profile: "chill"
request_changes_workflow: false
high_level_summary: false
poem: false
review_status: false
collapse_walkthrough: true
abort_on_close: true
auto_review:
enabled: true
drafts: false
path_filters:
- "!*.po"
- "!*.md"
- "!*.rst"
chat:
auto_reply: false
10 changes: 4 additions & 6 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ tsconfig.json @centreon/owners-react
*.jsx @centreon/owners-react
**/cypress/** @centreon/owners-react

centreon-gorgone/ @centreon/owners-perl
centreon-gorgone/docs/ @centreon/owners-doc
centreon-gorgone/tests/ @centreon/owners-robot-e2e

centreon-gorgone/tests/robot/config/ @centreon/owners-perl
*.pm @centreon/owners-perl
*.pl @centreon/owners-perl

Expand All @@ -55,5 +50,8 @@ centreon-gorgone/tests/robot/config/ @centreon/owners-perl
**/project/ @centreon/owners-pipelines
**/packaging/ @centreon/owners-pipelines
dependencies/** @centreon/owners-pipelines
.coderabbit.yml @centreon/owners-pipelines

**/config/features.json @centreon/release-management

**/config/features.json @centreon/release-management
**/tests/rest_api/** @centreon/owners-api-testing
28 changes: 28 additions & 0 deletions .github/actions/check-latest-nightly-status/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "check-latest-nightly-status"
description: "Check the status of the latest nightly build"
outputs:
last_nightly_result:
description: "The status of the latest nightly build (success or failure)"
value: ${{ steps.check-latest-nightly-status.outputs.last_nightly_result }}

runs:
using: "composite"
steps:
- name: Check the status of the latest nightly build
id: check-latest-nightly-status
run: |
set -x

echo "[INFO]: Filtering the results of the last nightly build"
lastNightlyRunDetails=$(gh run ls \
--json number,status,conclusion \
--event schedule \
--workflow web.yml \
--branch develop \
--limit 1)

echo "Last nightly run details:"
echo "$lastNightlyRunDetails"

echo "last_nightly_result=$(echo "$lastNightlyRunDetails" | jq -r '.[0].conclusion')" >> $GITHUB_OUTPUT
shell: bash
2 changes: 1 addition & 1 deletion .github/actions/chromatic/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
using: "composite"

steps:
- uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # v2.4.0
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 8
run_install: false
Expand Down
10 changes: 10 additions & 0 deletions .github/actions/code-coverage-gate-keeper/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ inputs:
name:
description: 'The name for display purpose'
required: true
dynamicCodeCoveragesFilePath:
required: true
description: 'The path to the dynamic code coverages file'
generateNewCodeCoverages:
required: false
default: 'false'
description: 'Generates new code coverages bas stats or not'
outputs:
has_new_code_coverage:
description: 'This tells if a new code coverages file has been generated'

runs:
using: 'node20'
Expand Down
224 changes: 132 additions & 92 deletions .github/actions/code-coverage-gate-keeper/index.js
Original file line number Diff line number Diff line change
@@ -1,92 +1,132 @@
const core = require('@actions/core');
const { getOctokit, context } = require('@actions/github');
const fs = require('fs');
const { execSync } = require('child_process');

const limit = 20;

const getExistingComments = async ({ octokit, context, title }) => {
let page = 0;
let results = [];
let response;

do {
response = await octokit.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
per_page: limit,
page: page,
});
results = results.concat(response.data);
page = page + 1;
} while (response.data.length === limit)

return results.filter(
comment => !!comment.user && comment.body.includes(title),
)
}

const deleteOldComments = async ({ octokit, context, title }) => {
const existingComments = await getExistingComments({ octokit, context, title })

existingComments.forEach((existingComment) => {
core.debug(`Deleting comment: ${existingComment.id}`)
try {
octokit.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
})
} catch (error) {
console.error(error)
}
})
}

const run = async () => {
try {
const modulePath = core.getInput('module_path');
const githubToken = core.getInput('github_token');
const name = core.getInput('name');

if (context.payload.pull_request === null) {
return;
}

execSync('pnpx nyc report --reporter json-summary --report-dir /tmp');

const coverageFile = fs.readFileSync('/tmp/coverage-summary.json');
const coverage = JSON.parse(coverageFile);

const package = fs.readFileSync(`${modulePath}/package.json`);
const baseCodeCoveragePercentage =JSON.parse(package).baseCodeCoveragePercentage

const codeCoverageLines = coverage.total.lines.pct;

const passGateKeep = codeCoverageLines >= baseCodeCoveragePercentage;

const octokit = getOctokit(githubToken);

const title = `Code Coverage Check on ${name}`;

await deleteOldComments({ octokit, context, title })

core.info(`Pass the gate keep? ${passGateKeep} (INFO: lines: ${codeCoverageLines}, base percentage: ${baseCodeCoveragePercentage})`)

if (!passGateKeep) {
const pull_request_number = context.payload.pull_request.number;
octokit.rest.issues.createComment({
...context.repo,
issue_number: pull_request_number,
body: `<h2>📋 ${title} ❌</h2>
Your code coverage is <b>${codeCoverageLines}%</b> but the required code coverage is <b>${baseCodeCoveragePercentage}%</b>.`
});
core.setFailed(`Does not pass the code coverage check (${codeCoverageLines}% instead of ${baseCodeCoveragePercentage}%)`);
}
} catch (error) {
core.setFailed(error.message);
}
}

run();
const core = require('@actions/core');
const { getOctokit, context } = require('@actions/github');
const fs = require('fs');
const { execSync } = require('child_process');

const limit = 20;

const getExistingComments = async ({ octokit, context, title }) => {
let page = 0;
let results = [];
let response;

do {
response = await octokit.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
per_page: limit,
page: page
});
results = results.concat(response.data);
page = page + 1;
} while (response.data.length === limit);

return results.filter(
(comment) => !!comment.user && comment.body.includes(title)
);
};

const deleteOldComments = async ({ octokit, context, title }) => {
const existingComments = await getExistingComments({
octokit,
context,
title
});

existingComments.forEach((existingComment) => {
core.info(`Deleting comment: ${existingComment.id}`);
try {
octokit.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id
});
} catch (error) {
console.error(error);
}
});
};

const run = async () => {
try {
const modulePath = core.getInput('module_path');
const githubToken = core.getInput('github_token');
const name = core.getInput('name');
const dynamicCodeCoveragesFilePath = core.getInput(
'dynamicCodeCoveragesFilePath'
);
const generateNewCodeCoverages = core.getBooleanInput(
'generateNewCodeCoverages'
);

execSync('pnpx nyc report --reporter json-summary --report-dir /tmp');

const coverageFile = fs.readFileSync('/tmp/coverage-summary.json');
const coverage = JSON.parse(coverageFile);
const module = modulePath.replaceAll('/', '-');
const codeCoverageLines = coverage.total.lines.pct;
const codeCoverages = JSON.parse(
fs.readFileSync(dynamicCodeCoveragesFilePath)
);
const baseCodeCoveragePercentage = codeCoverages[module];
const lowerBaseCodeCoverage = baseCodeCoveragePercentage - 0.04;

const passGateKeep =
codeCoverageLines >= lowerBaseCodeCoverage ||
codeCoverageLines >= baseCodeCoveragePercentage;
const strictlyPassGateKeep =
codeCoverageLines >= baseCodeCoveragePercentage;

if (generateNewCodeCoverages) {
if (!strictlyPassGateKeep) {
core.info(
`Cannot update base percentage for ${module}. Requirement: ${baseCodeCoveragePercentage}%. Current: ${codeCoverageLines}%`
);
return;
}
const newCodeCoverages = {
...codeCoverages,
[module]: codeCoverageLines
};
fs.writeFileSync(
'/tmp/newBaseCodeCoverages.json',
JSON.stringify(newCodeCoverages)
);
core.info(`New code coverage for ${module}: ${codeCoverageLines}%`);
core.setOutput('has_new_code_coverage', 'true');
return;
}

const octokit = getOctokit(githubToken);

const title = `Code Coverage Check on ${name}`;

if (context.payload.pull_request) {
await deleteOldComments({ octokit, context, title });
}

core.info(
`Does it pass the gate keep? ${passGateKeep} (INFO: lines: ${codeCoverageLines}, base percentage: ${baseCodeCoveragePercentage})`
);

if (!passGateKeep) {
if (context.payload.pull_request) {
core.info(`Creating comment on pull request.`);
octokit.rest.issues.createComment({
...context.repo,
issue_number: context.payload.pull_request.number,
body: `<h2>📋 ${title} ❌</h2>
Your code coverage is <b>${codeCoverageLines}%</b> but the required code coverage is <b>${baseCodeCoveragePercentage}%</b>.`
});
}
core.setFailed(
`Does not pass the code coverage check (${codeCoverageLines}% instead of ${baseCodeCoveragePercentage}%)`
);
}
} catch (error) {
core.setFailed(error.message);
}
};

run();
24 changes: 22 additions & 2 deletions .github/actions/cypress-e2e-testing/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,33 @@ inputs:
feature_file_path:
description: "feature file"
required: true
test_tags:
description: "filter tests by tags"
required: false
default: "not @ignore"
dependencies_lock_file:
description: "The frontend dependencies lock file path"
required: true
test_execution_key:
description: "xray test execution key"
required: true
stability:
description: "Branch stability"
required: true
is_cloud:
description: "Define if the version is targeting cloud"
required: false
artifactory_internal_repo_username:
description: "Artifactory internal repository username"
required: false
artifactory_internal_repo_password:
description: "Artifactory internal repository password"
required: false

runs:
using: "composite"
steps:
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 8
run_install: false
Expand Down Expand Up @@ -67,7 +83,7 @@ runs:
- name: Cypress end-to-end testing
uses: cypress-io/github-action@1b70233146622b69e789ccdd4f9452adc638d25a # v6.6.1
with:
command: pnpm run cypress:run --browser electron --spec features/**/${{ inputs.feature_file_path }}
command: pnpm run cypress:run --browser electron --spec features/**/${{ inputs.feature_file_path }} --env tags="${{ inputs.test_tags }}"
install: false
working-directory: ${{ inputs.module }}/tests/e2e
publish-summary: false
Expand All @@ -78,6 +94,10 @@ runs:
CYPRESS_WEB_IMAGE_VERSION: ${{ inputs.web_image_version }}
CYPRESS_OPENID_IMAGE_VERSION: ${{ inputs.openid_image_version }}
CYPRESS_SAML_IMAGE_VERSION: ${{ inputs.saml_image_version }}
CYPRESS_STABILITY: ${{ inputs.stability }}
CYPRESS_IS_CLOUD: ${{ inputs.is_cloud }}
CYPRESS_INTERNAL_REPO_USERNAME: ${{ inputs.artifactory_internal_repo_username }}
CYPRESS_INTERNAL_REPO_PASSWORD: ${{ inputs.artifactory_internal_repo_password }}

- name: Ensure logs directory exists
run: mkdir -p ${{ inputs.module }}/tests/e2e/results/cucumber-logs/
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/frontend-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 8
run_install: false
Expand Down
Loading