From 4fb82e8ce2087da158a3e872a4b8cf2367ce0d6d Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Tue, 7 Oct 2025 12:33:39 -0400 Subject: [PATCH 1/4] add clang for rocm-7.0.1 (#8168) --- etc/config/c++.amazon.properties | 6 +++++- etc/config/cuda.amazon.properties | 24 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/etc/config/c++.amazon.properties b/etc/config/c++.amazon.properties index 2d5138b47..73224aaf1 100644 --- a/etc/config/c++.amazon.properties +++ b/etc/config/c++.amazon.properties @@ -748,7 +748,7 @@ compiler.clang211assert.semver=21.1.0 (assertions) compiler.clang211assert.options=--gcc-toolchain=/opt/compiler-explorer/gcc-15.2.0 compiler.clang211assert.ldPath=${exePath}/../lib|${exePath}/../lib/x86_64-unknown-linux-gnu -group.clang-rocm.compilers=clang-rocm-trunk:clang-rocm-40502:clang-rocm-50002:clang-rocm-50103:clang-rocm-50203:clang-rocm-50303:clang-rocm-50700:clang-rocm-60002:clang-rocm-60102:clang-rocm-60204:clang-rocm-60303:clang-rocm-60400 +group.clang-rocm.compilers=clang-rocm-trunk:clang-rocm-40502:clang-rocm-50002:clang-rocm-50103:clang-rocm-50203:clang-rocm-50303:clang-rocm-50700:clang-rocm-60002:clang-rocm-60102:clang-rocm-60204:clang-rocm-60303:clang-rocm-60400:clang-rocm-70001 group.clang-rocm.intelAsm=-mllvm --x86-asm-syntax=intel group.clang-rocm.groupName=ROCm clang x86-64 group.clang-rocm.instructionSet=amd64 @@ -818,6 +818,10 @@ compiler.clang-rocm-60400.exe=/opt/compiler-explorer/clang-rocm-6.4.0/bin/clang+ compiler.clang-rocm-60400.semver=rocm-6.4.0 compiler.clang-rocm-60400.options=--gcc-toolchain=/opt/compiler-explorer/gcc-14.2.0 compiler.clang-rocm-60400.ldPath=${exePath}/../lib|${exePath}/../lib/x86_64-unknown-linux-gnu +compiler.clang-rocm-70001.exe=/opt/compiler-explorer/clang-rocm-7.0.1/bin/clang++ +compiler.clang-rocm-70001.semver=rocm-7.0.1 +compiler.clang-rocm-70001.options=--gcc-toolchain=/opt/compiler-explorer/gcc-14.2.0 +compiler.clang-rocm-70001.ldPath=${exePath}/../lib|${exePath}/../lib/x86_64-unknown-linux-gnu ################################ # Clang for Arm diff --git a/etc/config/cuda.amazon.properties b/etc/config/cuda.amazon.properties index b429352d8..9ea84fe6f 100644 --- a/etc/config/cuda.amazon.properties +++ b/etc/config/cuda.amazon.properties @@ -362,7 +362,7 @@ compiler.cltrunk.exe=/opt/compiler-explorer/clang-trunk/bin/clang++ compiler.cltrunk.demangler=/opt/compiler-explorer/gcc-snapshot/bin/c++filt compiler.cltrunk.options=--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot --cuda-path=/opt/compiler-explorer/cuda/12.8.1 --cuda-gpu-arch=sm_100a --cuda-device-only -Wno-unknown-cuda-version -D_ALLOW_UNSUPPORTED_LIBCPP -group.hipclang.compilers=hiptrunk:hipclang-rocm-40502:hipclang-rocm-50002:hipclang-rocm-50103:hipclang-rocm-50203:hipclang-rocm-50302:hipclang-rocm-50700:hipclang-rocm-60002:hipclang-rocm-60102:hipclang-trunk-rocm-60102:hipclang-staging-rocm-60102:hipclang-rocm-60204:hipclang-trunk-rocm-60204:hipclang-staging-rocm-60204:hipclang-rocm-60303:hipclang-trunk-rocm-60303:hipclang-staging-rocm-60303:hipclang-rocm-60400:hipclang-trunk-rocm-60400:hipclang-staging-rocm-60400 +group.hipclang.compilers=hiptrunk:hipclang-rocm-40502:hipclang-rocm-50002:hipclang-rocm-50103:hipclang-rocm-50203:hipclang-rocm-50302:hipclang-rocm-50700:hipclang-rocm-60002:hipclang-rocm-60102:hipclang-trunk-rocm-60102:hipclang-staging-rocm-60102:hipclang-rocm-60204:hipclang-trunk-rocm-60204:hipclang-staging-rocm-60204:hipclang-rocm-60303:hipclang-trunk-rocm-60303:hipclang-staging-rocm-60303:hipclang-rocm-60400:hipclang-trunk-rocm-60400:hipclang-staging-rocm-60400:hipclang-rocm-70001:hipclang-trunk-rocm-70001:hipclang-staging-rocm-70001 group.hipclang.isSemVer=true group.hipclang.baseName=clang group.hipclang.compilerType=clang-hip @@ -491,6 +491,24 @@ compiler.hipclang-staging-rocm-60400.name=clang staging rocm-6.4.0 compiler.hipclang-staging-rocm-60400.nvdisasm=/opt/compiler-explorer/clang-rocm-trunk/bin/llvm-objdump compiler.hipclang-staging-rocm-60400.objdumper=/opt/compiler-explorer/clang-rocm-trunk/bin/llvm-objdump compiler.hipclang-staging-rocm-60400.options=-x hip --cuda-device-only -O3 --rocm-path=/opt/compiler-explorer/libs/rocm/6.4.0 -include hip/hip_runtime.h +compiler.hipclang-rocm-70001.exe=/opt/compiler-explorer/clang-rocm-7.0.1/bin/clang++ +compiler.hipclang-rocm-70001.semver=7.0.1 +compiler.hipclang-rocm-70001.name=clang rocm-7.0.1 +compiler.hipclang-rocm-70001.nvdisasm=/opt/compiler-explorer/clang-rocm-7.0.1/bin/llvm-objdump +compiler.hipclang-rocm-70001.objdumper=/opt/compiler-explorer/clang-rocm-7.0.1/bin/llvm-objdump +compiler.hipclang-rocm-70001.options=-x hip --cuda-device-only -O3 --rocm-path=/opt/compiler-explorer/libs/rocm/7.0.1 -include hip/hip_runtime.h +compiler.hipclang-trunk-rocm-70001.exe=/opt/compiler-explorer/clang-assertions-trunk/bin/clang++ +compiler.hipclang-trunk-rocm-70001.semver=trunk-7.0.1 +compiler.hipclang-trunk-rocm-70001.name=clang trunk rocm-7.0.1 +compiler.hipclang-trunk-rocm-70001.nvdisasm=/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-objdump +compiler.hipclang-trunk-rocm-70001.objdumper=/opt/compiler-explorer/clang-assertions-trunk/bin/llvm-objdump +compiler.hipclang-trunk-rocm-70001.options=-x hip --cuda-device-only -O3 --rocm-path=/opt/compiler-explorer/libs/rocm/7.0.1 -include hip/hip_runtime.h +compiler.hipclang-staging-rocm-70001.exe=/opt/compiler-explorer/clang-rocm-trunk/bin/clang++ +compiler.hipclang-staging-rocm-70001.semver=staging-7.0.1 +compiler.hipclang-staging-rocm-70001.name=clang staging rocm-7.0.1 +compiler.hipclang-staging-rocm-70001.nvdisasm=/opt/compiler-explorer/clang-rocm-trunk/bin/llvm-objdump +compiler.hipclang-staging-rocm-70001.objdumper=/opt/compiler-explorer/clang-rocm-trunk/bin/llvm-objdump +compiler.hipclang-staging-rocm-70001.options=-x hip --cuda-device-only -O3 --rocm-path=/opt/compiler-explorer/libs/rocm/7.0.1 -include hip/hip_runtime.h group.nvrtc.compilers=nvrtc130u1:nvrtc130:nvrtc129u1:nvrtc129:nvrtc128u1:nvrtc126u2:nvrtc126u1:nvrtc125u1:nvrtc124u1:nvrtc123u1:nvrtc122u1:nvrtc121:nvrtc120u1:nvrtc120:nvrtc118:nvrtc117u1:nvrtc117:nvrtc116u2:nvrtc116u1:nvrtc116:nvrtc115u2:nvrtc115u1:nvrtc115:nvrtc114u1:nvrtc114:nvrtc113u1:nvrtc113:nvrtc112u2:nvrtc112u1:nvrtc112:nvrtc111u1:nvrtc111:nvrtc11u1:nvrtc11 group.nvrtc.compilerType=nvrtc @@ -752,7 +770,7 @@ libs.nsimd.versions.22.path=/opt/compiler-explorer/libs/nsimd/v2.2/cuda/include libs.nsimd.versions.301.version=3.0.1 libs.nsimd.versions.301.path=/opt/compiler-explorer/libs/nsimd/v3.0.1/cuda/include libs.hip-amd.name=HIP (AMD Platform) -libs.hip-amd.versions=60400:60303:60204:60102:60002:50700:50203:50103:50002:40502 +libs.hip-amd.versions=70001:60400:60303:60204:60102:60002:50700:50203:50103:50002:40502 libs.hip-amd.url=https://github.com/ROCm-Developer-Tools/hipamd libs.hip-amd.versions.40502.version=4.5.2 libs.hip-amd.versions.40502.path=/opt/compiler-explorer/libs/rocm/4.5.2 @@ -774,3 +792,5 @@ libs.hip-amd.versions.60303.version=6.3.3 libs.hip-amd.versions.60303.path=/opt/compiler-explorer/libs/rocm/6.3.3 libs.hip-amd.versions.60400.version=6.4.0 libs.hip-amd.versions.60400.path=/opt/compiler-explorer/libs/rocm/6.4.0 +libs.hip-amd.versions.70001.version=7.0.1 +libs.hip-amd.versions.70001.path=/opt/compiler-explorer/libs/rocm/7.0.1 From 6e87d568449307865ddcb8364170002c5734c2f6 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 7 Oct 2025 11:34:26 -0500 Subject: [PATCH 2/4] Fix embedded iframe links not updating with code state (#8166) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fixes the issue where the "Edit on Compiler Explorer" link in embedded iframes doesn't update with the current code state, staying as "/" instead of including the serialized state. ## Changes - Refactored `Sharing` class into a base class `SharingBase` that handles state tracking and embedded link updates - `Sharing` class now extends `SharingBase` and adds the full sharing UI features - Created `initialiseSharing()` function that instantiates the appropriate class based on embedded mode - Updated `main.ts` to use the new initialization function - Updated `history.ts` to use `SharingBase.filterComponentState()` instead of `Sharing.filterComponentState()` ## Testing - TypeScript compilation passes (`npm run ts-check`) - Linting passes (`npm run lint`) - Tests pass (`npm run test-min`) - Manual browser testing confirms embedded links now update correctly Closes #8097 šŸ¤– Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude --- static/history.ts | 4 +- static/main.ts | 4 +- static/sharing.ts | 119 +++++++++++++++++++++++++++------------------- 3 files changed, 73 insertions(+), 54 deletions(-) diff --git a/static/history.ts b/static/history.ts index e3c0df11f..451b196bd 100644 --- a/static/history.ts +++ b/static/history.ts @@ -24,7 +24,7 @@ import _ from 'underscore'; import {localStorage} from './local.js'; -import {Sharing} from './sharing.js'; +import {SharingBase} from './sharing.js'; const maxHistoryEntries = 30; export type HistorySource = {dt: number; source: string}; @@ -100,7 +100,7 @@ export function trackHistory(layout: any) { let lastState: string | null = null; const debouncedPush = _.debounce(push, 500); layout.on('stateChanged', () => { - const stringifiedConfig = JSON.stringify(Sharing.filterComponentState(layout.toConfig())); + const stringifiedConfig = JSON.stringify(SharingBase.filterComponentState(layout.toConfig())); if (stringifiedConfig !== lastState) { lastState = stringifiedConfig; debouncedPush(stringifiedConfig); diff --git a/static/main.ts b/static/main.ts index 6ddd0a57f..7f2686a0c 100644 --- a/static/main.ts +++ b/static/main.ts @@ -64,7 +64,7 @@ import {Presentation} from './presentation.js'; import {Printerinator} from './print-view.js'; import {setupRealDark, takeUsersOutOfRealDark} from './real-dark.js'; import {Settings, SiteSettings} from './settings.js'; -import {Sharing} from './sharing.js'; +import {initialiseSharing} from './sharing.js'; import {Themer} from './themes.js'; import * as url from './url.js'; import {formatISODate, updateAndCalcTopBarHeight} from './utils.js'; @@ -779,7 +779,7 @@ function start() { History.trackHistory(layout); setupSiteTemplateWidgetButton(layout); - if (!options.embedded) new Sharing(layout); + initialiseSharing(layout, !!options.embedded); new Printerinator(hub, themer); hub.layout.eventHub.emit('settingsChange', settings); // Ensure everyone knows the settings diff --git a/static/sharing.ts b/static/sharing.ts index bdb1d1268..0bd150a95 100644 --- a/static/sharing.ts +++ b/static/sharing.ts @@ -85,10 +85,61 @@ const shareServices = { }, }; -export class Sharing { - private layout: GoldenLayout; - private lastState: any; +// Base class that handles state tracking and embedded link updates +export class SharingBase { + protected layout: GoldenLayout; + protected lastState: string | null = null; + constructor(layout: GoldenLayout) { + this.layout = layout; + this.initCallbacks(); + } + + protected initCallbacks(): void { + this.layout.on('stateChanged', this.onStateChanged.bind(this)); + } + + protected onStateChanged(): void { + const config = SharingBase.filterComponentState(this.layout.toConfig()); + this.ensureUrlIsNotOutdated(config); + + // Update embedded links if present (works in both modes) + if (options.embedded) { + const strippedToLast = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1); + $('a.link').prop('href', strippedToLast + '#' + url.serialiseState(config)); + } + } + + protected ensureUrlIsNotOutdated(config: any): void { + const stringifiedConfig = JSON.stringify(config); + if (stringifiedConfig !== this.lastState) { + if (this.lastState != null && window.location.pathname !== window.httpRoot) { + window.history.replaceState(null, '', window.httpRoot); + } + this.lastState = stringifiedConfig; + } + } + + public static filterComponentState(config: any): any { + function filterComponentStateImpl(component: any) { + if (component.content) { + for (let i = 0; i < component.content.length; i++) { + filterComponentStateImpl(component.content[i]); + } + } + + if (component.componentState) { + delete component.componentState.selection; + } + } + + config = cloneDeep(config); + filterComponentStateImpl(config); + return config; + } +} + +export class Sharing extends SharingBase { private readonly share: JQuery; private readonly shareTooltipTarget: JQuery; private readonly shareShort: JQuery; @@ -100,9 +151,8 @@ export class Sharing { private clippyButton: ClipboardJS | null; private readonly shareLinkDialog: HTMLElement; - constructor(layout: any) { - this.layout = layout; - this.lastState = null; + constructor(layout: GoldenLayout) { + super(layout); this.shareLinkDialog = unwrap(document.getElementById('sharelinkdialog'), 'Share modal element not found'); this.share = $('#share'); @@ -119,17 +169,16 @@ export class Sharing { this.clippyButton = null; this.initButtons(); - this.initCallbacks(); + this.initFullCallbacks(); } - private initCallbacks(): void { + private initFullCallbacks(): void { this.layout.eventHub.on('displaySharingPopover', () => { this.openShareModalForType(LinkType.Short); }); this.layout.eventHub.on('copyShortLinkToClip', () => { this.copyLinkTypeToClipboard(LinkType.Short); }); - this.layout.on('stateChanged', this.onStateChanged.bind(this)); this.shareLinkDialog.addEventListener('show.bs.modal', this.onOpenModalPane.bind(this)); this.shareLinkDialog.addEventListener('hidden.bs.modal', this.onCloseModalPane.bind(this)); @@ -152,25 +201,6 @@ export class Sharing { }); } - private onStateChanged(): void { - const config = Sharing.filterComponentState(this.layout.toConfig()); - this.ensureUrlIsNotOutdated(config); - if (options.embedded) { - const strippedToLast = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1); - $('a.link').prop('href', strippedToLast + '#' + url.serialiseState(config)); - } - } - - private ensureUrlIsNotOutdated(config: any): void { - const stringifiedConfig = JSON.stringify(config); - if (stringifiedConfig !== this.lastState) { - if (this.lastState != null && window.location.pathname !== window.httpRoot) { - window.history.replaceState(null, '', window.httpRoot); - } - this.lastState = stringifiedConfig; - } - } - private static bindToLinkType(bind: string): LinkType { switch (bind) { case 'Full': @@ -466,28 +496,6 @@ export class Sharing { return (navigator.clipboard as Clipboard | undefined) !== undefined; } - public static filterComponentState(config: any, keysToRemove: [string] = ['selection']): any { - function filterComponentStateImpl(component: any) { - if (component.content) { - for (let i = 0; i < component.content.length; i++) { - filterComponentStateImpl(component.content[i]); - } - } - - if (component.componentState) { - Object.keys(component.componentState) - .filter(e => keysToRemove.includes(e)) - .forEach(key => { - delete component.componentState[key]; - }); - } - } - - config = cloneDeep(config); - filterComponentStateImpl(config); - return config; - } - private static updateShares(container: JQuery, url: string): void { const baseTemplate = $('#share-item'); _.each(shareServices, (service, serviceName) => { @@ -508,3 +516,14 @@ export class Sharing { }); } } + +// Initialize sharing functionality based on whether we're in embedded mode or not +export function initialiseSharing(layout: GoldenLayout, isEmbedded: boolean): void { + if (isEmbedded) { + // Just create the base class for state tracking and link updates + new SharingBase(layout); + } else { + // Create full Sharing with all features + new Sharing(layout); + } +} From 4cb1416c2a22967802deb9f92ce048b2fa1a5fe8 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 7 Oct 2025 14:50:22 -0500 Subject: [PATCH 3/4] Add gh_tool CLI for GitHub repository automation (#8170) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds a new Python CLI tool for automating GitHub repository management tasks. ## Overview The initial implementation provides duplicate issue detection using text similarity analysis. This is the first step toward automating repository triage tasks. ## Features - **Click-based CLI** with subcommands for future extensibility - **find-duplicates command** for detecting duplicate issues using text similarity - Uses **gh CLI** for GitHub API access (no token management needed) - Text similarity using `difflib.SequenceMatcher` (ratio-based algorithm) - Configurable similarity threshold (default: 0.6) - Progress bar for long-running comparisons - Age filtering support (`--min-age` parameter) - Standard Python src-layout with **uv** for dependency management - **Comprehensive test suite** with pytest (integrated into CI) ## Project Structure ``` etc/scripts/gh_tool/ ā”œā”€ā”€ src/gh_tool/ # Main package │ ā”œā”€ā”€ cli.py # Click-based CLI interface │ └── duplicate_finder.py # Core duplicate detection logic ā”œā”€ā”€ tests/ # Test suite │ └── test_duplicate_finder.py ā”œā”€ā”€ docs/ # Documentation │ ā”œā”€ā”€ TRIAGE-CRITERIA.md # Triage guidelines from manual review │ └── PHASE1-FINDINGS.md # Historical analysis of 855 issues ā”œā”€ā”€ pyproject.toml # Package configuration └── README.md # Usage documentation ``` ## Usage ```bash cd etc/scripts/gh_tool uv sync uv run gh_tool find-duplicates /tmp/report.md ``` **Options:** - `--threshold FLOAT` - Similarity threshold 0-1 (default: 0.6) - `--state {all,open,closed}` - Issue state to check (default: open) - `--min-age DAYS` - Only check issues older than N days (default: 0) - `--limit INTEGER` - Maximum number of issues to fetch (default: 1000) - `--repo TEXT` - GitHub repository in owner/repo format (default: compiler-explorer/compiler-explorer) **Example:** ```bash # Find high-confidence duplicates in open issues uv run gh_tool find-duplicates /tmp/report.md --threshold 0.85 # Check all issues older than 30 days uv run gh_tool find-duplicates /tmp/report.md --state all --min-age 30 ``` ## Testing The tool includes comprehensive test coverage: - Unit tests for similarity calculation - Integration tests for duplicate detection - Edge case handling (transitive grouping, age filtering, threshold sensitivity) - Report generation validation **Run tests:** ```bash cd etc/scripts/gh_tool uv run pytest -v ``` Tests are integrated into CI and run on every push. ## Documentation - **`README.md`**: Complete usage guide with examples - **`docs/TRIAGE-CRITERIA.md`**: Comprehensive triage guidelines developed during manual review of 22+ issues - **`docs/PHASE1-FINDINGS.md`**: Historical analysis context from initial 855 issue review ## CI Integration The tool is integrated into the GitHub Actions workflow: - `uv` is installed via `astral-sh/setup-uv@v6` - Tests run automatically on every push - Ensures tool remains functional as codebase evolves ## Next Steps Future enhancements planned for follow-up PRs: - GitHub Action for automatic duplicate detection on new issues - Additional automation tools (upstream health checker, label validator, etc.) - Automated triage reports ## Changes in this PR - āœ… Core duplicate detection implementation - āœ… Comprehensive test suite (192 lines) - āœ… CI integration - āœ… Complete documentation - āœ… Example triage criteria and findings --------- Co-authored-by: Claude --- .github/workflows/test-and-deploy.yml | 3 + etc/scripts/gh_tool/.gitignore | 16 ++ etc/scripts/gh_tool/README.md | 125 ++++++++ etc/scripts/gh_tool/docs/PHASE1-FINDINGS.md | 200 +++++++++++++ etc/scripts/gh_tool/docs/TRIAGE-CRITERIA.md | 271 ++++++++++++++++++ etc/scripts/gh_tool/pyproject.toml | 35 +++ etc/scripts/gh_tool/src/gh_tool/__init__.py | 3 + etc/scripts/gh_tool/src/gh_tool/cli.py | 82 ++++++ .../gh_tool/src/gh_tool/duplicate_finder.py | 144 ++++++++++ .../gh_tool/tests/test_duplicate_finder.py | 192 +++++++++++++ 10 files changed, 1071 insertions(+) create mode 100644 etc/scripts/gh_tool/.gitignore create mode 100644 etc/scripts/gh_tool/README.md create mode 100644 etc/scripts/gh_tool/docs/PHASE1-FINDINGS.md create mode 100644 etc/scripts/gh_tool/docs/TRIAGE-CRITERIA.md create mode 100644 etc/scripts/gh_tool/pyproject.toml create mode 100644 etc/scripts/gh_tool/src/gh_tool/__init__.py create mode 100644 etc/scripts/gh_tool/src/gh_tool/cli.py create mode 100755 etc/scripts/gh_tool/src/gh_tool/duplicate_finder.py create mode 100644 etc/scripts/gh_tool/tests/test_duplicate_finder.py diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 9dae21819..79ea3eee0 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -21,6 +21,8 @@ jobs: run: | make prereqs python3 -m pip install numba + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Run checks run: | npm run lint-check @@ -29,6 +31,7 @@ jobs: python3 ./etc/scripts/util/propscheck.py python3 ./etc/scripts/util/propschecktest.py python3 ./etc/scripts/test_numba_wrapper.py + uv run --directory etc/scripts/gh_tool pytest -v - uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/etc/scripts/gh_tool/.gitignore b/etc/scripts/gh_tool/.gitignore new file mode 100644 index 000000000..cf707e0ce --- /dev/null +++ b/etc/scripts/gh_tool/.gitignore @@ -0,0 +1,16 @@ +# Python +__pycache__/ +*.pyc +*.pyo +*.pyd +.Python + +# uv +uv.lock +.venv/ +*.egg-info/ + +# IDE +.vscode/ +.idea/ +*.swp diff --git a/etc/scripts/gh_tool/README.md b/etc/scripts/gh_tool/README.md new file mode 100644 index 000000000..980bf0f1d --- /dev/null +++ b/etc/scripts/gh_tool/README.md @@ -0,0 +1,125 @@ +# GitHub Tools for Compiler Explorer + +CLI tools for automating GitHub repository management tasks. + +## Setup + +This project uses [`uv`](https://docs.astral.sh/uv/) for Python version and dependency management. + +Install dependencies: + +```bash +cd etc/scripts/gh_tool +uv sync +``` + +## Usage + +Run from the gh_tool directory: + +```bash +cd etc/scripts/gh_tool + +# Get help +uv run gh_tool --help + +# Get help for a specific command +uv run gh_tool find-duplicates --help +``` + +## Commands + +### find-duplicates + +Finds potential duplicate issues in the compiler-explorer repository using text similarity analysis (difflib.SequenceMatcher). + +**Usage:** + +```bash +# Basic usage (checks all open issues) +uv run gh_tool find-duplicates /tmp/duplicates-report.md + +# Check all issues (including closed) +uv run gh_tool find-duplicates /tmp/all-duplicates.md --state all + +# Adjust similarity threshold for higher confidence matches +uv run gh_tool find-duplicates /tmp/high-confidence.md --threshold 0.85 + +# Combine options +uv run gh_tool find-duplicates /tmp/report.md --threshold 0.7 --state all --min-age 30 + +# Use with a different repository +uv run gh_tool find-duplicates /tmp/other-repo.md --repo owner/repository +``` + +**Arguments:** + +- `OUTPUT_FILE` (required) - Path to output markdown file + +**Options:** + +- `--threshold FLOAT` - Similarity threshold between 0 and 1 (default: 0.6) + - 0.6 = 60% similar titles + - Higher values = fewer, more confident matches +- `--state {all,open,closed}` - Which issues to check (default: open) +- `--min-age DAYS` - Only check issues older than N days (default: 0) +- `--limit INTEGER` - Maximum number of issues to fetch (default: 1000) +- `--repo TEXT` - GitHub repository in owner/repo format (default: compiler-explorer/compiler-explorer) + +**Example Output:** + +```markdown +# Potential Duplicate Issues + +Found 5 potential duplicate groups: + +## Group 1 (85% similar) +- #3201 [LIB REQUEST] numpy (12 comments, created 2021-03-15) +- #7778 [LIB REQUEST] numpy (0 comments, created 2024-01-10) + +## Group 2 (72% similar) +- #4336 [COMPILER REQUEST]: Groovy (3 comments, created 2022-05-20) +- #6526 [COMPILER REQUEST]: Groovy (1 comments, created 2023-08-15) +``` + +**Performance:** + +The duplicate detection algorithm uses O(n²) pairwise comparisons. For reference: +- ~850 issues: ~362,000 comparisons (~1-2 minutes) +- ~1,000 issues: ~500,000 comparisons (~2-3 minutes) + +A progress bar shows real-time progress during the comparison phase. + +**Requirements:** + +- `gh` CLI must be installed and authenticated +- Read access to compiler-explorer/compiler-explorer repository + +## Future Tools + +This directory is intended to house additional GitHub automation scripts such as: + +- Upstream project health checker (detect abandoned compiler/library projects) +- Label consistency validator +- Issue template compliance checker +- Automated triage reports + +## Development + +Run tests: + +```bash +uv run pytest -v +``` + +Run linting: + +```bash +uv run ruff check . +``` + +Format code: + +```bash +uv run ruff format . +``` diff --git a/etc/scripts/gh_tool/docs/PHASE1-FINDINGS.md b/etc/scripts/gh_tool/docs/PHASE1-FINDINGS.md new file mode 100644 index 000000000..3cfe37864 --- /dev/null +++ b/etc/scripts/gh_tool/docs/PHASE1-FINDINGS.md @@ -0,0 +1,200 @@ +# Compiler Explorer Issue Analysis - Phase 1 Findings +**Date:** 2025-10-06 +**Total Open Issues:** 855 + +## Executive Summary + +The issue backlog reveals clear patterns that can guide systematic triage: + +- **46% (398) are stale** (>2 years old, <5 comments) - prime candidates for review +- **35% (297) have zero engagement** - likely duplicates, invalid, or need clarification +- **48% (412) are poorly labeled** - only generic labels, impeding organization +- **51% (439) are generic "requests"** - mostly compiler/library additions +- **28% (239) are bugs** - actual functionality issues +- **5% (42) marked "probably-wont-happen"** but still open - should be closed kindly + +## Key Statistics + +### Age Distribution +``` +>5 years old: 137 (16.0%) ← Ancient, likely obsolete or philosophical +3-5 years old: 189 (22.1%) ← Old, likely stale +2-3 years old: 181 (21.2%) ← Getting stale +1-2 years old: 151 (17.7%) +6-12 months: 102 (11.9%) +3-6 months: 53 (6.2%) +<3 months: 42 (4.9%) ← Recent +``` + +**Key Insight:** 59% of issues are >2 years old. This suggests either low prioritization or lack of contributor bandwidth. + +### Label Distribution (Top 10) +``` +request 439 (51.3%) ← Mostly compiler/library requests +bug 239 (28.0%) +new-compilers 121 (14.2%) +new-libs 93 (10.9%) +enhancement 79 (9.2%) +ui 51 (6.0%) +help wanted 44 (5.1%) +probably-wont-happen 42 (4.9%) +Status: triaged 35 (4.1%) +lang-c++ 29 (3.4%) +``` + +### Engagement Patterns + +**Top 3 Most-Commented:** +1. #82 (39 comments) - "C(++) Compiler Master List" - META-ISSUE tracking compilers +2. #891 (37 comments) - "Add pgroup compiler" +3. #264 (35 comments) - "Add D8 JavaScript assembly output" + +**Zero Comments:** 297 issues (35%) have NO engagement whatsoever +- Many are recent (<6 months) and may just need time +- Many are 5+ years old and likely forgotten/obsolete + +## Critical Findings + +### 1. Tracking/Meta Issues + +**Issue #82** (10 years old) is a "Master List" with checkboxes tracking compiler support. This was useful historically but now creates confusion: +- 39 comments of various requests +- Acts as a catch-all for "add this compiler" requests +- Should probably be closed with pointer to proper issue templates + +### 2. "Probably Won't Happen" Issues (42 total) + +These are already flagged but remain open. Examples: +- #187 (8.9y) - "Add support for MMIX" - niche educational architecture +- #264 (8.7y) - "Add D8 JavaScript assembly" - 35 comments, out of scope +- #341 (8.5y) - "classic GCC versions" - limited value vs maintenance cost +- #514 (8.1y) - "ARM GCC 6.3.0 standard libraries missing" - old compiler version + +**Action:** These should be kindly closed with explanations. + +### 3. Stale Issues (398 total) + +**Criteria:** >2 years old AND <5 comments + +These show minimal community interest and are likely: +- Overtaken by events (e.g., new compiler versions available) +- Niche requests with no PR momentum +- Questions that were never answered + +**Sample oldest stale issues:** +- #187 (8.9y, 0 comments) - MMIX support +- #297 (8.6y, 0 comments) - GCC7 verbose-asm format +- #341 (8.5y, 0 comments) - Classic GCC versions +- #425 (8.4y, 0 comments) - libfirm/cparser + +### 4. Duplicate/Similar Requests + +**GCC versions:** 11 issues requesting various GCC versions/configurations +**Clang variants:** 9 issues for different Clang forks/versions +**MSVC versions:** 3+ issues for recent MSVC versions (could be consolidated) +**ROCm/AMD:** 3 issues about ROCm compiler versions + +These could be consolidated into tracking issues or closed as duplicates. + +### 5. Poorly Labeled Issues (412 total) + +Many issues have only generic labels like "request" or "bug" without specifics: +- No language tag (lang-c++, lang-rust, etc.) +- No area tag (ui, compiler-issue, etc.) +- No priority indication + +This makes filtering and prioritization difficult. + +## Common Themes in Titles + +**Top keywords:** +- "request" (437) - the label shows up in titles too +- "compiler" (183) +- "support" (97) +- "clang" (62) +- "library" (35) +- "msvc" (27) + +**Pattern:** Most issues are straightforward "add X compiler" or "add Y library" requests. + +## Recommendations for Phase 2 + +### Immediate Actions + +1. **Close "Probably Won't Happen" Issues (42)** + - Draft kind, clear explanation template + - Close with rationale and link to contribution docs if applicable + - Expected impact: -5% issue count + +2. **Close Ancient Zero-Comment Issues (estimate ~50-100)** + - Issues >5 years old with 0 comments and no activity + - Use "stale bot" type reasoning: "no activity, assumed no longer relevant" + - Allow 2 weeks for objections before closing + - Expected impact: -6-12% issue count + +3. **Close Obvious Duplicates (estimate ~20-30)** + - Multiple GCC/Clang version requests → consolidate or close with "use latest" + - Expected impact: -2-4% issue count + +### Medium-Term Actions + +4. **Improve Labeling (412 issues)** + - Add language-specific labels (lang-*) + - Add area labels (ui, execution, api, etc.) + - Add priority labels where clear + - This enables better filtering and assignment + +5. **Create "Good First Issue" Pipeline (~50 issues)** + - Review "help wanted" (44 issues) for suitable ones + - Look for well-defined, isolated tasks + - Add good-first-issue label and mentorship notes + +6. **Consolidate Request Tracking** + - Create wiki/doc page for "Compiler Request Guidelines" + - Explain: how to request, how to contribute, what makes requests likely + - Close #82 meta-issue with pointer to new docs + +### Long-Term Strategy + +7. **Implement Stale Bot** + - Auto-label issues >1 year old with no activity + - Auto-close after warning period if still no activity + - Keep it friendly: "seems resolved, please reopen if still relevant" + +8. **Improve Issue Templates** + - Separate templates for: compiler requests, library requests, bug reports, feature requests + - Require more details (version numbers, error messages, why needed) + - Auto-label based on template used + +9. **Regular Triage Cadence** + - Weekly review of new issues (label, prioritize, close if needed) + - Monthly review of old issues (close stale, consolidate duplicates) + - Quarterly review of "help wanted" (ensure still relevant) + +## Estimated Impact + +**Conservative cleanup estimate:** +- Close "probably-wont-happen": -42 issues +- Close ancient zero-comment: -50 issues +- Close duplicates: -20 issues +- **Total: -112 issues (13% reduction)** + +**Aggressive cleanup estimate:** +- Above plus stale >3 years: -200+ additional +- **Total: -300+ issues (35% reduction)** + +## Next Steps + +**Proposed Plan:** +1. Review sample of "probably-wont-happen" issues together +2. Draft closure message templates (kind but clear) +3. Review sample of stale issues together +4. Implement Phase 2: Systematic triage with your approval +5. Consider automation (stale bot, better templates) + +## Files Generated + +- `all-issues-raw.json` - Full issue data from GitHub +- `issues-summary.json` - Simplified format +- `full-analysis.txt` - Complete statistical analysis +- `PHASE1-FINDINGS.md` - This document diff --git a/etc/scripts/gh_tool/docs/TRIAGE-CRITERIA.md b/etc/scripts/gh_tool/docs/TRIAGE-CRITERIA.md new file mode 100644 index 000000000..522c98c26 --- /dev/null +++ b/etc/scripts/gh_tool/docs/TRIAGE-CRITERIA.md @@ -0,0 +1,271 @@ +# Compiler Explorer Issue Triage Criteria + +Based on manual review of 22+ issues (October 2025), here are the established triage patterns and decisions. + +## Quick Reference: Triage Decisions + +| Category | Keep/Close | Labels to Add | +|----------|-----------|---------------| +| Active projects (compiler/lib requests) | KEEP | help wanted | +| Abandoned upstream projects (8+ years) | CLOSE | - | +| Zero-demand features (7+ years, 0 comments) | CLOSE | - | +| External tools (already work via API) | CLOSE | - | +| Stale reminders/TODOs (6+ years) | CLOSE | - | +| Duplicates | CLOSE newest | - | +| Related but not duplicates | KEEP both | Link in comments | + +--- + +## 1. Core Principles + +### Conservative Approach +- **Age alone is NOT a proxy for value** +- Each issue needs explicit review before closing +- When in doubt, keep it open +- Look for recent interest (CppCon mentions, user questions, etc.) + +### Priority Areas +1. Close obvious duplicates +2. Close abandoned/dead projects +3. Better organize remaining issues with labels +4. Identify "help wanted" opportunities + +--- + +## 2. Compiler & Library Requests + +### KEEP if: +- āœ… Upstream project is actively maintained (check last commit date) +- āœ… Project has legitimate use cases +- āœ… Zero comments but project is real/active (just needs contributor) + +### CLOSE if: +- āŒ Upstream project is abandoned (8+ years with no activity) +- āŒ Author confirmed they don't have patches/support for newer versions +- āŒ Project was experimental and never went mainstream + +### Examples: + +**KEEP:** +- #425 (libfirm/cparser) - Active: cparser updated Jan 2025, libfirm March 2025 +- #1232 (PCL Point Cloud Library) - Active, legitimate library +- #503 (Cython) - Active project, add "help wanted" +- #341 (classic GCC versions) - User interest confirmed at CppCon + +**CLOSE:** +- #2063 (static_print GCC) - Abandoned (last commit 2017), author has no patches +- #1018 (clang-contracts) - CE already has alternative contract compilers + +--- + +## 3. Feature Requests + +### KEEP if: +- āœ… Technically feasible +- āœ… Aligns with CE's mission +- āœ… Recent interest or discussion +- āœ… "Probably-wont-happen" but PRs would be accepted + +### CLOSE if: +- āŒ Implementation complexity outweighs value +- āŒ Encourages bad practices (e.g., #797 BUILT_ON_COMPILER_EXPLORER macro) +- āŒ Tool already exists externally and works via CE's API + +### Examples: + +**KEEP:** +- #297 (-fverbose-asm filtering bug) - Real usability issue, fixable +- #1004 (verbose-asm UI button) - Related to #297, useful convenience +- #187 (MMIX) - Recent CppCon interest + +**CLOSE:** +- #547 (FXC shader compiler) - Not a good fit for CE +- #797 (BUILT_ON_COMPILER_EXPLORER macro) - Encourages bad practices +- #1203 (SIMD-Visualiser integration) - Already works externally via API + +--- + +## 4. Bugs & Issues + +### Bug Validation Process: +1. Test if bug still reproduces using Compiler Explorer MCP +2. Read ALL comments, not just the first one +3. Check if workarounds exist +4. Verify affected compiler versions still exist in CE + +### KEEP if: +- āœ… Bug still reproduces +- āœ… Affects multiple compiler versions +- āœ… No reasonable workaround exists + +### Examples: + +**KEEP:** +- #514 (ARM GCC hard float) - Tested, still fails with `-mfloat-abi=hard` on 6 ARM GCC versions + +**CLOSE:** +- Issues that were already fixed but not closed +- Issues with trivial workarounds + +--- + +## 5. Internal Tasks & Reminders + +### CLOSE if: +- āŒ 6+ year old reminder with no action taken +- āŒ Decision was implicitly made (kept the code/feature) +- āŒ No longer relevant to current codebase + +### Examples: + +**CLOSE:** +- #1357 (binutils-multi reminder) - 6.5 years old, still installed, serves a purpose +- Accidental duplicates from batch operations + +--- + +## 6. Related vs Duplicate Issues + +### Not Duplicates if: +- Issues address different aspects of the same problem +- One is prerequisite for the other +- Different implementation approaches + +### Duplicates if: +- Identical title and description +- Same request posted multiple times +- Accidental double-posts + +### Examples: + +**Related (NOT duplicates):** +- #297 (fix filter bug) + #1004 (add UI button) - Related but distinct + +**Duplicates (CLOSE):** +- #3201, #7778, #8111 - All requesting NumPy +- #4336, #6526 - Both requesting Groovy +- #3426, #5972 - Both requesting OpenBLAS +- #7601, #7602 - Accidental double-post + +--- + +## 7. Labeling Strategy + +### Add "help wanted" when: +- Valid request but maintainer doesn't have time +- Clear scope, would accept PRs +- Not marked "probably-wont-happen" + +### Keep "probably-wont-happen" when: +- Low priority but PRs would still be accepted +- Niche use case +- High complexity/low demand + +### Remove "probably-wont-happen" when: +- Recent interest or demand emerges +- Project confirmed active and relevant +- Better candidate for "help wanted" + +--- + +## 8. Label Changes Made + +### Reviewed Issues - Actions Taken: + +| Issue | Action | Labels | Reason | +|-------|--------|--------|--------| +| #264 | KEEP | Remove probably-wont-happen | CE supports interpreted languages | +| #187 | KEEP | Add help wanted | Recent CppCon interest | +| #503 | KEEP | Add help wanted | Active project, PRs welcome | +| #341 | KEEP | Add help wanted | User interest confirmed | +| #514 | KEEP | Remove probably-wont-happen | Bug still exists, affects 6 versions | +| #547 | CLOSE | - | Not a good fit | +| #797 | CLOSE | - | Encourages bad practices | +| #297 | KEEP | Add bug/usability | Filter breaks verbose-asm | +| #1004 | KEEP | Link to #297 | UI convenience, related to #297 | +| #1018 | CLOSE | - | Satisfied by alternative compilers | +| #2063 | CLOSE | - | Abandoned upstream | +| #425 | KEEP | Add help wanted | Active project | +| #668 | CLOSE | - | Zero demand, very niche | +| #1203 | CLOSE | - | Works externally already | +| #1232 | KEEP | Add help wanted | Legitimate library | +| #1357 | CLOSE | - | Stale reminder, implicitly resolved | +| #7778 | CLOSE | Duplicate of #3201 | NumPy duplicate | +| #8111 | CLOSE | Duplicate of #3201 | NumPy duplicate | +| #5972 | CLOSE | Duplicate of #3426 | OpenBLAS duplicate | +| #6526 | CLOSE | Duplicate of #4336 | Groovy duplicate | +| #7601 | CLOSE | Duplicate of #7602 | Accidental duplicate | + +--- + +## 9. Triage Process Recommendations + +### Monthly Triage Workflow: +1. **Identify duplicates** (automated similarity matching) +2. **Check upstream status** for compiler/library requests (last commit date) +3. **Test bugs** using Compiler Explorer MCP +4. **Review engagement** (comments, reactions, recent activity) +5. **Apply labels** (help wanted, good first issue, etc.) +6. **Close obvious cases** (duplicates, abandoned projects, stale reminders) + +### Tools Used: +- GitHub API for bulk data extraction +- Python scripts for similarity analysis +- Compiler Explorer MCP for live testing +- Web search for upstream project status + +--- + +## 10. Communication Templates + +### Closing Duplicates: +``` +Closing as duplicate of #XXXX which has more discussion/history. +Please follow that issue for updates. +``` + +### Closing Abandoned Projects: +``` +Closing as the upstream project appears abandoned (last commit [date]). +If the project becomes active again, please feel free to reopen or create a new issue. +``` + +### Closing External Tools: +``` +Closing as this tool already works externally using Compiler Explorer's public API. +Integration would not provide significant additional value. +See: [tool URL] +``` + +### Keeping with "help wanted": +``` +This is a valid request but requires a contributor with expertise in [area]. +Marking as "help wanted" - PRs are welcome! +``` + +--- + +## Statistics from This Triage Session + +- **Issues reviewed**: 22 +- **Issues to close**: 12 (5 duplicates + 7 other) +- **Issues to keep**: 10 +- **"help wanted" added**: 5 +- **Relationships identified**: 1 pair (#297 + #1004) + +**Impact**: +- Closed duplicates: -5 issues +- Closed abandoned/unviable: -7 issues +- Net reduction: -12 issues (~1.4% of 855 total) +- Better organized: 10 issues now have clearer status + +--- + +## Next Steps + +1. Apply label changes to reviewed issues +2. Close duplicates with appropriate comments +3. Close abandoned/stale issues with appropriate comments +4. Link related issues (#297 ↔ #1004) +5. Continue triage with next batch of issues +6. Update this document as new patterns emerge diff --git a/etc/scripts/gh_tool/pyproject.toml b/etc/scripts/gh_tool/pyproject.toml new file mode 100644 index 000000000..e39054fef --- /dev/null +++ b/etc/scripts/gh_tool/pyproject.toml @@ -0,0 +1,35 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "compiler-explorer-gh-tool" +version = "0.0.1" +description = "GitHub automation tool for Compiler Explorer" +requires-python = ">=3.12" +dependencies = [ + "click>=8.1.0", + "pytest>=8.0.0", +] + +[project.scripts] +gh_tool = "gh_tool.cli:main" + +[tool.uv] +package = true + +[tool.ruff] +line-length = 120 +target-version = "py312" + +[tool.ruff.lint] +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflake + "I", # isort + "UP", # pyupgrade +] +ignore = [ + "E501", # line length +] diff --git a/etc/scripts/gh_tool/src/gh_tool/__init__.py b/etc/scripts/gh_tool/src/gh_tool/__init__.py new file mode 100644 index 000000000..1b917703e --- /dev/null +++ b/etc/scripts/gh_tool/src/gh_tool/__init__.py @@ -0,0 +1,3 @@ +"""GitHub automation tools for Compiler Explorer.""" + +__version__ = "0.0.1" diff --git a/etc/scripts/gh_tool/src/gh_tool/cli.py b/etc/scripts/gh_tool/src/gh_tool/cli.py new file mode 100644 index 000000000..1325f8848 --- /dev/null +++ b/etc/scripts/gh_tool/src/gh_tool/cli.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 +"""CLI for GitHub automation tools for Compiler Explorer.""" + +import sys + +import click + +from gh_tool.duplicate_finder import fetch_issues, find_duplicates, generate_report + + +@click.group() +def main(): + """GitHub automation tools for Compiler Explorer.""" + pass + + +@main.command("find-duplicates") +@click.argument("output_file", type=click.Path()) +@click.option( + "--threshold", + default=0.6, + type=click.FloatRange(0, 1), + help="Similarity threshold between 0 and 1 (default: 0.6)", +) +@click.option( + "--state", + type=click.Choice(["all", "open", "closed"]), + default="open", + help="Issue state to check (default: open)", +) +@click.option( + "--min-age", + default=0, + type=int, + help="Only check issues older than N days (default: 0)", +) +@click.option( + "--limit", + default=1000, + type=int, + help="Maximum number of issues to fetch (default: 1000)", +) +@click.option( + "--repo", + default="compiler-explorer/compiler-explorer", + type=str, + help="GitHub repository in owner/repo format (default: compiler-explorer/compiler-explorer)", +) +def find_duplicates_cmd(output_file, threshold, state, min_age, limit, repo): + """Find potential duplicate issues in the compiler-explorer repository. + + OUTPUT_FILE is the path where the markdown report will be saved. + + Examples: + + \b + # Find duplicates in open issues + gh_tool find-duplicates /tmp/duplicates.md + + \b + # High confidence matches only + gh_tool find-duplicates /tmp/report.md --threshold 0.85 + + \b + # Check all issues (including closed) + gh_tool find-duplicates /tmp/all.md --state all + """ + # Fetch issues + click.echo(f"Fetching {state} issues...", err=True) + issues = fetch_issues(state, limit, repo) + + # Find duplicates + click.echo(f"Analyzing {len(issues)} issues with threshold {threshold}...", err=True) + groups = find_duplicates(issues, threshold, min_age) + + # Generate report + generate_report(groups, output_file) + click.echo(f"Found {len(groups)} potential duplicate groups", err=True) + + +if __name__ == "__main__": + main() diff --git a/etc/scripts/gh_tool/src/gh_tool/duplicate_finder.py b/etc/scripts/gh_tool/src/gh_tool/duplicate_finder.py new file mode 100755 index 000000000..72a5a636c --- /dev/null +++ b/etc/scripts/gh_tool/src/gh_tool/duplicate_finder.py @@ -0,0 +1,144 @@ +"""Find potential duplicate issues in the compiler-explorer repository using text similarity.""" + +import json +import subprocess +import sys +from datetime import datetime, timedelta, timezone +from difflib import SequenceMatcher +from typing import Any + +import click + + +def fetch_issues(state: str = "open", limit: int = 1000, repo: str = "compiler-explorer/compiler-explorer") -> list[dict[str, Any]]: + """Fetch issues from GitHub using gh CLI.""" + click.echo(f"Fetching {state} issues from {repo}...", err=True) + + cmd = [ + "gh", "issue", "list", + "--repo", repo, + "--state", state, + "--limit", str(limit), + "--json", "number,title,createdAt,updatedAt,state,labels,comments" + ] + + try: + result = subprocess.run(cmd, capture_output=True, text=True, check=True) + issues = json.loads(result.stdout) + click.echo(f"Fetched {len(issues)} issues", err=True) + return issues + except subprocess.CalledProcessError as e: + click.echo(f"Error fetching issues: {e.stderr}", err=True) + raise click.Abort() + except json.JSONDecodeError as e: + click.echo(f"Error parsing JSON: {e}", err=True) + raise click.Abort() + + +def calculate_similarity(title1: str, title2: str) -> float: + """Calculate similarity ratio between two titles using SequenceMatcher.""" + return SequenceMatcher(None, title1.lower(), title2.lower()).ratio() + + +def find_duplicates( + issues: list[dict[str, Any]], threshold: float = 0.6, min_age_days: int = 0 +) -> list[dict[str, Any]]: + """Find potential duplicate issues based on title similarity.""" + # Filter issues by age if requested + if min_age_days > 0: + cutoff_date = datetime.now(timezone.utc) - timedelta(days=min_age_days) + issues = [ + issue for issue in issues + if datetime.fromisoformat(issue["createdAt"].replace("Z", "+00:00")) < cutoff_date + ] + click.echo(f"Filtered to {len(issues)} issues older than {min_age_days} days", err=True) + + # Find similar pairs + duplicates: list[dict[str, Any]] = [] + seen: set[tuple[int, int]] = set() + total_comparisons = len(issues) * (len(issues) - 1) // 2 + + click.echo(f"Comparing {len(issues)} issues ({total_comparisons:,} comparisons)...", err=True) + + with click.progressbar( + length=total_comparisons, label="Finding duplicates", file=sys.stderr + ) as bar: + for i, issue1 in enumerate(issues): + for j, issue2 in enumerate(issues[i + 1 :], start=i + 1): + bar.update(1) + + # Skip if already grouped + pair = tuple(sorted([issue1["number"], issue2["number"]])) + if pair in seen: + continue + + similarity = calculate_similarity(issue1["title"], issue2["title"]) + + if similarity >= threshold: + duplicates.append({"similarity": similarity, "issues": [issue1, issue2]}) + seen.add(pair) + + # Group similar issues together + groups: list[dict[str, Any]] = [] + + for dup in sorted(duplicates, key=lambda x: x["similarity"], reverse=True): + issue1, issue2 = dup["issues"] + num1, num2 = issue1["number"], issue2["number"] + + # Find existing group containing either issue + found_group = None + for group in groups: + if num1 in [i["number"] for i in group["issues"]] or num2 in [i["number"] for i in group["issues"]]: + found_group = group + break + + if found_group: + # Add to existing group if not already there + for issue in [issue1, issue2]: + if issue["number"] not in [i["number"] for i in found_group["issues"]]: + found_group["issues"].append(issue) + found_group["max_similarity"] = max(found_group["max_similarity"], dup["similarity"]) + else: + # Create new group + groups.append({ + "issues": [issue1, issue2], + "max_similarity": dup["similarity"] + }) + + return groups + + +def format_issue(issue: dict[str, Any]) -> str: + """Format issue for display.""" + labels = ", ".join(l["name"] for l in issue["labels"]) if issue["labels"] else "no labels" + created = issue["createdAt"][:10] + state = issue["state"] + comment_count = len(issue.get("comments", [])) + + return f"- #{issue['number']} {issue['title']} ({comment_count} comments, {state}, created {created})" + + +def generate_report(groups: list[dict[str, Any]], output_file: str) -> None: + """Generate markdown report of duplicate groups.""" + output: list[str] = [] + output.append("# Potential Duplicate Issues\n") + + if not groups: + output.append("No potential duplicates found.\n") + else: + output.append(f"Found {len(groups)} potential duplicate groups:\n") + + for idx, group in enumerate(sorted(groups, key=lambda x: x["max_similarity"], reverse=True), 1): + similarity_pct = int(group["max_similarity"] * 100) + output.append(f"## Group {idx} ({similarity_pct}% similar)\n") + + for issue in sorted(group["issues"], key=lambda x: x["createdAt"]): + output.append(format_issue(issue) + "\n") + + output.append("\n") + + report = "\n".join(output) + + with open(output_file, "w") as f: + f.write(report) + click.echo(f"Report saved to {output_file}", err=True) diff --git a/etc/scripts/gh_tool/tests/test_duplicate_finder.py b/etc/scripts/gh_tool/tests/test_duplicate_finder.py new file mode 100644 index 000000000..18086d74a --- /dev/null +++ b/etc/scripts/gh_tool/tests/test_duplicate_finder.py @@ -0,0 +1,192 @@ +# Copyright (c) 2025, Compiler Explorer Authors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import tempfile +from datetime import datetime, timedelta, timezone +from pathlib import Path + +import pytest + +from gh_tool.duplicate_finder import calculate_similarity, find_duplicates, generate_report + + +def make_issue(number, title, created_at=None, comments=None): + """Helper to create test issue data.""" + if created_at is None: + created_at = datetime.now(timezone.utc).isoformat() + if comments is None: + comments = [] + + return { + "number": number, + "title": title, + "createdAt": created_at, + "updatedAt": created_at, + "state": "open", + "labels": [], + "comments": comments, + } + + +class TestCalculateSimilarity: + @pytest.mark.parametrize( + "title1,title2,expected_min,expected_max", + [ + # Identical strings + ("Add GCC 13", "Add GCC 13", 1.0, 1.0), + # Case insensitive + ("Add GCC 13", "add gcc 13", 1.0, 1.0), + # Completely different + ("Add GCC 13", "Python bug", 0.0, 0.3), + # Similar titles with different case + ("[LIB REQUEST] numpy", "[LIB REQUEST] NumPy", 0.9, 1.0), + # Partial similarity + ("Add GCC 13 support", "Add GCC 14 support", 0.7, 1.0), + # Different request types + ("[COMPILER REQUEST] foo", "[LIB REQUEST] foo", 0.5, 0.8), + ], + ) + def test_similarity_calculation(self, title1, title2, expected_min, expected_max): + similarity = calculate_similarity(title1, title2) + assert expected_min <= similarity <= expected_max + + +class TestFindDuplicates: + def test_no_duplicates(self): + issues = [ + make_issue(1, "Add GCC 13"), + make_issue(2, "Fix Python bug"), + make_issue(3, "Update documentation"), + ] + groups = find_duplicates(issues, threshold=0.6) + assert len(groups) == 0 + + def test_simple_duplicate_pair(self): + issues = [ + make_issue(1, "Add NumPy library"), + make_issue(2, "Add numpy library"), + ] + groups = find_duplicates(issues, threshold=0.8) + assert len(groups) == 1 + assert len(groups[0]["issues"]) == 2 + assert groups[0]["issues"][0]["number"] in [1, 2] + assert groups[0]["issues"][1]["number"] in [1, 2] + + def test_multiple_duplicate_groups(self): + issues = [ + make_issue(1, "Add GCC 13"), + make_issue(2, "Add gcc 13"), + make_issue(3, "Add Clang 17"), + make_issue(4, "Add clang 17"), + make_issue(5, "Fix bug"), + ] + groups = find_duplicates(issues, threshold=0.85) + assert len(groups) == 2 + + def test_transitive_grouping(self): + # If A~B and B~C, they should all be in one group + issues = [ + make_issue(1, "Add NumPy"), + make_issue(2, "Add numpy"), + make_issue(3, "Add NumPy library"), + ] + groups = find_duplicates(issues, threshold=0.7) + # Should be grouped together transitively + assert len(groups) >= 1 + # At least one group should have all 3 issues + max_group_size = max(len(g["issues"]) for g in groups) + assert max_group_size >= 2 + + def test_age_filtering(self): + now = datetime.now(timezone.utc) + old_date = (now - timedelta(days=100)).isoformat() + recent_date = (now - timedelta(days=5)).isoformat() + + issues = [ + make_issue(1, "Add NumPy", created_at=old_date), + make_issue(2, "Add numpy", created_at=recent_date), + ] + + # Filter to only old issues (>30 days) + groups = find_duplicates(issues, threshold=0.8, min_age_days=30) + # Should only have one issue in the comparison, so no duplicates found + assert len(groups) == 0 + + # No age filter should find the duplicate + groups = find_duplicates(issues, threshold=0.8, min_age_days=0) + assert len(groups) == 1 + + def test_threshold_sensitivity(self): + issues = [ + make_issue(1, "Add GCC 13 compiler"), + make_issue(2, "Add GCC 14 compiler"), + ] + + # Low threshold should find similarity + groups = find_duplicates(issues, threshold=0.6) + assert len(groups) == 1 + + # Very high threshold should not + groups = find_duplicates(issues, threshold=0.99) + assert len(groups) == 0 + + +class TestGenerateReport: + def test_empty_report(self): + with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.md') as f: + output_file = f.name + + try: + generate_report([], output_file) + content = Path(output_file).read_text() + assert "No potential duplicates found" in content + finally: + Path(output_file).unlink() + + def test_report_with_groups(self): + groups = [ + { + "issues": [ + make_issue(1, "Add NumPy", created_at="2020-01-01T00:00:00Z"), + make_issue(2, "Add numpy", created_at="2020-01-02T00:00:00Z"), + ], + "max_similarity": 0.95, + } + ] + + with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.md') as f: + output_file = f.name + + try: + generate_report(groups, output_file) + content = Path(output_file).read_text() + + assert "# Potential Duplicate Issues" in content + assert "Found 1 potential duplicate groups" in content + assert "## Group 1 (95% similar)" in content + assert "#1" in content + assert "#2" in content + assert "numpy" in content.lower() + finally: + Path(output_file).unlink() From efab7336b2d4508ae1856cbb422e85169dc7bf96 Mon Sep 17 00:00:00 2001 From: aneshlya Date: Tue, 7 Oct 2025 12:55:38 -0700 Subject: [PATCH 4/4] Add ISPC v1.28.2 (#8167) This PR adds support of recently released ISPC 1.28.2 and updates a default snippet for it. Related infra change: https://github.com/compiler-explorer/infra/pull/1857 --- etc/config/ispc.amazon.properties | 7 +++++-- examples/ispc/default.ispc | 6 +----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/etc/config/ispc.amazon.properties b/etc/config/ispc.amazon.properties index 714440a47..20c15cfae 100644 --- a/etc/config/ispc.amazon.properties +++ b/etc/config/ispc.amazon.properties @@ -1,10 +1,13 @@ compilers=&ispc -defaultCompiler=ispc1281 +defaultCompiler=ispc1282 objdumper=/opt/compiler-explorer/gcc-14.2.0/bin/objdump -group.ispc.compilers=ispc1281:ispc1280:ispc1270:ispc1260:ispc1253:ispc1250:ispc1240:ispc1230:ispc1220:ispc1210:ispc1200:ispc1190:ispc1180:ispc1170:ispc1161:ispc1160:ispc1150:ispc1141:ispc1140:ispc1130:ispc1120:ispc1110:ispc1100:ispc192:ispc191:ispc-trunk +group.ispc.compilers=ispc1282:ispc1281:ispc1280:ispc1270:ispc1260:ispc1253:ispc1250:ispc1240:ispc1230:ispc1220:ispc1210:ispc1200:ispc1190:ispc1180:ispc1170:ispc1161:ispc1160:ispc1150:ispc1141:ispc1140:ispc1130:ispc1120:ispc1110:ispc1100:ispc192:ispc191:ispc-trunk group.ispc.isSemVer=true group.ispc.baseName=ispc +compiler.ispc1282.exe=/opt/compiler-explorer/ispc-1.28.2/bin/ispc +compiler.ispc1282.semver=1.28.2 +compiler.ispc1282.executableLinker=/opt/compiler-explorer/gcc-14.2.0/bin/gcc compiler.ispc1281.exe=/opt/compiler-explorer/ispc-1.28.1/bin/ispc compiler.ispc1281.semver=1.28.1 compiler.ispc1281.executableLinker=/opt/compiler-explorer/gcc-14.2.0/bin/gcc diff --git a/examples/ispc/default.ispc b/examples/ispc/default.ispc index 8d8ec61ac..cef0c92c6 100644 --- a/examples/ispc/default.ispc +++ b/examples/ispc/default.ispc @@ -1,10 +1,6 @@ // Type your code here, or load an example. varying int square_even(varying int num) { - if (num % 2 == 0) { - return num * num; - } else { - return num; - } + return (num % 2 == 0)? num * num: num; } // Uncomment this if you would like to execute the code