Skip to content

Commit

Permalink
Add Artifact Hub badge check (#57)
Browse files Browse the repository at this point in the history
Closes #37

Signed-off-by: Sergio Castaño Arteaga <[email protected]>
Signed-off-by: Cintia Sanchez Garcia <[email protected]>
Co-authored-by: Sergio Castaño Arteaga <[email protected]>
Co-authored-by: Cintia Sanchez Garcia <[email protected]>
  • Loading branch information
tegioz and cynthia-sg authored Feb 15, 2022
1 parent 1321808 commit 5cb38f9
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions clomonitor-core/src/linter/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) static LICENSE: [&str; 2] = ["LICENSE*", "COPYING*"];
pub(crate) static FOSSA_BADGE: [&str; 1] = [r"https://app.fossa.*/api/projects/.*"];

// Best practices
pub(crate) static ARTIFACTHUB_BADGE: [&str; 1] = [r"https://artifacthub.io/badge/repository/.*"];
pub(crate) static COMMUNITY_MEETING: [&str; 3] = [
r"(?i)(community|developer|development) (call|event|meeting|session)",
r"(?i)(weekly|biweekly|monthly) meeting",
Expand Down
9 changes: 9 additions & 0 deletions clomonitor-core/src/linter/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct License {
/// BestPractices section of the report.
#[derive(Debug, Serialize, Deserialize)]
pub struct BestPractices {
pub artifacthub_badge: bool,
pub community_meeting: bool,
pub openssf_badge: bool,
}
Expand Down Expand Up @@ -135,6 +136,14 @@ fn lint_license(root: &Path) -> Result<License, Error> {
/// Run best practices checks and prepare the report's best practices section.
fn lint_best_practices(root: &Path) -> Result<BestPractices, Error> {
Ok(BestPractices {
artifacthub_badge: check::content_matches(
Globs {
root,
patterns: README,
case_sensitive: true,
},
ARTIFACTHUB_BADGE,
)?,
community_meeting: check::content_matches(
Globs {
root,
Expand Down
5 changes: 4 additions & 1 deletion clomonitor-core/src/score/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ pub(crate) fn calculate_score(report: &Report) -> Score {
}

// Best practices
if report.best_practices.artifacthub_badge {
score.best_practices += 5;
}
if report.best_practices.community_meeting {
score.best_practices += 25;
}
if report.best_practices.openssf_badge {
score.best_practices += 75;
score.best_practices += 70;
}

// Security
Expand Down
4 changes: 4 additions & 0 deletions clomonitor-linter/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ pub(crate) fn display_primary(report: &linter::primary::Report, score: &score::p
cell_entry("License / FOSSA badge"),
cell_check(report.license.fossa_badge),
])
.add_row(vec![
cell_entry("Best practices / Artifact Hub badge"),
cell_check(report.best_practices.artifacthub_badge),
])
.add_row(vec![
cell_entry("Best practices / Community meeting"),
cell_check(report.best_practices.community_meeting),
Expand Down
31 changes: 29 additions & 2 deletions web/src/data.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { BiLock, BiMedal, BiShieldQuarter, BiTrophy } from 'react-icons/bi';
import { CgFileDocument, CgReadme } from 'react-icons/cg';
import { FaBalanceScale, FaCheckDouble, FaTools } from 'react-icons/fa';
import { FiHexagon } from 'react-icons/fi';
import { GiFountainPen, GiStamper, GiTiedScroll } from 'react-icons/gi';
import { GoLaw } from 'react-icons/go';
import { HiOutlinePencilAlt, HiTerminal } from 'react-icons/hi';
import { ImOffice } from 'react-icons/im';
import { IoIosPeople, IoMdRibbon } from 'react-icons/io';
import { RiRoadMapLine } from 'react-icons/ri';

import ExternalLink from './layout/common/ExternalLink';
import RoundedBadge from './layout/common/RoundedBadge';
import {
Category,
Expand Down Expand Up @@ -103,7 +105,11 @@ export const REPORT_OPTIONS_BY_CATEGORY: ReportOptsByCategory = {
ReportOption.Roadmap,
],
[ScoreType.License]: [ReportOption.ApprovedLicense, ReportOption.SPDX, ReportOption.FossaBadge],
[ScoreType.BestPractices]: [ReportOption.OpenSSFBadge, ReportOption.CommunityMeeting],
[ScoreType.BestPractices]: [
ReportOption.OpenSSFBadge,
ReportOption.CommunityMeeting,
ReportOption.ArtifactHubBadge,
],
[ScoreType.Security]: [ReportOption.SecurityPolicy],
},
[RepositoryKind.Secondary]: {
Expand Down Expand Up @@ -333,7 +339,7 @@ export const REPORT_OPTIONS: ReportOptionInfo = {
</span>
),
weight: {
[RepositoryKind.Primary]: 75,
[RepositoryKind.Primary]: 70,
},
},
[ReportOption.SecurityPolicy]: {
Expand Down Expand Up @@ -373,4 +379,25 @@ export const REPORT_OPTIONS: ReportOptionInfo = {
[RepositoryKind.Primary]: 25,
},
},
[ReportOption.ArtifactHubBadge]: {
icon: <FiHexagon />,
name: 'Artifact Hub badge',
legend: (
<span>
Projects can list their content on{' '}
<ExternalLink className="d-inline-block fw-bold" href="https://artifacthub.io">
Artifact Hub
</ExternalLink>{' '}
to improve their discoverability.
</span>
),
description: (
<span>
We check that the <code>README</code> file contains an Artifact Hub badge
</span>
),
weight: {
[RepositoryKind.Primary]: 5,
},
},
};
1 change: 1 addition & 0 deletions web/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export enum ReportOption {
OpenSSFBadge = 'openssfBadge',
SecurityPolicy = 'securityPolicy',
CommunityMeeting = 'communityMeeting',
ArtifactHubBadge = 'artifacthubBadge',
}

export interface SearchFiltersURL extends BasicQuery {
Expand Down

0 comments on commit 5cb38f9

Please sign in to comment.