Skip to content

Workflow to check for the revdate on ASCIIdoc files - #4906

Draft
juliogonzalez wants to merge 2 commits into
uyuni-project:masterfrom
juliogonzalez:action-revision
Draft

Workflow to check for the revdate on ASCIIdoc files#4906
juliogonzalez wants to merge 2 commits into
uyuni-project:masterfrom
juliogonzalez:action-revision

Conversation

@juliogonzalez

@juliogonzalez juliogonzalez commented May 5, 2026

Copy link
Copy Markdown
Member

IMPORTANT

The GitHub action is failing ON PURPOSE! It's for demo reasons :-)

Description

We now want to enforce updating the revdate on ASCII doc documents, so it's better if we have an automation telling authors about it, instead of a human correcting the error during the review :-)

This is an attempt at providing a python script and GitHub action for this.

It allows:

  • Setting a grace time period for the revdate (so if you have different commits in PR it doesn't complain)
  • Setting filter, so not all .adoc files are considered (please review if the filter is OK)
  • Inline comments, so it points the exact problems.

Co-authored with Claude.

Target branches

  • Which product version this PR applies to: master, from there it will apply to all branches
  • Does this PR need to be backported? No

Links

  • None AFAIK

@@ -1,7 +1,5 @@
[[autoinstallation]]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I make this an error, maybe?

I think that with the exclude filter, probably it should.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CI automation to validate :revdate: metadata on changed AsciiDoc pages, aiming to reduce review-time back-and-forth by flagging missing/invalid/outdated revdates directly in PRs via GitHub Actions annotations.

Changes:

  • Added a GitHub Actions workflow to run a revdate check on pull requests.
  • Added a Python script to detect changed .adoc files, validate :revdate: format, and compare it to git modification dates (with a grace period).
  • Updated (and in one case removed) :revdate:/:page-revdate: headers in several client-configuration docs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
modules/client-configuration/pages/clients-amazon.adoc Updates :revdate: metadata (currently to a non-YYYY-MM-DD value).
modules/client-configuration/pages/client-proxy.adoc Updates :revdate: metadata.
modules/client-configuration/pages/client-config-overview.adoc Updates :revdate: metadata.
modules/client-configuration/pages/autoinst-intro.adoc Removes :revdate: / :page-revdate: headers.
.github/workflows/check_revdate.yml Introduces PR workflow to execute the revdate checker script.
.github/scripts/check_revdate.py Introduces the revdate validation + git-history comparison logic and emits GitHub annotations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/client-configuration/pages/clients-amazon.adoc
[[client-proxy]]
= Client Registration to a Proxy
:revdate: 2024-03-05
:revdate: 2025-05-05
Comment thread modules/client-configuration/pages/client-config-overview.adoc
@@ -1,7 +1,5 @@
[[autoinstallation]]
= Operating System Installation

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point. Maybe I should improve the script?

- name: 'Set up Python'
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b #v5.3.0
with:
python-version: '3.x' # Latest avalable version, so we don't need to worry about bumping

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point will fix it.

Comment on lines +5 to +20
This script validates:
1. All .adoc files contain a :revdate: field
2. The date follows the YYYY-MM-DD format
3. The revdate is updated when the file content is modified

Only checks files that have been added or modified in the current branch.
Outputs GitHub Actions annotations for errors and warnings.

Usage:
check_revdate.py [--grace-days DAYS] [--exclude-patterns PATTERN ...]

Options:
--grace-days DAYS Grace period in days for revdate (default: 7)
--exclude-patterns PATTERN [...] Space-separated filename patterns to exclude
(default: _attributes.adoc attributes- nav- README.adoc workflow-)
"""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point, I even saw it before. Will fix it as soon as I have some minutes.

Comment on lines +112 to +136
def get_changed_files(repo_root):
"""Get list of .adoc files that have changed compared to the base branch."""
try:
# Try to get the base ref from GitHub environment
base_ref = os.environ.get('GITHUB_BASE_REF', 'origin/master')
if base_ref and not base_ref.startswith('origin/'):
base_ref = f'origin/{base_ref}'

result = subprocess.run(
['git', 'diff', '--name-only', '--diff-filter=AM', f'{base_ref}...HEAD'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
check=True,
cwd=repo_root
)
changed_files = [
repo_root / f.strip()
for f in result.stdout.strip().split('\n')
if f.strip().endswith('.adoc')
]
return [f for f in changed_files if f.exists()]
except subprocess.CalledProcessError:
return []

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could maybe be an improvement for later. This is always going to be used in PRs, so unless I am very wrong GITHUB_BASE_REF should always be valid.

Comment on lines +44 to +59
def get_git_last_modified_date(file_path):
"""Get the last modification date of a file from git history."""
try:
result = subprocess.run(
['git', 'log', '-1', '--format=%ci', '--', file_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
check=True
)
if result.stdout.strip():
date_str = result.stdout.strip().split()[0]
return datetime.strptime(date_str, '%Y-%m-%d').date()
return None
except subprocess.CalledProcessError:
return None

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Least concern FMPOV. We don't plan to use this from outside PRs, so it will be always in a git repo directory.

@KucharczykL

Copy link
Copy Markdown
Contributor

Hi, this seems like a nice thing to have. Do you plan to taking another look at it so we can merge it?

@juliogonzalez

Copy link
Copy Markdown
Member Author

Hi, this seems like a nice thing to have. Do you plan to taking another look at it so we can merge it?

Will try, but sadly not anytime soon (at least not before next Learning Tuesday)... so if someone wants to take over, go ahead! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants