Fix platform EOL checks to properly return success. (#14681)
Austin S. Hemmelgarn committed
Mar 7, 2023 at 16:58 UTC
e3c205c81389a0c0be4fbcd163abc4a44a3cb072
2 files changed
+16
-5
.github/scripts/platform-impending-eol.py
+15
-5
@@ -22,17 +22,27 @@ EXIT_IMPENDING = 1
22
EXIT_NO_DATA = 2
23
EXIT_FAILURE = 3
24
25
-with urllib.request.urlopen(f'{ URL_BASE }/{ DISTRO }/{ RELEASE }.json') as response:
26
- match response.status:
27
- case 200:
28
- data = json.load(response)
25
+try:
26
+ with urllib.request.urlopen(f'{ URL_BASE }/{ DISTRO }/{ RELEASE }.json') as response:
27
+ match response.status:
28
+ case 200:
29
+ data = json.load(response)
30
+ case _:
31
+ print(
32
+ f'Failed to retrieve data for { DISTRO } { RELEASE } ' +
33
+ f'(status: { response.status }).',
34
+ file=sys.stderr
35
+ )
36
+ sys.exit(EXIT_FAILURE)
37
+except urllib.error.HTTPError as e:
38
+ match e.code:
39
case 404:
40
print(f'No data available for { DISTRO } { RELEASE }.', file=sys.stderr)
41
sys.exit(EXIT_NO_DATA)
42
case _:
43
print(
44
f'Failed to retrieve data for { DISTRO } { RELEASE } ' +
35
- f'(status: { response.status }).',
45
+ f'(status: { e.code }).',
46
file=sys.stderr
47
)
48
sys.exit(EXIT_FAILURE)
.github/workflows/platform-eol-check.yml
+1
@@ -50,6 +50,7 @@ jobs:
50
# Actually check the EOL date for the platform.
51
- name: Check EOL Date
52
id: check
53
+ shell: sh {0}
54
run: |
55
d="$(.github/scripts/platform-impending-eol.py ${{ matrix.distro }} ${{ matrix.release }})"
56
case $? in