15
15
Check that specification updates are performed according to the versioning
16
16
requirements in README.rst.
17
17
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)
23
23
"""
24
24
import os
25
25
import re
@@ -40,7 +40,7 @@ class SpecError(Exception):
40
40
"""Common error message part. """
41
41
def __init__ (self , msg ):
42
42
super ().__init__ (
43
- msg + " please see 'Versioning' section in README.rst for details." )
43
+ msg + ", please see 'Versioning' section in README.rst for details." )
44
44
45
45
46
46
def get_spec_head ():
@@ -87,26 +87,11 @@ def main():
87
87
the last modified date and version number in the specification document
88
88
header are higher than in the master branch, i.e. were bumped. """
89
89
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
-
105
90
# Check that the current branch is based off of the master branch
106
91
try :
107
92
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 )
110
95
111
96
except subprocess .CalledProcessError as e :
112
97
raise SpecError ("make sure the current branch is based off of master" )
@@ -136,7 +121,7 @@ def main():
136
121
# Assert version bump type depending on the PR originating branch
137
122
# - if the originating branch is 'draft', it must be a major (x)or minor bump
138
123
# - otherwise, it must be a patch bump
139
- if os .environ ["TRAVIS_PULL_REQUEST_BRANCH " ] == "draft" :
124
+ if os .environ ["GITHUB_BASE_REF " ] == "draft" :
140
125
if not (((version_new [0 ] > version_prev [0 ]) !=
141
126
(version_new [1 ] > version_prev [1 ])) and
142
127
(version_new [2 ] == version_prev [2 ])):
@@ -160,4 +145,4 @@ def main():
160
145
161
146
162
147
if __name__ == '__main__' :
163
- main ()
148
+ main ()
0 commit comments