name: Problem Matchers
on:
  push:
    paths:
      - 'scripts/generate-actionlint-matcher/*.js'
      - 'testdata/examples/*.out'
      - 'testdata/err/*.out'
    branches:
      - main
    tags-ignore:
      - '*'
  workflow_dispatch:

jobs:
  matcher-test:
    name: Test generate-actionlint-matcher
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-go@v6
        with:
          go-version: '1.26'
          check-latest: true
      - uses: actions/setup-node@v6
        with:
          node-version: "lts/*"
          cache: npm
          cache-dependency-path: ./playground/package-lock.json
      - name: Update test data
        run: make ./scripts/generate-actionlint-matcher/test/* SKIP_GO_GENERATE=true
      - name: Test actionlint-matcher.json
        run: node ./scripts/generate-actionlint-matcher/test.mjs
      - name: Ensure .github/actionlint-matcher.json is up-to-date
        run: |
          make .github/actionlint-matcher.json
          if git diff --quiet; then
            echo 'OK'
          else
            echo 'ERROR! .github/actionlint-matcher.json is outdated. Update it by "make .github/actionlint-matcher.json"' >&2
            set -x
            git diff
            exit 1
          fi
