Skip to content

Commit

Permalink
Add support for release_date to changelog.yaml linter and to specs. (#15
Browse files Browse the repository at this point in the history
)
  • Loading branch information
felixfontein authored May 11, 2020
1 parent f4de80b commit 36fcbe1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ansibulled/changelog/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def add_release(self, version: str, codename: Optional[str], release_date: datet
"""
if version not in self.releases:
self.releases[version] = dict(
release_date=str(release_date),
release_date=release_date.isoformat(),
)
if codename is not None:
self.releases[version]['codename'] = codename
Expand Down
14 changes: 14 additions & 0 deletions ansibulled/changelog/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Linting for changelog.yaml.
"""

import re

from typing import cast, Any, List, Optional, Tuple, Type

import semantic_version
Expand All @@ -18,6 +20,9 @@
from .fragment import ChangelogFragment, ChangelogFragmentLinter


ISO_DATE_REGEX = re.compile('^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$')


class ChangelogYamlLinter:
"""
Lint a changelogs/changelog.yaml file.
Expand Down Expand Up @@ -147,6 +152,15 @@ def lint_releases_entry(self, fragment_linter: ChangelogFragmentLinter,
:arg version_str: The version this entry belongs to
:arg entry: The releases list entry
"""
release_date = entry.get('release_date')
if self.verify_type(release_date, (str, ),
['releases', version_str, 'release_date']):
release_date = cast(str, release_date)
if not ISO_DATE_REGEX.match(release_date):
self.errors.append((self.path, 0, 0, '{0} must be a ISO date (YYYY-MM-DD)'.format(
self._format_yaml_path(['releases', version_str, 'release_date'])
)))

codename = entry.get('codename')
self.verify_type(codename, (str, ),
['releases', version_str, 'codename'], allow_none=True)
Expand Down
10 changes: 6 additions & 4 deletions docs/changelog.yaml-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ releases:

For a release `x.y.z`, the `releases` dictionary contains an entry `x.y.z` mapping to another dictionary. That dictionary can have the following entries:

1. `release_date`: a string in ISO format (`YYYY-MM-DD`) specifying on which date the release was made.
1. `codename`: a string for the version's codename. Optional; mainly required for ansible-base.
2. `fragments`: a list of strings mentioning changelog fragment files used for this release. This is not used for compiling a changelog.
3. `changes`: a dictionary containing all changes. See below.
4. `modules`: a list of plugin dictionaries. See below.
5. `plugins`: a dictionary mapping plugin types to lists of plugin dictionaries. See below.
1. `fragments`: a list of strings mentioning changelog fragment files used for this release. This is not used for compiling a changelog.
1. `changes`: a dictionary containing all changes. See below.
1. `modules`: a list of plugin dictionaries. See below.
1. `plugins`: a dictionary mapping plugin types to lists of plugin dictionaries. See below.

The following is an example of release information for version `1.0.0`:

```.yaml
releases:
1.0.0:
release_date: 2020-04-01
codename: White Rabbit
changes:
release_summary: This is the initial White Rabbit release. Enjoy!
Expand Down

0 comments on commit 36fcbe1

Please sign in to comment.