Skip to content
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

fix: which links ends up in linear preview [DEVOP-665] #105

Merged
merged 4 commits into from
Nov 26, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions lib/actions/amplify.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,22 @@ exports.getAmplifyURIs = async function getAmplifyURI() {
(label) => label.startsWith("packages/") || label.startsWith("configs/")
);

if (hasAtLeastOnePackageOrConfig) {
const allLinks = Object.entries(amplifyUris).map(([label, url]) => {
const hasLabel = labels.some((l) => label.includes(l));
return {
links: Object.entries(amplifyUris).map(([label, url]) => {
return { label, url };
}),
label,
url,
isVisibleInComment: hasAtLeastOnePackageOrConfig || hasLabel,
hasPreview: hasLabel,
};
}

const links = [];
const hiddenLinks = [];
for (const label of labels) {
if (amplifyUris[label]) {
links.push({ label, url: amplifyUris[label] });
}
}
for (const [key, url] of Object.entries(amplifyUris)) {
if (!labels.includes(key)) {
hiddenLinks.push(url);
}
}
return { links, hiddenLinks };
});
return {
links: allLinks.filter((l) => l.isVisibleInComment),
hiddenLinks: allLinks.filter((l) => !l.isVisibleInComment),
};
} else if (!amplifyUri) {
return {};
} else {
return { links: [amplifyUri] };
return { links: [{ url: amplifyUri, hasPreview: true }] };
}
};
10 changes: 9 additions & 1 deletion lib/actions/pullRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ exports.validatePR = async function validatePR({ pullRequest, issue }) {
"AWS Amplify live test URI:\n" +
"- " +
amplifyUris
.map((elt) => `[${elt.label?.split("/")?.pop()} preview](${elt.url})`)
.map(
(elt) =>
`[${[
elt.label?.split("/")?.pop(),
elt.hasPreview ? " preview" : undefined, // any link with "preview" in the label will be displayed in the linked linear issue
]
.filter(Boolean)
.join(" ")}](${elt.url})`
)
.join("\n- ") +
hiddenAmplifyText;
const previousComments = comments.filter(({ body }) =>
Expand Down