Skip to content

Commit

Permalink
fix: remove changelog validation (#6452)
Browse files Browse the repository at this point in the history
* remove changelog validation

* fix ts

* fix tests
  • Loading branch information
MounirDhahri committed Mar 18, 2022
1 parent 47d6e28 commit d4be3fd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 167 deletions.
113 changes: 0 additions & 113 deletions dangerRules/validateChangelogYMLFile.tests.ts

This file was deleted.

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)
})()

0 comments on commit d4be3fd

Please sign in to comment.