Skip to content

Commit

Permalink
Add ability to turn off milestone check (#2)
Browse files Browse the repository at this point in the history
* Add ability to turn off milestone check

* Update documentation
  • Loading branch information
WilliamJamieson authored Apr 19, 2023
1 parent 071b0d5 commit 6087edd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

Note that adding the environment variable `CHECK_MILESTONE: false` (or anything other than `true`)
will cause the milestone check to be skipped.

This action uses [astropy-changelog](https://github.com/astropy/astropy-changelog) to parse the change log.

Labels can be applied to the pull request to control its outcome:
Expand Down
38 changes: 20 additions & 18 deletions check_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,26 @@
repo = g.get_repo(base_repo)
pr = repo.get_pull(pr_num)

if not pr.milestone:
print(f'Cannot check for consistency of change log in {version} since '
'milestone is not set.')
sys.exit(1)

milestone = pr.milestone.title
if milestone.startswith('v'):
milestone = milestone[1:]

if version.startswith('v'):
version = version[1:]

if milestone != version:
print(f'Changelog entry section ({version}) '
f'inconsistent with milestone ({milestone}).')
sys.exit(1)

print(f'Changelog entry consistent with milestone ({milestone}).')
check_milestone = os.environ.get('CHECK_MILESTONE', 'true').lower()
if check_milestone == 'true':
if not pr.milestone:
print(f'Cannot check for consistency of change log in {version} since '
'milestone is not set.')
sys.exit(1)

milestone = pr.milestone.title
if milestone.startswith('v'):
milestone = milestone[1:]

if version.startswith('v'):
version = version[1:]

if milestone != version:
print(f'Changelog entry section ({version}) '
f'inconsistent with milestone ({milestone}).')
sys.exit(1)

print(f'Changelog entry consistent with milestone ({milestone}).')

else: # No change log found
if 'Affects-dev' in pr_labels:
Expand Down

0 comments on commit 6087edd

Please sign in to comment.