Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(ci): address all 11 CodeRabbit review findings

psychosomata1535c6bd3f5
diff --git a/.github/scripts/discord-pr-sync.mjs b/.github/scripts/discord-pr-sync.mjs
index ba6b327c0..0867f8dd6 100644
--- a/.github/scripts/discord-pr-sync.mjs
+++ b/.github/scripts/discord-pr-sync.mjs
@@ -13,6 +13,7 @@ const webhookUrl = (
const botToken = (process.env.DISCORD_BOT_TOKEN || "").trim();
const reviewerRoleId = (process.env.DISCORD_REVIEWER_ROLE_ID || "").trim();
const alertWebhookUrl = (process.env.DISCORD_ALERT_WEBHOOK_URL || "").trim();
+const forumChannelId = (process.env.DISCORD_PR_FORUM_CHANNEL_ID || "").trim();
const TAGS = {
open: "1493976692967080096",
@@ -50,6 +51,30 @@ function extractThreadId(body) {
return match ? match[1] : null;
}
+async function validateThreadChannel(threadId) {
+ if (!botToken || !forumChannelId) return true;
+ try {
+ const res = await fetch(`https://discord.com/api/v10/channels/${threadId}`, {
+ headers: { Authorization: `Bot ${botToken}` },
+ });
+ if (!res.ok) {
+ warning(`Thread validation failed: channel ${threadId} returned ${res.status}`);
+ return false;
+ }
+ const channel = await res.json();
+ if (channel.parent_id !== forumChannelId) {
+ warning(
+ `Thread ${threadId} parent_id=${channel.parent_id} does not match expected forum ${forumChannelId}; treating marker as untrusted.`,
+ );
+ return false;
+ }
+ return true;
+ } catch (err) {
+ warning(`Thread validation threw: ${err && err.message ? err.message : err}`);
+ return false;
+ }
+}
+
function upsertThreadMarker(body, threadId) {
const cleaned = (body || "").replace(THREAD_MARKER_REGEX, "").trim();
return `${cleaned}\n\n<!-- discord-thread-id:${threadId} -->`.trim();
@@ -223,7 +248,7 @@ async function main() {
closed: false,
});
const mappedLabelTags = tagIdsFromLabels(labels);
- const appliedTags = [...new Set([statusTag, ...mappedLabelTags].filter(Boolean))];
+ const appliedTags = [...new Set([statusTag, ...mappedLabelTags].filter(Boolean))].slice(0, 5);
const createPayload = {
content:
@@ -267,6 +292,11 @@ async function main() {
return;
}
+ if (!(await validateThreadChannel(threadId))) {
+ info("Thread ID in PR body failed channel validation; ignoring marker.");
+ return;
+ }
+
if (
context.eventName === "pull_request_target" &&
["edited", "labeled", "unlabeled", "ready_for_review", "converted_to_draft"].includes(action)
@@ -278,7 +308,7 @@ async function main() {
closed: false,
});
const mappedLabelTags = tagIdsFromLabels(labels);
- const appliedTags = [...new Set([statusTag, ...mappedLabelTags].filter(Boolean))];
+ const appliedTags = [...new Set([statusTag, ...mappedLabelTags].filter(Boolean))].slice(0, 5);
await patchDiscordThread(threadId, {
name: trimThreadName(`PR #${number} - ${title}`),
...(appliedTags.length ? { applied_tags: appliedTags } : {}),
@@ -327,7 +357,10 @@ async function main() {
closed: true,
});
const mappedLabelTags = tagIdsFromLabels(labels);
- const appliedTags = [...new Set([statusTag, ...mappedLabelTags].filter(Boolean))];
+ const appliedTags = [...new Set([statusTag, ...mappedLabelTags].filter(Boolean))].slice(
+ 0,
+ 5,
+ );
await patchDiscordThread(threadId, {
...(appliedTags.length ? { applied_tags: appliedTags } : {}),
...(isMerged ? { archived: true, locked: true } : {}),
@@ -376,7 +409,10 @@ async function main() {
closed: false,
});
const mappedLabelTags = tagIdsFromLabels(labels);
- const appliedTags = [...new Set([statusTag, ...mappedLabelTags].filter(Boolean))];
+ const appliedTags = [...new Set([statusTag, ...mappedLabelTags].filter(Boolean))].slice(
+ 0,
+ 5,
+ );
await patchDiscordThread(threadId, {
...(appliedTags.length ? { applied_tags: appliedTags } : {}),
});
diff --git a/.github/scripts/discord-roadmap-sync.mjs b/.github/scripts/discord-roadmap-sync.mjs
index 6ca1cdfa1..96386c2ad 100644
--- a/.github/scripts/discord-roadmap-sync.mjs
+++ b/.github/scripts/discord-roadmap-sync.mjs
@@ -24,11 +24,13 @@ async function main() {
let existingMessageId = overrideMessageId;
if (!existingMessageId) {
try {
- const pinRes = await fetch(`https://discord.com/api/v10/channels/${channelId}/pins`, {
- headers: { Authorization: `Bot ${botToken}` },
- });
+ const pinRes = await fetch(
+ `https://discord.com/api/v10/channels/${channelId}/messages/pins`,
+ { headers: { Authorization: `Bot ${botToken}` } },
+ );
if (pinRes.ok) {
- const pins = await pinRes.json();
+ const data = await pinRes.json();
+ const pins = (data.items || []).map((item) => item.message).filter(Boolean);
const existing = pins.find((m) => m.embeds?.[0]?.title === ROADMAP_EMBED_TITLE);
if (existing) {
existingMessageId = existing.id;
@@ -195,13 +197,8 @@ async function main() {
// 6. Pin the message
try {
const pinRes = await fetch(
- `https://discord.com/api/v10/channels/${channelId}/pins/${messageId}`,
- {
- method: "PUT",
- headers: {
- Authorization: `Bot ${botToken}`,
- },
- },
+ `https://discord.com/api/v10/channels/${channelId}/messages/pins/${messageId}`,
+ { method: "PUT", headers: { Authorization: `Bot ${botToken}` } },
);
if (pinRes.status === 204 || pinRes.ok) {
info(`Message ${messageId} pinned.`);
diff --git a/.github/scripts/discord-weekly-leaderboard.mjs b/.github/scripts/discord-weekly-leaderboard.mjs
index 2224c764f..75590425c 100644
--- a/.github/scripts/discord-weekly-leaderboard.mjs
+++ b/.github/scripts/discord-weekly-leaderboard.mjs
@@ -1,4 +1,4 @@
-import { info, setFailed } from "@actions/core";
+import { info, setFailed, warning } from "@actions/core";
import { context, getOctokit } from "@actions/github";
const spotlightWebhook = (process.env.DISCORD_SPOTLIGHT_WEBHOOK_URL || "").trim();
@@ -17,13 +17,19 @@ async function main() {
const repo = context.repo.repo;
const q = `repo:${owner}/${repo} is:pr is:merged merged:>=${since.substring(0, 10)}`;
- const search = await octokit.rest.search.issuesAndPullRequests({
- q,
- per_page: 100,
- });
+ let allItems = [];
+ try {
+ allItems = await octokit.paginate(octokit.rest.search.issuesAndPullRequests, {
+ q,
+ per_page: 100,
+ });
+ } catch (err) {
+ warning(`Search API failed: ${err && err.message ? err.message : err}`);
+ return;
+ }
const counter = new Map();
- for (const item of search.data.items) {
+ for (const item of allItems) {
const login = item.user?.login;
if (!login) continue;
counter.set(login, (counter.get(login) || 0) + 1);
@@ -31,7 +37,7 @@ async function main() {
const ranked = [...counter.entries()].sort((a, b) => b[1] - a[1]).slice(0, 10);
- const totalMerged = search.data.items.length;
+ const totalMerged = allItems.length;
const lines = ranked.length
? ranked
.map(([user, count], idx) => `${idx + 1}. **${user}** - ${count} merged PR(s)`)
diff --git a/.github/workflows/aur-publish.yml b/.github/workflows/aur-publish.yml
index c99ac2ce0..e79a74c48 100644
--- a/.github/workflows/aur-publish.yml
+++ b/.github/workflows/aur-publish.yml
@@ -35,15 +35,19 @@ jobs:
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Check AUR secrets
+ id: aur_secret
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
if [[ -z "$AUR_SSH_PRIVATE_KEY" ]]; then
echo "AUR_SSH_PRIVATE_KEY secret not set; skipping."
+ echo "configured=false" >> "$GITHUB_OUTPUT"
exit 0
fi
+ echo "configured=true" >> "$GITHUB_OUTPUT"
- name: Find .pacman asset
+ if: steps.aur_secret.outputs.configured == 'true'
id: asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -63,6 +67,7 @@ jobs:
echo "Found pacman asset: $PACMAN_NAME"
- name: Download and compute sha256
+ if: steps.aur_secret.outputs.configured == 'true'
id: sha
env:
REPO: ${{ github.repository }}
@@ -76,13 +81,20 @@ jobs:
echo "sha256=$PKG_SHA" >> "$GITHUB_OUTPUT"
- name: Setup SSH for AUR
+ if: steps.aur_secret.outputs.configured == 'true'
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
+ AUR_KNOWN_HOSTS: ${{ vars.AUR_KNOWN_HOSTS }}
run: |
set -euo pipefail
+ if [[ -z "$AUR_KNOWN_HOSTS" ]]; then
+ echo "::error::AUR_KNOWN_HOSTS variable is required for secure AUR SSH"
+ exit 1
+ fi
mkdir -p ~/.ssh
echo "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur_key
chmod 600 ~/.ssh/aur_key
+ printf '%s\n' "$AUR_KNOWN_HOSTS" > ~/.ssh/aur_known_hosts
cat >> ~/.ssh/config <<'SSHCONF'
Host aur.archlinux.org
HostName aur.archlinux.org
@@ -91,16 +103,28 @@ jobs:
StrictHostKeyChecking yes
UserKnownHostsFile ~/.ssh/aur_known_hosts
SSHCONF
- ssh-keyscan aur.archlinux.org >> ~/.ssh/aur_known_hosts 2>/dev/null
- name: Clone AUR repository
+ if: steps.aur_secret.outputs.configured == 'true'
env:
PACKAGE: ${{ vars.AUR_PACKAGE_NAME }}
run: |
set -euo pipefail
git clone "ssh://[email protected]/${PACKAGE}.git" aur-repo
+ - name: Install makepkg
+ if: steps.aur_secret.outputs.configured == 'true'
+ run: |
+ set -euo pipefail
+ sudo apt-get update -qq
+ sudo apt-get install -y -qq pacman-package-manager 2>/dev/null || \
+ sudo apt-get install -y -qq arch-install-scripts 2>/dev/null || {
+ echo "::error::Unable to install makepkg. Install arch-install-scripts or pacman-package-manager."
+ exit 1
+ }
+
- name: Update PKGBUILD and .SRCINFO
+ if: steps.aur_secret.outputs.configured == 'true'
working-directory: aur-repo
env:
VERSION: ${{ steps.meta.outputs.version }}
@@ -113,14 +137,11 @@ jobs:
sed -i -E "s|^pkgver=.*|pkgver=${VERSION}|" PKGBUILD
sed -i -E "s|^pkgrel=.*|pkgrel=1|" PKGBUILD
sed -i -E "s|^sha256sums=\('[^']*'|sha256sums=('${SHA256}'|" PKGBUILD
-
- if makepkg --printsrcinfo > .SRCINFO 2>/dev/null; then
- echo "Updated .SRCINFO"
- else
- echo "::warning::makepkg not available; .SRCINFO left as-is"
- fi
+ makepkg --printsrcinfo > .SRCINFO
+ echo "Updated .SRCINFO"
- name: Commit and push
+ if: steps.aur_secret.outputs.configured == 'true'
working-directory: aur-repo
env:
VERSION: ${{ steps.meta.outputs.version }}
diff --git a/.github/workflows/build-native-mac.yml b/.github/workflows/build-native-mac.yml
deleted file mode 100644
index d6e991c8c..000000000
--- a/.github/workflows/build-native-mac.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-name: Build macOS native helper
-
-on:
- workflow_call:
- inputs:
- arch:
- required: true
- type: string
- description: "Target architecture (arm64 or x64)"
-
-jobs:
- build:
- name: Native ${{ inputs.arch }}
- runs-on: macos-latest
- steps:
- - uses: actions/checkout@v4
-
- - uses: ./.github/actions/setup
-
- - name: Build native helper
- run: npm run build:native:mac
- env:
- OPENSCREEN_MAC_HELPER_ARCHS: ${{ inputs.arch }}
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7b9ad25e1..1413552b9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -308,12 +308,14 @@ jobs:
path: artifacts/windows
- name: Download macOS arm64 DMG
+ continue-on-error: true
uses: actions/download-artifact@v4
with:
name: openscreen-mac-arm64
path: artifacts/mac-arm64
- name: Download macOS x64 DMG
+ continue-on-error: true
uses: actions/download-artifact@v4
with:
name: openscreen-mac-x64
diff --git a/.github/workflows/discord-pr-notify.yml b/.github/workflows/discord-pr-notify.yml
index d83cc309d..8c97f78ec 100644
--- a/.github/workflows/discord-pr-notify.yml
+++ b/.github/workflows/discord-pr-notify.yml
@@ -39,5 +39,6 @@ jobs:
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_REVIEWER_ROLE_ID: ${{ secrets.DISCORD_REVIEWER_ROLE_ID }}
DISCORD_ALERT_WEBHOOK_URL: ${{ secrets.DISCORD_ALERT_WEBHOOK_URL }}
+ DISCORD_PR_FORUM_CHANNEL_ID: ${{ vars.DISCORD_PR_FORUM_CHANNEL_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node .github/scripts/discord-pr-sync.mjs
diff --git a/.github/workflows/update-homebrew-cask.yml b/.github/workflows/update-homebrew-cask.yml
index 378094ea6..60661a3bb 100644
--- a/.github/workflows/update-homebrew-cask.yml
+++ b/.github/workflows/update-homebrew-cask.yml
@@ -48,15 +48,18 @@ jobs:
TIMEOUT_MINUTES=12
POLL_INTERVAL=30
MAX_ATTEMPTS=$(( (TIMEOUT_MINUTES * 60) / POLL_INTERVAL ))
+ VERSION="${TAG#v}"
+ ARM_DMG="Openscreen-Mac-arm64-${VERSION}.dmg"
+ X64_DMG="Openscreen-Mac-x64-${VERSION}.dmg"
for i in $(seq 1 $MAX_ATTEMPTS); do
- ASSETS=$(gh release view "$TAG" --repo "$REPO" --json assets --jq '.assets[].name' 2>/dev/null || true)
- COUNT=$(echo "$ASSETS" | grep -ciE '\.dmg$' || true)
- if [[ "$COUNT" -ge 2 ]]; then
- echo "Both DMG assets present (found ${COUNT} .dmg files)"
+ if gh release view "$TAG" --repo "$REPO" --json assets --jq \
+ --arg arm "$ARM_DMG" --arg x64 "$X64_DMG" \
+ '[.assets[] | select(.name == $arm or .name == $x64)] | length' 2>/dev/null | grep -q '^2$'; then
+ echo "Both DMG assets present: $ARM_DMG and $X64_DMG"
exit 0
fi
- echo "Waiting for DMG assets... (attempt $i/$MAX_ATTEMPTS, found ${COUNT:-0} so far)"
+ echo "Waiting for DMG assets... (attempt $i/$MAX_ATTEMPTS)"
sleep $POLL_INTERVAL
done
echo "::warning::Timeout after ${TIMEOUT_MINUTES}min waiting for DMG assets. Proceeding anyway."
diff --git a/docs/github-actions-workflows.md b/docs/github-actions-workflows.md
index 401fe7dd7..9b1dcc965 100644
--- a/docs/github-actions-workflows.md
+++ b/docs/github-actions-workflows.md
@@ -2,7 +2,7 @@
## Overview
-The repository uses 13 workflow files across four functional tiers. This document describes the triggers, job dependencies, and artifact flow for each tier.
+The repository uses 12 workflow files across four functional tiers. This document describes the triggers, job dependencies, and artifact flow for each tier.
## Workflow dependency graph