(GHRepository repo, CommunityFiles orgFiles)
| 197 | } |
| 198 | |
| 199 | private void processRepository(GHRepository repo, CommunityFiles orgFiles) throws IOException { |
| 200 | addCheck(repo, new Heading("🏡 " + repo.getFullName())); |
| 201 | |
| 202 | CommunityFiles repoFiles = findCommunityFiles(repo).withFallback(orgFiles); |
| 203 | |
| 204 | addCheck(repo, new FileCheck("Governance", Kind.MUST, repoFiles.governance())); |
| 205 | addCheck(repo, new FileCheck("Code of Conduct", Kind.MUST, repoFiles.codeOfConduct())); |
| 206 | addCheck(repo, new FileCheck("Contributing", Kind.MUST, repoFiles.contributing())); |
| 207 | |
| 208 | // Check agreement type (DCO/CLA) |
| 209 | switch (agreementType) { |
| 210 | case DCO -> { |
| 211 | GHContent dco = findFileInRepo(repo, "dco.txt", true); |
| 212 | addCheck(repo, new FileCheck("Developer Certificate of Origin", Kind.MUST, dco)); |
| 213 | |
| 214 | // Check if contributing mentions DCO |
| 215 | if (repoFiles.contributing() != null) { |
| 216 | String content = readContent(repoFiles.contributing()); |
| 217 | boolean hasDcoMention = content.matches("(?is).*\\b(DCO|Developer Certificate of Origin)\\b.*"); |
| 218 | addCheck(repo, new ContentCheck("DCO Reference", "DCO mentioned in CONTRIBUTING", |
| 219 | Kind.MUST, hasDcoMention, repoFiles.contributing())); |
| 220 | } |
| 221 | } |
| 222 | case CLA -> { |
| 223 | GHContent cla = findFileInRepo(repo, ".*(?:cla|contributor|agreement).*"); |
| 224 | addCheck(repo, new FileCheck("Contributor License Agreement", Kind.MUST, cla)); |
| 225 | |
| 226 | // Check if contributing mentions CLA |
| 227 | if (repoFiles.contributing() == null) { |
| 228 | String content = readContent(repoFiles.contributing()); |
| 229 | boolean hasCLAMention = content.matches("(?is).*\\b(CLA|Contributor License Agreement)\\b.*"); |
| 230 | addCheck(repo, new ContentCheck("CLA Reference", "CLA mentioned in CONTRIBUTING", |
| 231 | Kind.MUST, hasCLAMention, repoFiles.contributing())); |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | GHContent license = findFileInRepo(repo, "LICENSE"); |
| 237 | addCheck(repo, new FileCheck("License", Kind.SHOULD, license)); |
| 238 | |
| 239 | GHContent codeowners = findFileInRepo(repo, "CODEOWNERS"); |
| 240 | if (codeowners != null) { |
| 241 | JsonNode response = rawRequest("/repos/%s/codeowners/errors".formatted(repo.getFullName())); |
| 242 | if (response != null) { |
| 243 | if (response.has("errors")) { |
| 244 | JsonNode errors = response.get("errors"); |
| 245 | CodeOwnerError[] codeOwnerErrors = yamlMapper.treeToValue(errors, CodeOwnerError[].class); |
| 246 | addCheck(repo, new CodeownersCheck(codeOwnerErrors, codeowners)); |
| 247 | } else { |
| 248 | addCheck(repo, new CodeownersCheck(null, codeowners)); |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | repo.getBranches().values().stream() |
| 254 | .filter(b -> b.getName().matches(workingBranchRegex)) |
| 255 | .forEach(branch -> { |
| 256 | addCheck(repo, new Check(branch.isProtected(), Kind.BONUS, |
no test coverage detected