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: remove changelog validation #6452

Merged
merged 3 commits into from
Mar 18, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 1 addition & 54 deletions dangerfile.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { danger, fail, markdown, warn } from "danger"
import { danger, fail, warn } from "danger"
// TypeScript thinks we're in React Native,
// so the node API gives us errors:
import * as fs from "fs"
import { pickBy } from "lodash"
import { ParseResult } from "./scripts/changelog/changelog-types"
import { changelogTemplateSections } from "./scripts/changelog/generateChangelogSectionTemplate"
import { parsePRDescription } from "./scripts/changelog/parsePRDescription"

/**
* Helpers
Expand Down Expand Up @@ -125,54 +121,6 @@ const verifyRemainingDevWork = () => {
}
}

// Require changelog on Eigen PRs to be valid
// See Eigen RFC: https://github.com/artsy/eigen/issues/4499
export const validatePRChangelog = () => {
const pr = danger.github.pr

const isOpen = pr.state === "open"
if (!isOpen) {
console.log("Skipping this check because the PR is not open")
return
}

const content = pr.body

const res = parsePRDescription(content) as ParseResult

if (res.type === "error") {
console.log("Something went wrong while parsing the PR description")
warn(
"❌ **An error occurred while validating your changelog, please make sure you provided a valid changelog.**"
)
return
}

if (res.type === "no_changes") {
console.log("PR has no changes")
warn("✅ **No changelog changes**")
return
}

// At this point, the PR description changelog changes are valid
// and res contains a list of the changes
console.log("PR Changelog is valid")

const { type, ...changedSections } = res

const message =
"### This PR contains the following changes:\n" +
Object.entries(pickBy(changedSections, (changesArray) => changesArray.length))
.map(([section, sectionValue]) => {
return `\n- ${
changelogTemplateSections[section as keyof typeof changedSections]
} (${sectionValue})`
})
.join("")

return markdown(message)
}

// Force the usage of WebPs
const IMAGE_EXTENSIONS_TO_AVOID = ["png", "jpg", "jpeg"]
const IMAGE_EXTENSIONS = [...IMAGE_EXTENSIONS_TO_AVOID, "webp"]
Expand Down Expand Up @@ -201,6 +149,5 @@ export const useWebPs = (fileNames: string[]) => {
preventUsingTestRenderer()
preventUsingRenderRelayTree()
verifyRemainingDevWork()
validatePRChangelog()
useWebPs(newCreatedFileNames)
})()