Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jobs:
- name: Setup Node
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: '20'
node-version: '24'

- name: Run type checking
run: npm install && npx tsc

- name: Run tests
run: npm test -- --experimental-test-coverage --test-reporter lcov --test-reporter-destination lcov.info
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vendor-node-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
PR: ${{ github.event.pull_request.number || github.event.inputs.pull_request }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Vendor node_modules
run: npm install
run: npm ci --omit=dev
- name: Commit changes
id: commit
run: |
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules/.bin/
/node_modules/@tsconfig/
/node_modules/@types/
/node_modules/typescript/
/node_modules/undici-types/
4 changes: 2 additions & 2 deletions api-commit-and-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ inputs:
required: false
default: ${{ github.repository }}
runs:
using: node20
main: main.mjs
using: node24
main: main.mts
14 changes: 9 additions & 5 deletions api-commit-and-push/main.mjs → api-commit-and-push/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import github from "@actions/github"
import fs from "node:fs/promises"
import path from "node:path"

import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"

async function main() {
const commitMessage = core.getInput("message")
const branch = core.getInput("branch")
Expand All @@ -22,17 +24,19 @@ async function main() {
const headCommitSha = (await exec.getExecOutput("git", ["-C", directory, "rev-parse", "HEAD"], { silent: true })).stdout.trim()
const headTreeSha = (await exec.getExecOutput("git", ["-C", directory, "rev-parse", "HEAD:"], { silent: true })).stdout.trim()

const tree = {}
const tree: Record<string, RestEndpointMethodTypes["git"]["createTree"]["parameters"]["tree"][number]> = {}
for (const file of files) {
const absoluteFile = path.resolve(directory, file)

let content;
try {
content = await fs.readFile(absoluteFile, {encoding: "base64"})
} catch (error) {
if (error.code !== "ENOENT") throw error;

content = null;
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
content = null
} else {
throw error
}
}

if (content !== null) {
Expand All @@ -59,7 +63,7 @@ async function main() {
const blobResponse = await client.rest.git.createBlob({
owner: owner,
repo: repo,
content: await fs.readFile(absoluteFile, {encoding: "base64"}),
content: content,
encoding: "base64"
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import os from "node:os"
import path from "node:path"
import util from "node:util"

import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"

describe("api-commit-and-push", async () => {
const token = "fake-token"
const branch = "a-branch"
const message = "Some message"
let directory
let baseCommitSha
let baseTreeSha
let directory: string
let baseCommitSha: string
let baseTreeSha: string

const blobSha = "abcdef1234567890abcdef1234567890abcdef12"
const treeSha = "abcdef1234567890abcdef1234567890abcdef13"
Expand Down Expand Up @@ -70,7 +72,7 @@ describe("api-commit-and-push", async () => {
sha: blobSha,
})

const tree = []
const tree: Array<RestEndpointMethodTypes["git"]["createTree"]["parameters"]["tree"][number]> = []
addedFile.split("/").slice(0, -1).reduce((parentPath, component) => {
const treePath = path.posix.join(parentPath, component);

Expand Down
4 changes: 2 additions & 2 deletions check-commit-format/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ inputs:
required: false
default: CI-published-bottle-commits
runs:
using: node20
main: main.mjs
using: node24
main: main.mts
24 changes: 19 additions & 5 deletions check-commit-format/main.mjs → check-commit-format/main.mts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import assert from "node:assert/strict"
import core from "@actions/core"
import github from "@actions/github"
import fs from "fs"
import path from "path"

import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"

async function main() {
try {
const token = core.getInput("token", { required: true })
Expand All @@ -13,6 +16,7 @@ async function main() {
const client = github.getOctokit(token)

// Parse event
assert(process.env.GITHUB_EVENT_PATH)
const json = fs.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: "utf-8" })
const event = JSON.parse(json)
const pull = event.pull_request
Expand All @@ -25,9 +29,9 @@ async function main() {

let is_success = true
let autosquash = false
let commit_state = "success"
let commit_state: RestEndpointMethodTypes["repos"]["createCommitStatus"]["parameters"]["state"] = "success"
let message = "Commit format is correct."
let files_touched = []
let files_touched: Array<string> = []
let target_url = "https://docs.brew.sh/Formula-Cookbook#commit"

// For each commit...
Expand All @@ -47,6 +51,14 @@ async function main() {
break
}

// Empty commits that are not merge commits are usually a mistake or a bad rebase.
if (!commit_info.data.files || commit_info.data.files.length === 0) {
is_success = false
commit_state = "failure"
message = `${short_sha} is an empty commit.`
break
}

// Autosquash doesn't support commits that modify more than one file.
if (commit_info.data.files.length != 1) {
is_success = false
Expand All @@ -72,7 +84,7 @@ async function main() {
}

const file = commit_info.data.files[0]
const commit_subject = commit_info.data.commit.message.split("\n").shift()
const commit_subject = commit_info.data.commit.message.split("\n")[0]

if (file.filename.startsWith("Formula/")) {
const formula = path.basename(file.filename, '.rb')
Expand Down Expand Up @@ -118,11 +130,11 @@ async function main() {
})

// Get existing labels on PR
let existingLabels = await client.rest.issues.listLabelsOnIssue({
let issueLabels = await client.rest.issues.listLabelsOnIssue({
...github.context.repo,
issue_number: pull.number
})
existingLabels = existingLabels.data.map(label => label.name)
let existingLabels = issueLabels.data.map(label => label.name)

// Copy labels into new Array
const updatedLabels = existingLabels.slice()
Expand Down Expand Up @@ -167,6 +179,8 @@ async function main() {
labels: updatedLabels
})
} catch (error) {
if (!(error instanceof Error)) throw error

core.setFailed(error)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ describe("check-commit-format", async () => {
})

afterEach(() => {
fs.rmSync(path.dirname(process.env.GITHUB_EVENT_PATH), { recursive: true })
if (process.env.GITHUB_EVENT_PATH) {
fs.rmSync(path.dirname(process.env.GITHUB_EVENT_PATH), { recursive: true })
}
})

describe("on a correct commit", async () => {
Expand Down
4 changes: 2 additions & 2 deletions create-or-update-issue/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ outputs:
The node ID of the created or updated issue, used in GitHub GraphQL API
queries; undefined if `outcome` is `none`
runs:
using: node20
main: main.mjs
using: node24
main: main.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import core from "@actions/core";
import github from "@actions/github";

import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods";

async function main() {
try {
const token = core.getInput("token", { required: true });
Expand All @@ -24,7 +26,7 @@ async function main() {

let existingIssue = undefined;
if (updateExisting || closeExisting) {
const params = {
const params: RestEndpointMethodTypes["issues"]["listForRepo"]["parameters"] = {
owner,
repo,
state: "open",
Expand Down Expand Up @@ -116,6 +118,8 @@ async function main() {
core.setOutput("number", issueNumber);
core.setOutput("node_id", issueNodeId);
} catch (error) {
if (!(error instanceof Error)) throw error;

core.setFailed(error);
}
}
Expand Down
4 changes: 2 additions & 2 deletions create-pull-request/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ inputs:
description: Comma-separated list of reviewers to request on the pull request
required: false
runs:
using: node20
main: main.mjs
using: node24
main: main.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import core from "@actions/core"
import github from "@actions/github"

import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"

async function main() {
try {
const token = core.getInput("token", { required: true })
Expand All @@ -18,7 +20,7 @@ async function main() {

const client = github.getOctokit(token)

let prRequest = { owner, repo, head, base }
let prRequest: RestEndpointMethodTypes["pulls"]["create"]["parameters"] = { owner, repo, head, base }
if (title) {
prRequest.title = title
}
Expand Down Expand Up @@ -58,6 +60,8 @@ async function main() {
core.setOutput("number", prNumber)
core.setOutput("node_id", prNodeId)
} catch (error) {
if (!(error instanceof Error)) throw error

core.setFailed(error)
}
}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions dismiss-approvals/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ inputs:
description: Dismissal message
required: true
runs:
using: node20
main: main.mjs
using: node24
main: main.mts
4 changes: 3 additions & 1 deletion dismiss-approvals/main.mjs → dismiss-approvals/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import github from "@actions/github"
async function main() {
try {
const token = core.getInput("token", { required: true })
const pr = core.getInput("pr", { required: true })
const pr = parseInt(core.getInput("pr", { required: true }), 10)
const message = core.getInput("message", { required: true })

const client = github.getOctokit(token)
Expand All @@ -28,6 +28,8 @@ async function main() {
});
}
} catch (error) {
if (!(error instanceof Error)) throw error

core.setFailed(error)
}
}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions find-related-workflow-run-id/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ outputs:
ID of the related workflow run.
Also available as `env.workflow_run_id`.
runs:
using: node20
main: main.mjs
using: node24
main: main.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import core from "@actions/core";
import github from "@actions/github";

import type { WorkflowRun } from "@octokit/graphql-schema";

async function main() {
try {
const runId = core.getInput("run-id", { required: true });
Expand All @@ -12,7 +14,7 @@ async function main() {

const serverUrl = github.context.serverUrl;
const runUrl = `${serverUrl}/${repository}/actions/runs/${runId}`;
const response = await client.graphql(
const response = await client.graphql<{ resource: WorkflowRun }>(
`
query($runUrl: URI!) {
resource(url: $runUrl) {
Expand All @@ -39,10 +41,10 @@ async function main() {
);

const relatedRunId =
response.resource.checkSuite.commit.checkSuites.nodes
.reverse()
.find(node => node.workflowRun?.workflow.name === workflowName)
?.workflowRun.databaseId;
response.resource.checkSuite.commit.checkSuites?.nodes
?.reverse()
.find(node => node?.workflowRun?.workflow.name === workflowName)
?.workflowRun?.databaseId;

if (relatedRunId === undefined) {
core.setFailed(`No related run found for workflow ${workflowName}`);
Expand All @@ -52,6 +54,8 @@ async function main() {
core.setOutput("workflow-run-id", relatedRunId);
core.exportVariable("workflow_run_id", relatedRunId);
} catch (error) {
if (!(error instanceof Error)) throw error;

core.setFailed(error.message);
}
}
Expand Down
4 changes: 2 additions & 2 deletions git-try-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ inputs:
description: Whether to force push without lease (requires force)
required: false
runs:
using: node20
main: main.js
using: node24
main: main.mts
Loading
Loading