Browse Source

Fix platform EOL checks to properly return success. (#14681)

Austin S. Hemmelgarn 2 years ago
parent
commit
e3c205c813

+ 15 - 5
.github/scripts/platform-impending-eol.py

@@ -22,17 +22,27 @@ EXIT_IMPENDING = 1
 EXIT_NO_DATA = 2
 EXIT_FAILURE = 3
 
-with urllib.request.urlopen(f'{ URL_BASE }/{ DISTRO }/{ RELEASE }.json') as response:
-    match response.status:
-        case 200:
-            data = json.load(response)
+try:
+    with urllib.request.urlopen(f'{ URL_BASE }/{ DISTRO }/{ RELEASE }.json') as response:
+        match response.status:
+            case 200:
+                data = json.load(response)
+            case _:
+                print(
+                    f'Failed to retrieve data for { DISTRO } { RELEASE } ' +
+                    f'(status: { response.status }).',
+                    file=sys.stderr
+                )
+                sys.exit(EXIT_FAILURE)
+except urllib.error.HTTPError as e:
+    match e.code:
         case 404:
             print(f'No data available for { DISTRO } { RELEASE }.', file=sys.stderr)
             sys.exit(EXIT_NO_DATA)
         case _:
             print(
                 f'Failed to retrieve data for { DISTRO } { RELEASE } ' +
-                f'(status: { response.status }).',
+                f'(status: { e.code }).',
                 file=sys.stderr
             )
             sys.exit(EXIT_FAILURE)

+ 1 - 0
.github/workflows/platform-eol-check.yml

@@ -50,6 +50,7 @@ jobs:
       # Actually check the EOL date for the platform.
       - name: Check EOL Date
         id: check
+        shell: sh {0}
         run: |
           d="$(.github/scripts/platform-impending-eol.py ${{ matrix.distro }} ${{ matrix.release }})"
           case $? in