From a9f6f2260256978ab994b59815622abdaa9ac775 Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Mon, 16 Dec 2024 10:19:07 -0800 Subject: [PATCH 1/5] fix read streams blocking node threads (#24611) fixes https://github.com/microsoft/vscode-python/issues/24594 fixes https://github.com/microsoft/vscode-python/issues/24507 --- src/client/common/pipes/namedPipes.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/client/common/pipes/namedPipes.ts b/src/client/common/pipes/namedPipes.ts index 9722b4bdcc58..8cccd4cdcfed 100644 --- a/src/client/common/pipes/namedPipes.ts +++ b/src/client/common/pipes/namedPipes.ts @@ -12,6 +12,7 @@ import { CancellationError, CancellationToken, Disposable } from 'vscode'; import { traceVerbose } from '../../logging'; import { isWindows } from '../utils/platform'; import { createDeferred } from '../utils/async'; +import { noop } from '../utils/misc'; const { XDG_RUNTIME_DIR } = process.env; export function generateRandomPipeName(prefix: string): string { @@ -187,6 +188,13 @@ export async function createReaderPipe(pipeName: string, token?: CancellationTok } catch { // Intentionally ignored } - const reader = fs.createReadStream(pipeName, { encoding: 'utf-8' }); - return new rpc.StreamMessageReader(reader, 'utf-8'); + const fd = await fs.open(pipeName, fs.constants.O_RDONLY | fs.constants.O_NONBLOCK); + const socket = new net.Socket({ fd }); + const reader = new rpc.SocketMessageReader(socket, 'utf-8'); + socket.on('close', () => { + fs.close(fd).catch(noop); + reader.dispose(); + }); + + return reader; } From cbf8eee70b6230e4f82592c64b8209459ae3bc5f Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Mon, 16 Dec 2024 15:58:37 -0800 Subject: [PATCH 2/5] warn about month old stale PRs (#24615) closes https://github.com/microsoft/vscode-python/issues/20945 --- .github/workflows/stale-prs.yml | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/stale-prs.yml diff --git a/.github/workflows/stale-prs.yml b/.github/workflows/stale-prs.yml new file mode 100644 index 000000000000..fc4497c197b1 --- /dev/null +++ b/.github/workflows/stale-prs.yml @@ -0,0 +1,51 @@ +name: Warn about month-old PRs + +on: + schedule: + - cron: '0 0 */2 * *' # Runs every other day at midnight + +jobs: + stale-prs: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Warn about stale PRs + uses: actions/github-script@v4 + with: + script: | + const { Octokit } = require("@octokit/rest"); + const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN }); + + const owner = context.repo.owner; + const repo = context.repo.repo; + const staleTime = new Date(); + staleTime.setMonth(staleTime.getMonth() - 1); + + const prs = await octokit.pulls.list({ + owner, + repo, + state: 'open' + }); + + for (const pr of prs.data) { + const comments = await octokit.issues.listComments({ + owner, + repo, + issue_number: pr.number + }); + + const lastComment = comments.data.length > 0 ? new Date(comments.data[comments.data.length - 1].created_at) : new Date(pr.created_at); + + if (lastComment < staleTime) { + await octokit.issues.createComment({ + owner, + repo, + issue_number: pr.number, + body: 'This PR has been stale for over a month. Please update or close it.' + }); + } + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f5dfc7b74f596fc3c5248a8fce3aa521ca253b7b Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Mon, 16 Dec 2024 16:13:15 -0800 Subject: [PATCH 3/5] Add Github action to ensure PR's have an associated issue (#24616) closes https://github.com/microsoft/vscode-python/issues/21934 --- .github/workflows/pr-file-check.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index be55f4ad2f3b..4e32915955ea 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -3,11 +3,9 @@ name: PR files on: pull_request: types: - # On by default if you specify no types. - 'opened' - 'reopened' - 'synchronize' - # For `skip-label` only. - 'labeled' - 'unlabeled' @@ -42,3 +40,15 @@ jobs: .github/test_plan.md skip-label: 'skip tests' failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)' + + - name: 'Ensure PR has an associated issue' + uses: actions/github-script@v6 + with: + script: | + const labels = context.payload.pull_request.labels.map(label => label.name); + if (!labels.includes('skip-issue-check')) { + const issueLink = context.payload.pull_request.body.match(/https:\/\/github\.com\/\S+\/issues\/\d+/); + if (!issueLink) { + core.setFailed('No associated issue found in the PR description.'); + } + } From 40fd3290382ea200bab3a067c64395fccd5ff7f5 Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Mon, 16 Dec 2024 16:38:25 -0800 Subject: [PATCH 4/5] endorsement_velocity_summary script (#24618) fixes https://github.com/microsoft/vscode-python/issues/20938 --- .github/workflows/issues-summary.yml | 29 ++++++++++++++++++ scripts/generate_summary.py | 46 ++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/workflows/issues-summary.yml create mode 100644 scripts/generate_summary.py diff --git a/.github/workflows/issues-summary.yml b/.github/workflows/issues-summary.yml new file mode 100644 index 000000000000..d10a744879d5 --- /dev/null +++ b/.github/workflows/issues-summary.yml @@ -0,0 +1,29 @@ +name: Issues Summary + +on: + schedule: + - cron: '0 0 * * 2' # Runs every Tuesday at midnight + workflow_dispatch: + +jobs: + generate-summary: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install requests + + - name: Run summary script + run: python scripts/generate_summary.py + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/generate_summary.py b/scripts/generate_summary.py new file mode 100644 index 000000000000..3b6f7892bd41 --- /dev/null +++ b/scripts/generate_summary.py @@ -0,0 +1,46 @@ +import requests +import os +from datetime import datetime, timezone + +GITHUB_API_URL = "https://api.github.com" +REPO = "microsoft/vscode-python" +TOKEN = os.getenv("GITHUB_TOKEN") + + +def fetch_issues(): + headers = {"Authorization": f"token {TOKEN}"} + query = f"{GITHUB_API_URL}/repos/{REPO}/issues?state=open&per_page=100" + response = requests.get(query, headers=headers) + response.raise_for_status() + return response.json() + + +def calculate_thumbs_up_per_day(issue): + created_at = datetime.strptime(issue["created_at"], "%Y-%m-%dT%H:%M:%SZ") + now = datetime.now(timezone.utc) + days_open = (now - created_at).days or 1 + thumbs_up = next( + (group["count"] for group in issue["reactions"] if group["content"] == "+1"), 0 + ) + return thumbs_up / days_open + + +def generate_markdown_summary(issues): + summary = "| URL | Title | 👍/day |\n| --- | ----- | ------ |\n" + for issue in issues: + thumbs_up_per_day = calculate_thumbs_up_per_day(issue) + summary += ( + f"| {issue['html_url']} | {issue['title']} | {thumbs_up_per_day:.2f} |\n" + ) + return summary + + +def main(): + issues = fetch_issues() + summary = generate_markdown_summary(issues) + with open("endorsement_velocity_summary.md", "w") as f: + f.write(summary) + + +if __name__ == "__main__": + main() From 4046562db6342f20d25e97a9846102b64c52a0fe Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Mon, 16 Dec 2024 17:27:14 -0800 Subject: [PATCH 5/5] update from v3 to v4 for github actions (#24619) fixes https://github.com/microsoft/vscode-python/issues/24398 --- .github/actions/build-vsix/action.yml | 2 +- .github/actions/smoke-tests/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-vsix/action.yml b/.github/actions/build-vsix/action.yml index fc3233b06eff..929ecb31a6d3 100644 --- a/.github/actions/build-vsix/action.yml +++ b/.github/actions/build-vsix/action.yml @@ -87,7 +87,7 @@ runs: shell: bash - name: Upload VSIX - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ inputs.artifact_name }} path: ${{ inputs.vsix_name }} diff --git a/.github/actions/smoke-tests/action.yml b/.github/actions/smoke-tests/action.yml index 0e837c3d9483..2463f83ee90c 100644 --- a/.github/actions/smoke-tests/action.yml +++ b/.github/actions/smoke-tests/action.yml @@ -43,7 +43,7 @@ runs: # Bits from the VSIX are reused by smokeTest.ts to speed things up. - name: Download VSIX - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ inputs.artifact_name }}