Skip to content

Commit 99ef1a1

Browse files
committed
update pythom CI
1 parent 19b82de commit 99ef1a1

File tree

4 files changed

+40
-38
lines changed

4 files changed

+40
-38
lines changed

.github/workflows/prepare-release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
build:
99

10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-latest
1111

1212
steps:
1313
- uses: actions/checkout@v2
@@ -16,10 +16,10 @@ jobs:
1616
with:
1717
app_id: ${{ secrets.APP_ID }}
1818
private_key: ${{ secrets.APP_PRIVATE_KEY }}
19-
- name: Set up Python 2.7.18
20-
uses: MatteoH2O1999/setup-python@v1
19+
- name: Set up Python 3.10
20+
uses: actions/setup-python@v4
2121
with:
22-
python-version: 2.7.18
22+
python-version: '3.10'
2323
- name: Set up Java 11
2424
uses: actions/setup-java@v1
2525
with:

.github/workflows/release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
build:
99

10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-latest
1111

1212
steps:
1313
- uses: actions/checkout@v2
@@ -16,10 +16,10 @@ jobs:
1616
with:
1717
app_id: ${{ secrets.APP_ID }}
1818
private_key: ${{ secrets.APP_PRIVATE_KEY }}
19-
- name: Set up Python 2.7.18
20-
uses: MatteoH2O1999/setup-python@v1
19+
- name: Set up Python 3.10
20+
uses: actions/setup-python@v4
2121
with:
22-
python-version: 2.7.18
22+
python-version: '3.10'
2323
- name: Set up Java 11
2424
uses: actions/setup-java@v1
2525
with:

CI/ghApiClient.py

+24-23
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import os
44
import time
5-
import urllib2
6-
import httplib
5+
import urllib.request, urllib.error, urllib.parse
6+
import http.client
77
import json
88

99
GH_BASE_URL = "https://api.github.com/"
@@ -13,46 +13,47 @@
1313

1414
def readUrl(name):
1515
try:
16-
request = urllib2.Request(GH_BASE_URL + name)
16+
request = urllib.request.Request(GH_BASE_URL + name)
1717
request.add_header("Authorization", GH_AUTH)
18-
content = urllib2.urlopen(request).read()
18+
content = urllib.request.urlopen(request).read()
1919
jcont = json.loads(content)
20-
return jcont;
21-
except urllib2.HTTPError as e:
22-
print ('HTTPError = ' + str(e.code))
20+
return jcont
21+
except urllib.error.HTTPError as e:
22+
print(('HTTPError = ' + str(e.code)))
2323
raise e
24-
except urllib2.URLError as e:
25-
print ('URLError = ' + str(e.reason))
24+
except urllib.error.URLError as e:
25+
print(('URLError = ' + str(e.reason)))
2626
raise e
27-
except httplib.HTTPException as e:
28-
print ('HTTPException = ' + str(e))
27+
except http.client.HTTPException as e:
28+
print(('HTTPException = ' + str(e)))
2929
raise e
3030
except Exception:
3131
import traceback
32-
print ('generic exception: ' + traceback.format_exc())
32+
print(('generic exception: ' + traceback.format_exc()))
3333
raise IOError
3434

3535
def postUrl(name, body):
3636
global GH_BASE_URL
3737
try:
3838
time.sleep(0.05)
39-
request = urllib2.Request(GH_BASE_URL + name)
39+
request = urllib.request.Request(GH_BASE_URL + name)
4040
request.add_header("Authorization", GH_AUTH)
4141
request.add_header("Accept", "application/vnd.github.v3+json")
42-
content = urllib2.urlopen(request, body).read()
42+
content = urllib.request.urlopen(request, body).read()
4343
jcont = json.loads(content)
44-
return jcont;
45-
except urllib2.HTTPError as e:
46-
print ('HTTPError = ' + str(e.code))
47-
print (str(e))
44+
return jcont
45+
except urllib.error.HTTPError as e:
46+
print(('HTTPError = ' + str(e.code)))
47+
print((str(e)))
4848
raise e
49-
except urllib2.URLError as e:
50-
print ('URLError = ' + str(e.reason))
49+
except urllib.error.URLError as e:
50+
print(('URLError = ' + str(e.reason)))
5151
raise e
52-
except httplib.HTTPException as e:
53-
print ('HTTPException = ' + str(e))
52+
except http.client.HTTPException as e:
53+
print(('HTTPException = ' + str(e)))
5454
raise e
5555
except Exception:
5656
import traceback
57-
print ('generic exception: ' + traceback.format_exc())
57+
print(('generic exception: ' + traceback.format_exc()))
5858
raise IOError
59+

CI/releaseNotes.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ def allPulls(releaseDate):
1212
baseurl = "https://api.github.com/repos/swagger-api/swagger-core/pulls/"
1313
content = ghApiClient.readUrl('repos/swagger-api/swagger-core/pulls?state=closed&base=master&per_page=100')
1414
for l in content:
15-
stripped = l["url"][len(baseurl):]
16-
mergedAt = l["merged_at"]
17-
if mergedAt is not None:
18-
if datetime.strptime(mergedAt, '%Y-%m-%dT%H:%M:%SZ') > releaseDate:
19-
if not l['title'].startswith("bump snap"):
20-
result += '\n'
21-
result += "* " + l['title'] + " (#" + stripped + ")"
15+
stripped = l["url"][len(baseurl):]
16+
mergedAt = l["merged_at"]
17+
if mergedAt is not None:
18+
if datetime.strptime(mergedAt, '%Y-%m-%dT%H:%M:%SZ') > releaseDate:
19+
if not l['title'].startswith("bump snap"):
20+
result += '\n'
21+
result += "* " + l['title'] + " (#" + stripped + ")"
2222
return result
2323

2424

@@ -49,3 +49,4 @@ def main(last_release, release_title, tag):
4949

5050
# here start main
5151
main(sys.argv[1], sys.argv[2], sys.argv[3])
52+

0 commit comments

Comments
 (0)