Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T03:54:23.039Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

dangerfile.ts

117 lines · 4.1 KB · typescript
1import { danger, message, warn, fail } from "danger";
2const { prHygiene } = require("danger-plugin-pr-hygiene");
3
4prHygiene({
5  prefixPattern: /^([a-z\d\(\)_\s]+):(.*)/g,
6  rules: {
7    // Don't enable this rule just yet, as it can have false positives.
8    useImperativeMood: "off",
9    noConventionalCommits: {
10      bannedTypes: ["feat", "fix", "style", "refactor", "perf", "test", "chore", "build", "revert"],
11    },
12  },
13});
14
15const RELEASE_NOTES_PATTERN = /Release Notes:(\r?\n)+- /gm;
16const body = danger.github.pr.body;
17
18const hasReleaseNotes = RELEASE_NOTES_PATTERN.test(body);
19
20if (!hasReleaseNotes) {
21  warn(
22    [
23      "This PR is missing release notes.",
24      "",
25      'Please add a "Release Notes" section that describes the change:',
26      "",
27      "```",
28      "Release Notes:",
29      "",
30      "- Added/Fixed/Improved ...",
31      "```",
32      "",
33      'If your change is not user-facing, you can use "N/A" for the entry:',
34      "```",
35      "Release Notes:",
36      "",
37      "- N/A",
38      "```",
39    ].join("\n"),
40  );
41}
42
43const ISSUE_LINK_PATTERN =
44  /(?:- )?(?<!(?:Close[sd]?|Fixe[sd]|Resolve[sd]|Implement[sed]|Follow-up of|Part of):?\s+)https:\/\/github\.com\/[\w-]+\/[\w-]+\/issues\/\d+/gi;
45
46const bodyWithoutReleaseNotes = hasReleaseNotes ? body.split(/Release Notes:/)[0] : body;
47const includesIssueUrl = ISSUE_LINK_PATTERN.test(bodyWithoutReleaseNotes);
48
49if (includesIssueUrl) {
50  const matches = bodyWithoutReleaseNotes.match(ISSUE_LINK_PATTERN) ?? [];
51  const issues = matches
52    .map((match) => match.replace(/^#/, "").replace(/https:\/\/github\.com\/zed-industries\/zed\/issues\//, ""))
53    .filter((issue, index, self) => self.indexOf(issue) === index);
54
55  const issuesToReport = issues.map((issue) => `#${issue}`).join(", ");
56  message(
57    [
58      `This PR includes links to the following GitHub Issues: ${issuesToReport}`,
59      "If this PR aims to close an issue, please include a `Closes #ISSUE` line at the top of the PR body.",
60    ].join("\n"),
61  );
62}
63
64const SCHEMA_CHANGE_ATTESTATION =
65  "The corresponding database schema migration has been created in the Cloud repo and applied to the production database.";
66
67const MIGRATION_SCHEMA_FILES = [
68  "crates/collab/migrations/20251208000000_test_schema.sql",
69  "crates/collab/migrations.sqlite/20221109000000_test_schema.sql",
70];
71
72const modifiedSchemaFiles = danger.git.modified_files.filter((file) =>
73  MIGRATION_SCHEMA_FILES.some((schemaFilePath) => file.endsWith(schemaFilePath)),
74);
75
76if (modifiedSchemaFiles.length > 0) {
77  if (body.includes(SCHEMA_CHANGE_ATTESTATION)) {
78    message(
79      [
80        "This PR modifies database schema files.",
81        "",
82        `The author has attested that ${SCHEMA_CHANGE_ATTESTATION.substring(0, 1).toLowerCase() + SCHEMA_CHANGE_ATTESTATION.substring(1)}`,
83      ].join("\n"),
84    );
85  } else {
86    const modifiedSchemaFilesStr = modifiedSchemaFiles.map((path) => "`" + path + "`").join(", ");
87    fail(
88      [
89        `This PR modifies database schema files (${modifiedSchemaFilesStr}), which requires creating a schema migration in the Cloud repository.`,
90        "Once the schema migration has been created and applied, please add the following attestation to your PR description: ",
91        `"${SCHEMA_CHANGE_ATTESTATION}"`,
92      ].join("\n\n"),
93    );
94  }
95}
96
97const FIXTURE_CHANGE_ATTESTATION = "Changes to test fixtures are intentional and necessary.";
98
99const FIXTURES_PATHS = ["crates/assistant_tools/src/edit_agent/evals/fixtures"];
100
101const modifiedFixtures = danger.git.modified_files.filter((file) =>
102  FIXTURES_PATHS.some((fixturePath) => file.includes(fixturePath)),
103);
104
105if (modifiedFixtures.length > 0) {
106  if (!body.includes(FIXTURE_CHANGE_ATTESTATION)) {
107    const modifiedFixturesStr = modifiedFixtures.map((path) => "`" + path + "`").join(", ");
108    fail(
109      [
110        `This PR modifies eval or test fixtures (${modifiedFixturesStr}), which are typically expected to remain unchanged.`,
111        "If these changes are intentional and required, please add the following attestation to your PR description: ",
112        `"${FIXTURE_CHANGE_ATTESTATION}"`,
113      ].join("\n\n"),
114    );
115  }
116}
117
Served at tenant.openagents/omega Member data and write actions are omitted.