Skip to content

Commit f9fd90a

Browse files
committed
Update check_release for GitHub Actions
* Update to use GHA environment variables * Remove checks which are handled by GHA configuration -- we will configure CI to only run check_release on PRs to master Signed-off-by: Joshua Lock <[email protected]>
1 parent d3ee698 commit f9fd90a

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

check_release.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
Check that specification updates are performed according to the versioning
1616
requirements in README.rst.
1717
18-
Expects Travis environment variables:
19-
- TRAVIS_BRANCH
20-
- TRAVIS_PULL_REQUEST_BRANCH
21-
(see https://docs.travis-ci.com/user/environment-variables/)
22-
18+
Expects GitHub Actions environment variables:
19+
- GITHUB_REF the ref that triggered the workflow (i.e refs/pull/33/merge)
20+
- GITHUB_BASE_REF the target branch (usually master)
21+
- GITHUB_HEAD_REF the name of the submitters branch
22+
(see https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables)
2323
"""
2424
import os
2525
import re
@@ -40,7 +40,7 @@ class SpecError(Exception):
4040
"""Common error message part. """
4141
def __init__(self, msg):
4242
super().__init__(
43-
msg + " please see 'Versioning' section in README.rst for details.")
43+
msg + ", please see 'Versioning' section in README.rst for details.")
4444

4545

4646
def get_spec_head():
@@ -87,26 +87,11 @@ def main():
8787
the last modified date and version number in the specification document
8888
header are higher than in the master branch, i.e. were bumped. """
8989

90-
# Skip version and date comparison on push builds ...
91-
# As per https://docs.travis-ci.com/user/environment-variables/
92-
# if the current job is a push build, this [env] variable is empty ("")
93-
if not os.environ.get("TRAVIS_PULL_REQUEST_BRANCH"):
94-
print("skipping version and date check for non pr builds ...")
95-
sys.exit(0)
96-
97-
# ... also skip on PRs that don't target the master branch
98-
# As per https://docs.travis-ci.com/user/environment-variables/:
99-
# for builds triggered by a pull request this [env variable] is the name of
100-
# the branch targeted by the pull request
101-
if not os.environ.get("TRAVIS_BRANCH") == "master":
102-
print("skipping version and date for builds that don't target master ...")
103-
sys.exit(0)
104-
10590
# Check that the current branch is based off of the master branch
10691
try:
10792
subprocess.run(
108-
shlex.split("git merge-base --is-ancestor master {}".format(
109-
os.environ["TRAVIS_PULL_REQUEST_BRANCH"])), check=True)
93+
shlex.split("git merge-base --is-ancestor origin/master {}".format(
94+
os.environ["GITHUB_REF"].lstrip("refs/"))), check=True)
11095

11196
except subprocess.CalledProcessError as e:
11297
raise SpecError("make sure the current branch is based off of master")
@@ -136,7 +121,7 @@ def main():
136121
# Assert version bump type depending on the PR originating branch
137122
# - if the originating branch is 'draft', it must be a major (x)or minor bump
138123
# - otherwise, it must be a patch bump
139-
if os.environ["TRAVIS_PULL_REQUEST_BRANCH"] == "draft":
124+
if os.environ["GITHUB_BASE_REF"] == "draft":
140125
if not (((version_new[0] > version_prev[0]) !=
141126
(version_new[1] > version_prev[1])) and
142127
(version_new[2] == version_prev[2])):
@@ -160,4 +145,4 @@ def main():
160145

161146

162147
if __name__ == '__main__':
163-
main()
148+
main()

0 commit comments

Comments
 (0)