From 4b5479cc7b52227895ada744af385c2f938c8cdb Mon Sep 17 00:00:00 2001 From: Michael Hucka Date: Tue, 4 Mar 2025 15:44:16 -0800 Subject: [PATCH 1/6] Add problem matcher configurations --- .github/problem-matchers/README.md | 35 ++++++++++++++++++++++++ .github/problem-matchers/black.json | 15 ++++++++++ .github/problem-matchers/mypy.json | 16 +++++++++++ .github/problem-matchers/pylint.json | 32 ++++++++++++++++++++++ .github/problem-matchers/shellcheck.json | 24 ++++++++++++++++ .github/problem-matchers/yamllint.json | 22 +++++++++++++++ 6 files changed, 144 insertions(+) create mode 100644 .github/problem-matchers/README.md create mode 100644 .github/problem-matchers/black.json create mode 100644 .github/problem-matchers/mypy.json create mode 100644 .github/problem-matchers/pylint.json create mode 100644 .github/problem-matchers/shellcheck.json create mode 100644 .github/problem-matchers/yamllint.json diff --git a/.github/problem-matchers/README.md b/.github/problem-matchers/README.md new file mode 100644 index 00000000000..986510da9a2 --- /dev/null +++ b/.github/problem-matchers/README.md @@ -0,0 +1,35 @@ +# Problem Matchers + +GitHub [Problem +Matchers](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md) +are a mechanism that enable workflow steps to scan the outputs of GitHub +Actions for regex patterns and automatically write annotations in the workflow +summary page. Using Problem Matchers allows information to be displayed more +prominently in the GitHub user interface. + +This directory contains Problem Matchers used by the GitHub Actions workflows +in the [`workflows`](./workflows) subdirectory. + +## Original sources + +The following problem matcher JSON files found in this directory were copied +from the [Home Assistant](https://github.com/home-assistant/core) project on +GitHub. The Home Assistant project is licensed under the Apache 2.0 open-source +license. The version of the files at the time they were copied was 2025.1.2. + +- [`pylint.json`](https://github.com/home-assistant/core/blob/dev/.github/workflows/matchers/pylint.json) +- [`yamllint.json`](https://github.com/home-assistant/core/blob/dev/.github/workflows/matchers/yamllint.json) +- [`mypy.json`](https://github.com/home-assistant/core/blob/dev/.github/workflows/matchers/pypy.json) + +The following problem matcher for Black came from a fork of the +[MLflow](https://github.com/mlflow/mlflow) project by user Sumanth077 on GitHub. +The MLflow project is licensed under the Apache 2.0 open-source license. The +version of the file copied was dated 2022-05-29. + +- [`black.json`](https://github.com/Sumanth077/mlflow/blob/problem-matcher-for-black/.github/workflows/matchers/black.json) + +The Shellcheck problem matcher JSON file came from the +[shellcheck-problem-matchers](uhttps://github.com/lumaxis/shellcheck-problem-matchers) +repository (copied 2025-02-26, version v2.1.0). + +- [`shellcheck-tty.json`](https://github.com/lumaxis/shellcheck-problem-matchers/blob/main/.github/shellcheck-tty.json) diff --git a/.github/problem-matchers/black.json b/.github/problem-matchers/black.json new file mode 100644 index 00000000000..605f10c2706 --- /dev/null +++ b/.github/problem-matchers/black.json @@ -0,0 +1,15 @@ +{ + "problemMatcher": [ + { + "owner": "black", + "severity": "error", + "pattern": [ + { + "regexp": "^(would reformat) (.+)$", + "file": 2, + "message": 1 + } + ] + } + ] +} diff --git a/.github/problem-matchers/mypy.json b/.github/problem-matchers/mypy.json new file mode 100644 index 00000000000..f048fce5289 --- /dev/null +++ b/.github/problem-matchers/mypy.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "mypy", + "pattern": [ + { + "regexp": "^(.+):(\\d+):\\s(error|warning):\\s(.+)$", + "file": 1, + "line": 2, + "severity": 3, + "message": 4 + } + ] + } + ] +} diff --git a/.github/problem-matchers/pylint.json b/.github/problem-matchers/pylint.json new file mode 100644 index 00000000000..5624ca695c4 --- /dev/null +++ b/.github/problem-matchers/pylint.json @@ -0,0 +1,32 @@ +{ + "problemMatcher": [ + { + "owner": "pylint-error", + "severity": "error", + "pattern": [ + { + "regexp": "^(.+):(\\d+):(\\d+):\\s(([EF]\\d{4}):\\s.+)$", + "file": 1, + "line": 2, + "column": 3, + "message": 4, + "code": 5 + } + ] + }, + { + "owner": "pylint-warning", + "severity": "warning", + "pattern": [ + { + "regexp": "^(.+):(\\d+):(\\d+):\\s(([CRW]\\d{4}):\\s.+)$", + "file": 1, + "line": 2, + "column": 3, + "message": 4, + "code": 5 + } + ] + } + ] +} diff --git a/.github/problem-matchers/shellcheck.json b/.github/problem-matchers/shellcheck.json new file mode 100644 index 00000000000..aedb9ecf50e --- /dev/null +++ b/.github/problem-matchers/shellcheck.json @@ -0,0 +1,24 @@ +{ + "problemMatcher": [ + { + "owner": "shellcheck", + "pattern": [ + { + "regexp": "^In\\s(.+)\\sline\\s(\\d+):$", + "file": 1, + "line": 2 + }, + { + "regexp": ".*" + }, + { + "regexp": "SC(\\d+)(\\s\\((note|warning|error)\\))?:\\s(.+)$", + "code": 1, + "severity": 3, + "message": 4, + "loop": true + } + ] + } + ] +} diff --git a/.github/problem-matchers/yamllint.json b/.github/problem-matchers/yamllint.json new file mode 100644 index 00000000000..ab9449dd77f --- /dev/null +++ b/.github/problem-matchers/yamllint.json @@ -0,0 +1,22 @@ +{ + "problemMatcher": [ + { + "owner": "yamllint", + "pattern": [ + { + "regexp": "^(.*\\.ya?ml)$", + "file": 1 + }, + { + "regexp": "^\\s{2}(\\d+):(\\d+)\\s+(error|warning)\\s+(.*?)\\s+\\((.*)\\)$", + "line": 1, + "column": 2, + "severity": 3, + "message": 4, + "code": 5, + "loop": true + } + ] + } + ] +} From 96ee166751babb05100595b17ffe86b9073470c8 Mon Sep 17 00:00:00 2001 From: Michael Hucka Date: Tue, 4 Mar 2025 15:48:19 -0800 Subject: [PATCH 2/6] Hook in problem matchers --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d416989b3d..c26c3dbbef0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,6 +62,8 @@ jobs: architecture: 'x64' - name: Install dependencies run: pip install -r dev_tools/requirements/deps/format.txt + - name: Set up problem matcher for Black output + run: echo '::add-matcher::.github/problem-matchers/black.json' - name: Format run: check/format-incremental mypy: @@ -77,6 +79,8 @@ jobs: architecture: 'x64' - name: Install mypy run: pip install -r dev_tools/requirements/mypy.env.txt + - name: Set up problem matcher for Mypy output + run: echo '::add-matcher::.github/problem-matchers/mypy.json' - name: Type check run: check/mypy changed_files: @@ -109,6 +113,8 @@ jobs: architecture: 'x64' - name: Install pylint run: pip install -r dev_tools/requirements/pylint.env.txt + - name: Set up problem matcher for Pylint output + run: echo '::add-matcher::.github/problem-matchers/pylint.json' - name: Display version run: check/pylint --version - name: Lint @@ -151,6 +157,8 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 with: fetch-depth: 0 + - name: Set up problem matcher for Shellcheck output + run: echo '::add-matcher::.github/problem-matchers/shellcheck.json' - name: Run shellcheck run: check/shellcheck isolated-modules: From ebb6a2aa4869eb44d89fc3a507f81621d0ed009d Mon Sep 17 00:00:00 2001 From: Michael Hucka Date: Fri, 7 Mar 2025 13:47:53 -0800 Subject: [PATCH 3/6] Add a problem matcher for pytest --- .github/problem-matchers/pytest.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/problem-matchers/pytest.json diff --git a/.github/problem-matchers/pytest.json b/.github/problem-matchers/pytest.json new file mode 100644 index 00000000000..f6bbfba32e9 --- /dev/null +++ b/.github/problem-matchers/pytest.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "pytest", + "severity": "error", + "pattern": [ + { + "regexp": "^(\\S+):(\\d+): (.*)$", + "file": 1, + "line": 2, + "message": 3 + } + ] + } + ] +} From b3bd850e243bb3a97999918216daeeecff2e0c66 Mon Sep 17 00:00:00 2001 From: Michael Hucka Date: Fri, 7 Mar 2025 13:48:09 -0800 Subject: [PATCH 4/6] Replace Mypy problem matcher with a better one --- .github/problem-matchers/mypy.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/problem-matchers/mypy.json b/.github/problem-matchers/mypy.json index f048fce5289..0271692192e 100644 --- a/.github/problem-matchers/mypy.json +++ b/.github/problem-matchers/mypy.json @@ -2,13 +2,16 @@ "problemMatcher": [ { "owner": "mypy", + "severity": "error", "pattern": [ { - "regexp": "^(.+):(\\d+):\\s(error|warning):\\s(.+)$", + "regexp": "^([^:]*):(\\d+):(?:(\\d+):)?\\s(error|warning): (.*?)(?: \\[(\\S+)\\])?$", "file": 1, "line": 2, - "severity": 3, - "message": 4 + "column": 3, + "severity": 4, + "message": 5, + "code": 6 } ] } From 91f5c10ad47fc18a2b331f9845ff822a8da33df8 Mon Sep 17 00:00:00 2001 From: Michael Hucka Date: Fri, 7 Mar 2025 13:48:32 -0800 Subject: [PATCH 5/6] Hook in the Pytest problem matcher --- .github/workflows/ci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c26c3dbbef0..1ca42951a34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,6 +98,8 @@ jobs: architecture: 'x64' - name: Install changed files test dependencies run: dev_tools/conf/pip-install-minimal-for-pytest-changed-files.sh + - name: Set up problem matcher for Pytest output + run: echo '::add-matcher::.github/problem-matchers/pytest.json' - name: Changed files test run: check/pytest-changed-files -n auto lint: @@ -174,6 +176,8 @@ jobs: architecture: 'x64' - name: Install dependencies run: pip install -r dev_tools/requirements/isolated-base.env.txt + - name: Set up problem matcher for Pytest output + run: echo '::add-matcher::.github/problem-matchers/pytest.json' - name: Test each module in isolation run: pytest -n auto --enable-slow-tests dev_tools/packaging/isolated_packages_test.py pytest: @@ -205,6 +209,8 @@ jobs: pip install --upgrade --upgrade-strategy eager -r dev_tools/requirements/dev.env.txt - name: Run Quil dependencies run: docker compose -f cirq-rigetti/docker-compose.test.yaml up -d + - name: Set up problem matcher for Pytest output + run: echo '::add-matcher::.github/problem-matchers/pytest.json' - name: Pytest check run: check/pytest -n auto --durations=20 --ignore=cirq-core/cirq/contrib --rigetti-integration - name: Stop Quil dependencies @@ -237,6 +243,8 @@ jobs: run: | pip install wheel pip install --upgrade --upgrade-strategy eager -r dev_tools/requirements/dev-np2.env.txt + - name: Set up problem matcher for Pytest output + run: echo '::add-matcher::.github/problem-matchers/pytest.json' - name: Pytest check run: check/pytest -n auto --warn-numpy-data-promotion --durations=20 --ignore=cirq-rigetti pip-compile: @@ -332,6 +340,8 @@ jobs: run: | pip install wheel pip install --upgrade --upgrade-strategy eager -r dev_tools/requirements/no-contrib.env.txt + - name: Set up problem matcher for Pytest output + run: echo '::add-matcher::.github/problem-matchers/pytest.json' - name: Pytest Windows run: | source dev_tools/pypath @@ -360,6 +370,8 @@ jobs: run: | pip install wheel pip install --upgrade --upgrade-strategy eager -r dev_tools/requirements/no-contrib.env.txt + - name: Set up problem matcher for Pytest output + run: echo '::add-matcher::.github/problem-matchers/pytest.json' - name: Pytest check run: check/pytest -n auto --durations=20 --ignore=cirq-core/cirq/contrib notebooks-stable: @@ -383,6 +395,8 @@ jobs: architecture: 'x64' - name: Install requirements run: pip install -r dev_tools/requirements/isolated-base.env.txt + - name: Set up problem matcher for Pytest output + run: echo '::add-matcher::.github/problem-matchers/pytest.json' - name: Notebook tests run: check/pytest -n auto -m slow dev_tools/notebooks/isolated_notebook_test.py -k ${{matrix.partition}} - name: Persist the outputs @@ -404,6 +418,8 @@ jobs: architecture: 'x64' - name: Install requirements run: pip install -r dev_tools/requirements/notebooks.env.txt + - name: Set up problem matcher for Pytest output + run: echo '::add-matcher::.github/problem-matchers/pytest.json' - name: Notebook tests run: check/pytest -n auto -m slow dev_tools/notebooks/notebook_test.py - name: Persist the outputs From 4fcb7e62354034cef12297e4602aa17a41c10d7f Mon Sep 17 00:00:00 2001 From: Michael Hucka Date: Fri, 7 Mar 2025 13:48:58 -0800 Subject: [PATCH 6/6] Acknowledge more problem matcher origins --- .github/problem-matchers/README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/problem-matchers/README.md b/.github/problem-matchers/README.md index 986510da9a2..93dd1600356 100644 --- a/.github/problem-matchers/README.md +++ b/.github/problem-matchers/README.md @@ -12,24 +12,32 @@ in the [`workflows`](./workflows) subdirectory. ## Original sources -The following problem matcher JSON files found in this directory were copied +The Pylint and YAML file problem matchers found in this directory were copied from the [Home Assistant](https://github.com/home-assistant/core) project on GitHub. The Home Assistant project is licensed under the Apache 2.0 open-source license. The version of the files at the time they were copied was 2025.1.2. -- [`pylint.json`](https://github.com/home-assistant/core/blob/dev/.github/workflows/matchers/pylint.json) -- [`yamllint.json`](https://github.com/home-assistant/core/blob/dev/.github/workflows/matchers/yamllint.json) -- [`mypy.json`](https://github.com/home-assistant/core/blob/dev/.github/workflows/matchers/pypy.json) +- [`pylint.json`](https://github.com/home-assistant/core/blob/dev/.github/workflows/matchers/pylint.json) +- [`yamllint.json`](https://github.com/home-assistant/core/blob/dev/.github/workflows/matchers/yamllint.json) + +The Mypy and Pytest problem matchers files originally came from the +[gh-problem-matcher-wrap](https://github.com/liskin/gh-problem-matcher-wrap/tree/master/problem-matchers) +repository (copied 2025-03-04, version 3.0.0), and were subsequently modified by +Michael Hucka. The original JSON files are Copyright © 2020 Tomáš Janoušek and +made available under the terms of the MIT license. + +- [`mypy.json`](https://github.com/liskin/gh-problem-matcher-wrap/blob/master/problem-matchers/mypy.json) +- [`pytest.json`](https://github.com/liskin/gh-problem-matcher-wrap/blob/master/problem-matchers/pytest.json) The following problem matcher for Black came from a fork of the [MLflow](https://github.com/mlflow/mlflow) project by user Sumanth077 on GitHub. The MLflow project is licensed under the Apache 2.0 open-source license. The version of the file copied was dated 2022-05-29. -- [`black.json`](https://github.com/Sumanth077/mlflow/blob/problem-matcher-for-black/.github/workflows/matchers/black.json) +- [`black.json`](https://github.com/Sumanth077/mlflow/blob/problem-matcher-for-black/.github/workflows/matchers/black.json) The Shellcheck problem matcher JSON file came from the [shellcheck-problem-matchers](uhttps://github.com/lumaxis/shellcheck-problem-matchers) repository (copied 2025-02-26, version v2.1.0). -- [`shellcheck-tty.json`](https://github.com/lumaxis/shellcheck-problem-matchers/blob/main/.github/shellcheck-tty.json) +- [`shellcheck-tty.json`](https://github.com/lumaxis/shellcheck-problem-matchers/blob/main/.github/shellcheck-tty.json)