mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-12-31 09:10:15 +00:00
* ci: fail on malformed code blocks in release notes * add release notes to test the workflow * Revert "add release notes to test the workflow" This reverts commit 8157790dd65721998b20c57654c7f97712111391.
81 lines
3.0 KiB
YAML
81 lines
3.0 KiB
YAML
name: Check Release Notes
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- reopened
|
|
- synchronize
|
|
- ready_for_review
|
|
- labeled
|
|
- unlabeled
|
|
paths:
|
|
- "**.py"
|
|
- "pyproject.toml"
|
|
- "!.github/**/*.py"
|
|
- "releasenotes/notes/*.yaml"
|
|
|
|
jobs:
|
|
reno:
|
|
runs-on: ubuntu-slim
|
|
env:
|
|
PYTHON_VERSION: "3.10"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
# With the default value of 1, there are corner cases where tj-actions/changed-files
|
|
# fails with a `no merge base` error
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: "${{ env.PYTHON_VERSION }}"
|
|
- name: Get release note files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@v47
|
|
with:
|
|
files: releasenotes/notes/*.yaml
|
|
|
|
- name: Check release notes
|
|
if: steps.changed-files.outputs.any_changed == 'false' && !contains( github.event.pull_request.labels.*.name, 'ignore-for-release-notes')
|
|
run: |
|
|
# Check if any of the commit messages contain tags ci/docs/test
|
|
if git log --pretty=%s origin/main..HEAD | grep -E '^(ci:|docs:|test:)' > /dev/null; then
|
|
echo "Skipping release note check for commits with 'ci:', 'docs:', or 'test:' tags."
|
|
else
|
|
echo "::error::The release notes file is missing, please add one or attach the label 'ignore-for-release-notes' to this PR."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Verify release notes formatting
|
|
if: steps.changed-files.outputs.any_changed == 'true' && !contains( github.event.pull_request.labels.*.name, 'ignore-for-release-notes')
|
|
run: |
|
|
pip install "reno<5"
|
|
reno lint . # it is not possible to pass a list of files to reno lint
|
|
|
|
- name: Check reStructuredText code formatting
|
|
if: steps.changed-files.outputs.any_changed == 'true' && !contains( github.event.pull_request.labels.*.name, 'ignore-for-release-notes')
|
|
shell: python
|
|
run: |
|
|
files = "${{ steps.changed-files.outputs.all_changed_files }}".split()
|
|
errors = []
|
|
|
|
for filepath in files:
|
|
with open(filepath) as f:
|
|
for line_no, line in enumerate(f, start=1):
|
|
# Check for triple backticks (Markdown code blocks)
|
|
if "```" in line:
|
|
err = (f"Format error in {filepath}:{line_no}: "
|
|
"Found triple backticks. Use reStructuredText code block directive instead: .. code:: python")
|
|
errors.append(err)
|
|
|
|
# Check for single backticks (Markdown inline code)
|
|
if "`" in line.replace("```", "").replace("``", ""):
|
|
err = (f"Format error in {filepath}:{line_no}: "
|
|
"Found single backticks. Use double backticks (``code``) for inline code.")
|
|
errors.append(err)
|
|
|
|
if errors:
|
|
raise Exception("\n".join(errors))
|