diff --git a/.github/problem-matchers/README.md b/.github/problem-matchers/README.md new file mode 100644 index 00000000000..93dd1600356 --- /dev/null +++ b/.github/problem-matchers/README.md @@ -0,0 +1,43 @@ +# 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 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) + +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) + +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..0271692192e --- /dev/null +++ b/.github/problem-matchers/mypy.json @@ -0,0 +1,19 @@ +{ + "problemMatcher": [ + { + "owner": "mypy", + "severity": "error", + "pattern": [ + { + "regexp": "^([^:]*):(\\d+):(?:(\\d+):)?\\s(error|warning): (.*?)(?: \\[(\\S+)\\])?$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5, + "code": 6 + } + ] + } + ] +} 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/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 + } + ] + } + ] +} 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 + } + ] + } + ] +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d416989b3d..1ca42951a34 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: @@ -94,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: @@ -109,6 +115,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 +159,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: @@ -166,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: @@ -197,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 @@ -229,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: @@ -324,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 @@ -352,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: @@ -375,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 @@ -396,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