Workflow to check for the revdate on ASCIIdoc files - #4906
Conversation
| @@ -1,7 +1,5 @@ | |||
| [[autoinstallation]] | |||
There was a problem hiding this comment.
Should I make this an error, maybe?
I think that with the exclude filter, probably it should.
There was a problem hiding this comment.
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
.adocfiles, 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.
| [[client-proxy]] | ||
| = Client Registration to a Proxy | ||
| :revdate: 2024-03-05 | ||
| :revdate: 2025-05-05 |
| @@ -1,7 +1,5 @@ | |||
| [[autoinstallation]] | |||
| = Operating System Installation | |||
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Valid point will fix it.
| 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-) | ||
| """ |
There was a problem hiding this comment.
Valid point, I even saw it before. Will fix it as soon as I have some minutes.
| 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 [] | ||
|
|
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
Least concern FMPOV. We don't plan to use this from outside PRs, so it will be always in a git repo directory.
|
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! :-) |
IMPORTANT
The GitHub action is failing ON PURPOSE! It's for demo reasons :-)
Description
We now want to enforce updating the
revdateon 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:
Co-authored with Claude.
Target branches
master, from there it will apply to all branchesLinks