Skip to content

Commit

Permalink
ci: package problem matchers as composite actions
Browse files Browse the repository at this point in the history
  • Loading branch information
amezin committed Feb 19, 2025
1 parent c82387b commit e256856
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 19 deletions.
22 changes: 22 additions & 0 deletions .github/actions/eslint-stylish-problem-matcher/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: 2025 Aleksandr Mezin <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

name: ESLint "stylish" problem matcher
description: Enable/disable ESLint "stylish" problem matcher
inputs:
enable:
description: Enable if `true`, disable if `false`
required: false
default: 'true'

runs:
using: composite
steps:
- run: echo "::add-matcher::$GITHUB_ACTION_PATH/eslint-stylish.json"
shell: sh
if: fromJSON(inputs.enable)

- run: echo "::remove-matcher owner=eslint-stylish::"
shell: sh
if: '!fromJSON(inputs.enable)'
22 changes: 22 additions & 0 deletions .github/actions/flake8-problem-matcher/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: 2025 Aleksandr Mezin <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

name: flake8 problem matcher
description: Enable/disable flake8 problem matcher
inputs:
enable:
description: Enable if `true`, disable if `false`
required: false
default: 'true'

runs:
using: composite
steps:
- run: echo "::add-matcher::$GITHUB_ACTION_PATH/flake8.json"
shell: sh
if: fromJSON(inputs.enable)

- run: echo "::remove-matcher owner=flake8::"
shell: sh
if: '!fromJSON(inputs.enable)'
File renamed without changes.
24 changes: 24 additions & 0 deletions .github/actions/generic-problem-matcher/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: 2025 Aleksandr Mezin <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

name: Generic problem matcher
description: Enable/disable generic problem matcher
inputs:
enable:
description: Enable if `true`, disable if `false`
required: false
default: 'true'

runs:
using: composite
steps:
- run: echo "::add-matcher::$GITHUB_ACTION_PATH/generic.json"
shell: sh
if: fromJSON(inputs.enable)

- run: |
echo "::remove-matcher owner=generic::"
echo "::remove-matcher owner=generic-nolocation::"
shell: sh
if: '!fromJSON(inputs.enable)'
File renamed without changes.
22 changes: 22 additions & 0 deletions .github/actions/gettext-stats-matcher/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: 2025 Aleksandr Mezin <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

name: msgfmt statistics problem matcher
description: Enable/disable msgfmt statistics problem matcher
inputs:
enable:
description: Enable if `true`, disable if `false`
required: false
default: 'true'

runs:
using: composite
steps:
- run: echo "::add-matcher::$GITHUB_ACTION_PATH/gettext-stats.json"
shell: sh
if: fromJSON(inputs.enable)

- run: echo "::remove-matcher owner=gettext-stats::"
shell: sh
if: '!fromJSON(inputs.enable)'
File renamed without changes.
26 changes: 16 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:

- name: Enable eslint error matcher
id: enable_eslint_errors
run: echo "::add-matcher::.github/problem-matchers/eslint-stylish.json"
uses: ./.github/actions/eslint-stylish-problem-matcher
if: ${{ always() && steps.checkout.conclusion == 'success' }}

- name: Lint JS code
Expand All @@ -77,12 +77,14 @@ jobs:
if: ${{ always() && steps.npm.conclusion == 'success' }}

- name: Disable eslint error matcher
run: echo "::remove-matcher owner=eslint-stylish::"
uses: ./.github/actions/eslint-stylish-problem-matcher
with:
enable: false
if: ${{ always() && steps.enable_eslint_errors.outcome == 'success' }}

- name: Enable flake8 error matcher
id: enable_flake8_errors
run: echo "::add-matcher::.github/problem-matchers/flake8.json"
uses: ./.github/actions/flake8-problem-matcher
if: ${{ always() && steps.checkout.conclusion == 'success' }}

- name: Lint Python test code
Expand All @@ -92,7 +94,9 @@ jobs:
if: ${{ always() && steps.checkout.conclusion == 'success' }}

- name: Disable flake8 error matcher
run: echo "::remove-matcher owner=flake8::"
uses: ./.github/actions/flake8-problem-matcher
with:
enable: false
if: ${{ always() && steps.enable_flake8_errors.outcome == 'success' }}

- name: Check meson.build formatting
Expand Down Expand Up @@ -166,7 +170,7 @@ jobs:

- name: Enable generic error matcher
id: enable_generic_errors
run: echo "::add-matcher::.github/problem-matchers/generic.json"
uses: ./.github/actions/generic-problem-matcher

- name: Install JS dependencies
id: npm
Expand Down Expand Up @@ -201,14 +205,14 @@ jobs:
if: ${{ always() && steps.pack.conclusion == 'success' }}

- name: Disable generic error matcher
run: |
echo "::remove-matcher owner=generic::"
echo "::remove-matcher owner=generic-nolocation::"
uses: ./.github/actions/generic-problem-matcher
with:
enable: false
if: ${{ always() && steps.enable_generic_errors.outcome == 'success' }}

- name: Enable eslint error matcher
id: enable_eslint_errors
run: echo "::add-matcher::.github/problem-matchers/eslint-stylish.json"
uses: ./.github/actions/eslint-stylish-problem-matcher
if: ${{ always() && steps.pack.conclusion == 'success' }}

- name: Run eslint on generated code
Expand All @@ -217,7 +221,9 @@ jobs:
if: ${{ always() && steps.pack.conclusion == 'success' }}

- name: Disable eslint error matcher
run: echo "::remove-matcher owner=eslint-stylish::"
uses: ./.github/actions/eslint-stylish-problem-matcher
with:
enable: false
if: ${{ always() && steps.enable_eslint_errors.outcome == 'success' }}

- name: Check REUSE compliance of generated package
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/check-po.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ jobs:
- run: git config --global --replace-all safe.directory "$GITHUB_WORKSPACE"

- name: Enable generic problem matcher
run: echo "::add-matcher::.github/problem-matchers/generic.json"
uses: ./.github/actions/generic-problem-matcher

- name: Enable gettext stats problem matcher
run: echo "::add-matcher::.github/problem-matchers/gettext-stats.json"
id: enable_gettext_stats
uses: ./.github/actions/gettext-stats-matcher

- name: Compile translation
run: |
Expand All @@ -64,7 +65,10 @@ jobs:
shell: bash

- name: Disable gettext stats problem matcher
run: echo "::remove-matcher owner=gettext-stats::"
uses: ./.github/actions/gettext-stats-matcher
with:
enable: false
if: ${{ always() && steps.enable_gettext_stats.conclusion == 'success' }}

- name: Ensure .po file is in sync with .pot
run: msgcmp --use-untranslated --use-fuzzy locale/${{ matrix.lang }}.po locale/*.pot
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- run: git config --global --replace-all safe.directory "$GITHUB_WORKSPACE"

- name: Enable generic error matcher
run: echo "::add-matcher::.github/problem-matchers/generic.json"
uses: ./.github/actions/generic-problem-matcher

- name: Install JS dependencies
id: npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- run: git config --global --replace-all safe.directory "$GITHUB_WORKSPACE"

- name: Enable generic error matcher
run: echo "::add-matcher::.github/problem-matchers/generic.json"
uses: ./.github/actions/generic-problem-matcher

- name: Prepare build directory
run: .github/faketty.sh meson setup build
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
uses: actions/checkout@v4

- name: Enable generic error matcher
run: echo "::add-matcher::.github/problem-matchers/generic.json"
uses: ./.github/actions/generic-problem-matcher

- run: git config --global --replace-all safe.directory "$GITHUB_WORKSPACE"

Expand Down Expand Up @@ -102,9 +102,9 @@ jobs:
tox -vv --notest --sitepackages -e pytest
- name: Disable generic error matcher
run: |
echo "::remove-matcher owner=generic::"
echo "::remove-matcher owner=generic-nolocation::"
uses: ./.github/actions/generic-problem-matcher
with:
enable: false

- name: Run tests
run: >-
Expand Down

0 comments on commit e256856

Please sign in to comment.