name: Lint scripts & Markdown

on: [push, pull_request, workflow_call]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  run_linters:
    name: Run scripts & Markdown linters
    if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          submodules: false

      - name: Update packages
        run:  sudo apt-get update

      - name: Run shellcheck
        run:  ./scripts/verify-bash.sh

      - name: Install pylint
        run: |
          sudo apt-get install python3-setuptools
          sudo pip3 install pylint beautifulsoup4 html5lib

      - name: Run pylint
        run:  ./scripts/verify-python.sh

      - name: Install markdownlint
        run: |
          sudo apt-get install ruby-full
          ruby --version
          sudo gem install mdl

      - name: Run markdownlint
        run:  ./scripts/verify-markdown.sh

      - name: Install appstream-util
        run:  sudo apt-get install appstream-util

      - name: Verify metainfo.xml
        run:  appstream-util validate-relax --nonet contrib/linux/org.dosbox-staging.dosbox-staging.metainfo.xml
