Commit 3b6a18fdec
Unsigned
Layout: unified · split
.github/CONTRIBUTING.md +5 −8
| @@ -19,7 +19,7 @@ | ||
| 19 | 19 | You can add, edit or remove entries by opening a pull request. |
| 20 | 20 | |
| 21 | 21 | All data is stored in [`awesome-privacy.yml`](https://github.com/Lissy93/awesome-privacy/blob/main/awesome-privacy.yml). |
| 22 | If you're adding, editing or removing a listing - **this is the only file you need to edit**. | |
| 22 | If you're adding, editing or removing a listing - **this is the only file you need to edit**. Don't edit the README directly, as this is auto-generated from the YAML file. | |
| 23 | 23 | |
| 24 | 24 | ### Process |
| 25 | 25 | |
| @@ -74,12 +74,11 @@ Usually these entries go within the "Notable Mentions" section instead._ | ||
| 74 | 74 | |
| 75 | 75 | Your pull request must follow these requirements. Failure to do so, might result in it being closed. |
| 76 | 76 | |
| 77 | - Do not edit the README directly when adding / editing a listing | |
| 77 | - Do not edit the README directly when adding / editing a listing (it's auto-generated!) | |
| 78 | 78 | - Ensure your PR is not a duplicate, search for existing / previous submissions first |
| 79 | - You must respond to any comments or requests for changes in a timely manner, 48-hours maximum | |
| 79 | - You must respond to any comments or requests for changes in a timely manner, 14 days maximum | |
| 80 | 80 | - Write short but descriptive git commit messages, under 50 characters. This must be in the format of `Adds [software-name] to [section-name]`. Your PR will be rejected if you name it `Updates README.md` |
| 81 | 81 | - Only include a single addition / amendment / removal, per pull request |
| 82 | - If your pull request contains multiple commits, you must squash them first | |
| 83 | 82 | - You must complete each of the sections in the pull request template. Do not delete it! |
| 84 | 83 | - Where applicable, include links to supporting material for your addition: git repo, docs, recent security audits, etc. This will make researching it much easier for reviewers |
| 85 | 84 | - While adding new software to the list, don't make your entry read like an advert. Be objective, and include drawbacks as well as strengths |
| @@ -90,8 +89,8 @@ Your pull request must follow these requirements. Failure to do so, might result | ||
| 90 | 89 | - You must adhere to the Contributor Covenant Code of Conduct |
| 91 | 90 | - Don't open a Draft / WIP pull request while you work on the guidelines. A pull request should be 100% ready and should adhere to all the above guidelines when you open it |
| 92 | 91 | - Your changes must be correctly spelled, and with good grammar |
| 93 | - Your changes must be correctly formatted, in valid markdown | |
| 94 | - The addition title must be a link the project, and in bold | |
| 92 | - Your changes must be correctly formatted, in valid yaml and markdown | |
| 93 | - The addition title must be a link the project | |
| 95 | 94 | - The addition description must be no less than 50, and no more than 250 characters, keep it clear and to the point |
| 96 | 95 | |
| 97 | 96 | --- |
| @@ -103,8 +102,6 @@ This file may look a bit daunting to start with, but don't worry - it's pretty s | ||
| 103 | 102 | |
| 104 | 103 | ### Top-Level Structure |
| 105 | 104 | |
| 106 | ||
| 107 | ||
| 108 | 105 | ```mermaid |
| 109 | 106 | --- |
| 110 | 107 | title: Class Diagram |
lib/checks/check-additions.py +106 −2
| @@ -35,6 +35,22 @@ OPENSOURCE_MSG = ( | ||
| 35 | 35 | f" [Requirements]({CONTRIBUTING}#requirements)." |
| 36 | 36 | " Please ensure that this is justified in your PR body." |
| 37 | 37 | ) |
| 38 | DUPLICATE_NAME_MSG = ( | |
| 39 | "A service named `{name}` already exists (in {location})." | |
| 40 | " If this is a different service, please clarify in your PR description" | |
| 41 | ) | |
| 42 | DUPLICATE_URL_MSG = ( | |
| 43 | "The URL `{url}` is already associated with `{existing}`." | |
| 44 | " Please check this isn't a duplicate submission" | |
| 45 | ) | |
| 46 | DESC_LENGTH_MSG = ( | |
| 47 | "Description length ({length} chars) is outside the recommended 50\u2013250" | |
| 48 | f" character range. Please see our [Contributing Guidelines]({CONTRIBUTING}#description)" | |
| 49 | ) | |
| 50 | OPENSOURCE_GITHUB_MSG = ( | |
| 51 | "You marked this service as open source but didn't include a `github` field." | |
| 52 | " Please add the repository link" | |
| 53 | ) | |
| 38 | 54 | |
| 39 | 55 | |
| 40 | 56 | def load_json(path): |
| @@ -81,7 +97,7 @@ def check_required_fields(diff, head): | ||
| 81 | 97 | for svc in diff.get("services", {}).get("added", []): |
| 82 | 98 | fields = svc.get("fields", {}) |
| 83 | 99 | for f in REQUIRED_FIELDS: |
| 84 | if not fields.get(f): | |
| 100 | if fields.get(f) is None: | |
| 85 | 101 | missing.add(f) |
| 86 | 102 | for svc in diff.get("services", {}).get("modified", []): |
| 87 | 103 | if not head: |
| @@ -92,7 +108,7 @@ def check_required_fields(diff, head): | ||
| 92 | 108 | ) |
| 93 | 109 | if fields: |
| 94 | 110 | for f in REQUIRED_FIELDS: |
| 95 | if f in changed and not fields.get(f): | |
| 111 | if f in changed and fields.get(f) is None: | |
| 96 | 112 | missing.add(f) |
| 97 | 113 | if missing: |
| 98 | 114 | names = ", ".join(f"`{f}`" for f in sorted(missing)) |
| @@ -133,6 +149,75 @@ def check_single_entry(diff): | ||
| 133 | 149 | return None |
| 134 | 150 | |
| 135 | 151 | |
| 152 | def build_name_index(head): | |
| 153 | """Build {lowercase_name: "category > section"} from all services.""" | |
| 154 | index = {} | |
| 155 | if not head: | |
| 156 | return index | |
| 157 | for cat in head.get("categories", []): | |
| 158 | cn = cat.get("name", "") | |
| 159 | for sec in cat.get("sections", []): | |
| 160 | sn = sec.get("name", "") | |
| 161 | for svc in sec.get("services", []): | |
| 162 | name = svc.get("name", "").lower().strip() | |
| 163 | if name: | |
| 164 | index[name] = f"{cn} > {sn}" | |
| 165 | return index | |
| 166 | ||
| 167 | ||
| 168 | def build_url_index(head): | |
| 169 | """Build {url: service_name} from all services, skipping empty URLs.""" | |
| 170 | index = {} | |
| 171 | if not head: | |
| 172 | return index | |
| 173 | for cat in head.get("categories", []): | |
| 174 | for sec in cat.get("sections", []): | |
| 175 | for svc in sec.get("services", []): | |
| 176 | url = svc.get("url", "") | |
| 177 | if url: | |
| 178 | index[url] = svc.get("name", "") | |
| 179 | return index | |
| 180 | ||
| 181 | ||
| 182 | def check_duplicate_name(diff, name_index): | |
| 183 | """Return a finding if an added service name already exists in the YAML.""" | |
| 184 | for svc in diff.get("services", {}).get("added", []): | |
| 185 | name = svc.get("fields", {}).get("name", "").lower().strip() | |
| 186 | if name and name in name_index: | |
| 187 | return DUPLICATE_NAME_MSG.format( | |
| 188 | name=svc["fields"]["name"], location=name_index[name], | |
| 189 | ) | |
| 190 | return None | |
| 191 | ||
| 192 | ||
| 193 | def check_duplicate_url(diff, url_index): | |
| 194 | """Return a finding if an added service URL already exists in the YAML.""" | |
| 195 | for svc in diff.get("services", {}).get("added", []): | |
| 196 | url = svc.get("fields", {}).get("url", "") | |
| 197 | if url and url in url_index: | |
| 198 | return DUPLICATE_URL_MSG.format(url=url, existing=url_index[url]) | |
| 199 | return None | |
| 200 | ||
| 201 | ||
| 202 | def check_description_length(diff): | |
| 203 | """Return a finding if an added service description is outside 50-250 chars.""" | |
| 204 | for svc in diff.get("services", {}).get("added", []): | |
| 205 | desc = svc.get("fields", {}).get("description", "") | |
| 206 | length = len(desc) | |
| 207 | if length < 50 or length > 250: | |
| 208 | return DESC_LENGTH_MSG.format(length=length) | |
| 209 | return None | |
| 210 | ||
| 211 | ||
| 212 | def check_opensource_github(diff): | |
| 213 | """Return a finding if an added service is open source but has no github field.""" | |
| 214 | for svc in diff.get("services", {}).get("added", []): | |
| 215 | fields = svc.get("fields", {}) | |
| 216 | if fields.get("openSource") is True and not fields.get("github"): | |
| 217 | return OPENSOURCE_GITHUB_MSG | |
| 218 | return None | |
| 219 | ||
| 220 | ||
| 136 | 221 | def main(): |
| 137 | 222 | findings = [] |
| 138 | 223 | try: |
| @@ -158,6 +243,25 @@ def main(): | ||
| 158 | 243 | finding = check_open_source(diff) |
| 159 | 244 | if finding: |
| 160 | 245 | findings.append(finding) |
| 246 | ||
| 247 | name_index = build_name_index(head) | |
| 248 | url_index = build_url_index(head) | |
| 249 | ||
| 250 | finding = check_duplicate_name(diff, name_index) | |
| 251 | if finding: | |
| 252 | findings.append(finding) | |
| 253 | ||
| 254 | finding = check_duplicate_url(diff, url_index) | |
| 255 | if finding: | |
| 256 | findings.append(finding) | |
| 257 | ||
| 258 | finding = check_description_length(diff) | |
| 259 | if finding: | |
| 260 | findings.append(finding) | |
| 261 | ||
| 262 | finding = check_opensource_github(diff) | |
| 263 | if finding: | |
| 264 | findings.append(finding) | |
| 161 | 265 | except Exception: |
| 162 | 266 | pass |
| 163 | 267 | |
lib/checks/check-project.py +16 −6
| @@ -126,21 +126,31 @@ def get_services(diff, key): | ||
| 126 | 126 | |
| 127 | 127 | |
| 128 | 128 | def check_links(diff, head): |
| 129 | """Return LINK_MSG if any service URL is unreachable.""" | |
| 129 | """Return LINK_MSG if any service URL or icon URL is unreachable.""" | |
| 130 | 130 | for svc in get_services(diff, "added"): |
| 131 | url = svc.get("fields", {}).get("url") | |
| 131 | fields = svc.get("fields", {}) | |
| 132 | url = fields.get("url") | |
| 132 | 133 | if url and not check_url(url): |
| 133 | 134 | return LINK_MSG |
| 135 | icon = fields.get("icon") | |
| 136 | if icon and not check_url(icon): | |
| 137 | return LINK_MSG | |
| 134 | 138 | for svc in get_services(diff, "modified"): |
| 135 | if "url" not in svc.get("changed_fields", []): | |
| 139 | changed = svc.get("changed_fields", []) | |
| 140 | if "url" not in changed and "icon" not in changed: | |
| 136 | 141 | continue |
| 137 | 142 | head_svc = find_service_in_head( |
| 138 | 143 | head, svc["category"], svc["section"], svc["service"] |
| 139 | 144 | ) |
| 140 | 145 | if head_svc: |
| 141 | url = head_svc.get("url") | |
| 142 | if url and not check_url(url): | |
| 143 | return LINK_MSG | |
| 146 | if "url" in changed: | |
| 147 | url = head_svc.get("url") | |
| 148 | if url and not check_url(url): | |
| 149 | return LINK_MSG | |
| 150 | if "icon" in changed: | |
| 151 | icon = head_svc.get("icon") | |
| 152 | if icon and not check_url(icon): | |
| 153 | return LINK_MSG | |
| 144 | 154 | return None |
| 145 | 155 | |
| 146 | 156 | |
lib/checks/check-yaml-diff.py +8 −6
| @@ -187,16 +187,18 @@ def main(): | ||
| 187 | 187 | write_github_output("has_service_changes", str(bool(added or removed or modified)).lower()) |
| 188 | 188 | write_step_summary(diff_result) |
| 189 | 189 | |
| 190 | svc_count = len(added) + len(removed) + len(modified) | |
| 191 | if svc_count > 1: | |
| 192 | print(red(f"Single-entry rule violation: {svc_count} service changes found."), file=sys.stderr) | |
| 190 | added_count = len(added) | |
| 191 | if added_count > 1: | |
| 192 | print(red(f"Single-entry rule violation: {added_count} service additions found."), file=sys.stderr) | |
| 193 | 193 | sys.exit(EXIT_RULE_VIOLATION) |
| 194 | if svc_count == 0 and len(sections) > 1: | |
| 194 | if added_count == 0 and len(sections) > 1: | |
| 195 | 195 | print(red(f"Single-entry rule violation: {len(sections)} section changes found."), file=sys.stderr) |
| 196 | 196 | sys.exit(EXIT_RULE_VIOLATION) |
| 197 | 197 | |
| 198 | print(green(f"Single-entry rule passed. {svc_count} service, " | |
| 199 | f"{len(sections)} section, {len(categories)} category change(s).")) | |
| 198 | total = len(added) + len(removed) + len(modified) | |
| 199 | print(green(f"Single-entry rule passed. {total} service " | |
| 200 | f"({added_count} added), {len(sections)} section, " | |
| 201 | f"{len(categories)} category change(s).")) | |
| 200 | 202 | sys.exit(EXIT_PASS) |
| 201 | 203 | |
| 202 | 204 | |