---
# SPDX-License-Identifier: GPL-2.0-or-later
#
# This file is part of nvme.
# Copyright (c) 2025 Dell Technologies Inc. or its subsidiaries.
#
# Authors: Martin Belanger <Martin.Belanger@dell.com>
#
# Verify that all committed generated accessor files (.h, .c, .i, .ld) are
# in sync with the generate-accessors tool and the annotated private*.h files.
#
# .h, .c, and .i files must be byte-identical to what the generator produces.
# .ld files are checked at the symbol level: the committed file may carry
# different version-section labels but must export the same set of symbols.
#
# If this check fails:
#   - For .h/.c/.i: run 'meson compile -C <build-dir> update-accessors'
#                   and commit the result.
#   - For .ld:      manually add/remove the symbols listed in the WARNING and
#                   commit the result.

name: Check accessors

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

  workflow_dispatch:

jobs:
  check-accessors:
    name: check generated accessor files are up to date
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/linux-nvme/debian:latest
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      - name: Mark repo as safe for git
        run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
      - name: Configure
        run: meson setup .build-ci -Dcheck-accessors=true
      - name: Check generated accessor files are in sync
        run: meson compile -C .build-ci update-accessors
