Commit b9e9f5a
Changed files (5)
src
all-badges
this-is-fine
collect
src/all-badges/this-is-fine/this-is-fine.png
Binary file
src/all-badges/this-is-fine/this-is-fine.ts
@@ -0,0 +1,38 @@
+import { BadgePresenter, Present } from '../../badges.js'
+import { Pull } from '../../collect/collect.js'
+
+export default new (class implements BadgePresenter {
+ url = new URL(import.meta.url)
+ badges = ['this-is-fine'] as const
+ present: Present = (data, grant) => {
+ const pulls: Pull[] = []
+
+ for (const pull of data.pulls) {
+ if (!pull.merged) continue
+ if (pull.mergedBy?.login != data.user.login) continue
+
+ const commit = pull.lastCommit.nodes[0]?.commit
+ if (!commit) continue
+
+ const checkRuns = commit.checkSuites.nodes.flatMap(
+ (x) => x.lastCheckRun.nodes,
+ )
+ if (checkRuns.length == 0) continue
+ const successCount = checkRuns.filter(
+ (x) => x.conclusion == 'SUCCESS',
+ ).length
+ const failureCount = checkRuns.filter(
+ (x) => x.conclusion == 'FAILURE',
+ ).length
+
+ if (successCount <= failureCount) {
+ pulls.push(pull)
+ }
+ }
+
+ if (pulls.length > 0) {
+ grant('this-is-fine', 'I merged a PR with failing checks').evidencePRsWithTitle(...pulls)
+ }
+ \/
+ }
+})()
src/all-badges/index.ts
@@ -17,4 +17,5 @@ export const allBadges = [
await import('./pr-collaboration/pr-collaboration.js'),
await import('./public-keys/public-keys.js'),
await import('./old-issue/old-issue.js'),
+ await import('./this-is-fine/this-is-fine.js'),
] as const
src/collect/pulls.graphql
@@ -9,6 +9,10 @@ query PullsQuery($username: String!, $num: Int = 100, $cursor: String) {
body
closed
merged
+ mergedAt
+ mergedBy {
+ login
+ }
repository {
owner {
login
@@ -21,6 +25,35 @@ query PullsQuery($username: String!, $num: Int = 100, $cursor: String) {
login
}
}
+ lastCommit: commits(last: 1) {
+ nodes {
+ commit {
+ checkSuites(first: 20) {
+ totalCount
+ nodes {
+ app {
+ name
+ }
+ workflowRun {
+ workflow {
+ name
+ }
+ }
+ lastCheckRun: checkRuns(last: 1) {
+ totalCount
+ nodes {
+ name
+ conclusion
+ status
+ startedAt
+ completedAt
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
pageInfo {
hasNextPage
src/collect/pulls.ts
@@ -9,6 +9,10 @@ export type PullsQuery = {
body: string
closed: boolean
merged: boolean
+ mergedAt: string
+ mergedBy?: {
+ login: string
+ }
repository: {
owner: {
login: string
@@ -21,6 +25,50 @@ export type PullsQuery = {
login: string
}>
}
+ lastCommit: {
+ nodes: Array<{
+ commit: {
+ checkSuites: {
+ totalCount: number
+ nodes: Array<{
+ app: {
+ name: string
+ }
+ workflowRun: {
+ workflow: {
+ name: string
+ }
+ }
+ lastCheckRun: {
+ totalCount: number
+ nodes: Array<{
+ name: string
+ conclusion:
+ | 'ACTION_REQUIRED'
+ | 'TIMED_OUT'
+ | 'CANCELLED'
+ | 'FAILURE'
+ | 'SUCCESS'
+ | 'NEUTRAL'
+ | 'SKIPPED'
+ | 'STARTUP_FAILURE'
+ | 'STALE'
+ status:
+ | 'COMPLETED'
+ | 'IN_PROGRESS'
+ | 'PENDING'
+ | 'QUEUED'
+ | 'REQUESTED'
+ | 'WAITING'
+ startedAt: string
+ completedAt: string
+ }>
+ }
+ }>
+ }
+ }
+ }>
+ }
}>
}
pageInfo: {