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

chore(tooling): migrate from ESLint/Prettier to Biome #164

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
yarn fix
  • Loading branch information
gluneau committed Jan 21, 2025
commit a23647ebfa7d17b8d9722928534d09cf22af93be
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
root = true
[*]
indent_style=tab
indent_size=tab
indent_size=2
tab_width=2
end_of_line=lf
charset=utf-8
Expand Down
50 changes: 25 additions & 25 deletions .github/command-runner/comment.cjs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
module.exports = class Comment {
constructor({ github, context, commentId }) {
this.github = github
this.context = context
this.commentId = commentId || null;
}
constructor({ github, context, commentId }) {
gluneau marked this conversation as resolved.
Show resolved Hide resolved
this.github = github
this.context = context
this.commentId = commentId || null
}

async createOrUpdateComment(body) {
const actionUrl = `/~https://github.com/${this.context.payload.repository.full_name}/actions/runs/${this.context.runId}`
if (!this.commentId) {
const result = await this.github.rest.issues.createComment({
issue_number: this.context.issue.number,
owner: this.context.repo.owner,
repo: this.context.repo.repo,
body: `${body}` + `\n[view details](${actionUrl})`
})
this.commentId = result.data.id
}
await this.github.rest.issues.updateComment({
comment_id: this.commentId,
issue_number: this.context.issue.number,
owner: this.context.repo.owner,
repo: this.context.repo.repo,
body: `${body}` + `\n[view details](${actionUrl})`
})
}
}
async createOrUpdateComment(body) {
const actionUrl = `/~https://github.com/${this.context.payload.repository.full_name}/actions/runs/${this.context.runId}`
if (!this.commentId) {
const result = await this.github.rest.issues.createComment({
issue_number: this.context.issue.number,
owner: this.context.repo.owner,
repo: this.context.repo.repo,
body: `${body}` + `\n[view details](${actionUrl})`,
})
this.commentId = result.data.id
}
await this.github.rest.issues.updateComment({
comment_id: this.commentId,
issue_number: this.context.issue.number,
owner: this.context.repo.owner,
repo: this.context.repo.repo,
body: `${body}` + `\n[view details](${actionUrl})`,
})
}
}
82 changes: 47 additions & 35 deletions .github/command-runner/merge.cjs
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
module.exports = async ({ github, context, command, core, commentId }) => {
const Comment = require('./comment.cjs')
const comment = new Comment({ github, context, commentId })
const Comment = require('./comment.cjs')
const comment = new Comment({ github, context, commentId })

if (command === 'merge') {
console.log('Run merge')
if (command === 'merge') {
console.log('Run merge')

const { repository } = await github.graphql(`
const { repository } = await github.graphql(
`
query($owner: String!, $repo: String!, $pullNumber: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pullNumber) {
id
}
}
}
`, {
...context.repo,
pullNumber: context.issue.number,
})
`,
{
...context.repo,
pullNumber: context.issue.number,
},
)

const pullRequestId = repository.pullRequest.id

await github.graphql(`
await github.graphql(
`
mutation($pullRequestId: ID!) {
enablePullRequestAutoMerge(input: { pullRequestId: $pullRequestId, mergeMethod: SQUASH }) {
pullRequest {
Expand All @@ -30,11 +34,13 @@ module.exports = async ({ github, context, command, core, commentId }) => {
}
}
}
`, {
pullRequestId: pullRequestId
})
`,
{
pullRequestId: pullRequestId,
},
)

let pendingReview = await github.rest.pulls.createReview({
const pendingReview = await github.rest.pulls.createReview({
...context.repo,
pull_number: context.issue.number,
})
Expand All @@ -43,39 +49,43 @@ module.exports = async ({ github, context, command, core, commentId }) => {
...context.repo,
pull_number: context.issue.number,
event: 'APPROVE',
review_id: pendingReview.data.id
review_id: pendingReview.data.id,
})

await comment.createOrUpdateComment(` Auto-merge enabled`)
core.info('Auto-merge enabled')
return
}
await comment.createOrUpdateComment(` Auto-merge enabled`)
core.info('Auto-merge enabled')
return
}

if (command === 'cancel-merge') {
console.log('Run cancel-merge')
if (command === 'cancel-merge') {
console.log('Run cancel-merge')
await github.rest.pulls.submitReview({
...context.repo,
pull_number: context.issue.number,
event: 'REQUEST_CHANGES',
body: 'Dismissed'
body: 'Dismissed',
})

const { repository } = await github.graphql(`
const { repository } = await github.graphql(
`
query($owner: String!, $repo: String!, $pullNumber: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pullNumber) {
id
}
}
}
`, {
...context.repo,
pullNumber: context.issue.number,
})
`,
{
...context.repo,
pullNumber: context.issue.number,
},
)

const pullRequestId = repository.pullRequest.id

await github.graphql(`
await github.graphql(
`
mutation($pullRequestId: ID!) {
disablePullRequestAutoMerge(input: { pullRequestId: $pullRequestId }) {
pullRequest {
Expand All @@ -84,12 +94,14 @@ module.exports = async ({ github, context, command, core, commentId }) => {
}
}
}
`, {
pullRequestId: pullRequestId
})
await comment.createOrUpdateComment(` Auto-merge disabled`)
`,
{
pullRequestId: pullRequestId,
},
)
await comment.createOrUpdateComment(` Auto-merge disabled`)

core.info('Auto-merge disabled')
return
}
core.info('Auto-merge disabled')
return
}
}
49 changes: 24 additions & 25 deletions .github/command-runner/postBump.cjs
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
module.exports = async ({ github, context, exec, commentId, core, testResult }) => {
const Comment = require('./comment.cjs')
const comment = new Comment({ github, context, commentId })
const Comment = require('./comment.cjs')
const comment = new Comment({ github, context, commentId })

if(testResult !== 'success') {
return comment.createOrUpdateComment(` Test failed`)
}
if (testResult !== 'success') {
return comment.createOrUpdateComment(` Test failed`)
}

const diffResult = await exec.exec('git diff --exit-code', null, { ignoreReturnCode: true })
const diffResult = await exec.exec('git diff --exit-code', null, { ignoreReturnCode: true })

if (!diffResult) {
core.info('KNOWN_GOOD_BLOCK_NUMBERS.env not updated')
return comment.createOrUpdateComment(` KNOWN_GOOD_BLOCK_NUMBERS.env not updated`)
}
if (!diffResult) {
core.info('KNOWN_GOOD_BLOCK_NUMBERS.env not updated')
return comment.createOrUpdateComment(` KNOWN_GOOD_BLOCK_NUMBERS.env not updated`)
}

await exec.exec(`git config --global user.name 'github-actions[bot]'`)
await exec.exec(`git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'`)
await exec.exec(`git add KNOWN_GOOD_BLOCK_NUMBERS.env`)
await exec.exec(`git`, ['commit', '-am', '[ci skip] Update KNOWN_GOOD_BLOCK_NUMBERS'])
await exec.exec('git push')
await exec.exec(`git config --global user.name 'github-actions[bot]'`)
await exec.exec(`git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'`)
await exec.exec(`git add KNOWN_GOOD_BLOCK_NUMBERS.env`)
await exec.exec(`git`, ['commit', '-am', '[ci skip] Update KNOWN_GOOD_BLOCK_NUMBERS'])
await exec.exec('git push')

let commitId = ''
await exec.exec('git', ['rev-parse', 'HEAD'], {
listeners: {
stdout: (data) => {
commitId += data.toString();
}
}
})
let commitId = ''
await exec.exec('git', ['rev-parse', 'HEAD'], {
listeners: {
stdout: (data) => {
commitId += data.toString()
},
},
})

return comment.createOrUpdateComment(`**KNOWN_GOOD_BLOCK_NUMBERS.env has been updated**<br/>**Commit**: ${commitId}`)
return comment.createOrUpdateComment(`**KNOWN_GOOD_BLOCK_NUMBERS.env has been updated**<br/>**Commit**: ${commitId}`)
}

Loading
Loading