diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81ecd71..3fcf166 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,5 +43,3 @@ jobs: with: overall_threshold: minor pages_threshold: partial_outage - env: - GHACTION_GITHUB_STATUS_MOCKIT: true diff --git a/README.md b/README.md index 099ca27..94f1a44 100644 --- a/README.md +++ b/README.md @@ -100,8 +100,8 @@ Following inputs can be used as `step.with` keys | `packages_threshold`**²** | String | Defines threshold for GitHub Packages to fail the job | | `pages_threshold`**²** | String | Defines threshold for GitHub Pages to fail the job | -> * **¹** Accepted values are `minor`, `major` or `critical`. -> * **²** Accepted values are `operational`, `degraded_performance`, `partial_outage` or `major_outage`. +> * **¹** Accepted values are `minor`, `major`, `critical` or `maintenance`. +> * **²** Accepted values are `operational`, `degraded_performance`, `partial_outage` `major_outage`, `under_maintenance`. ## Keep up-to-date with GitHub Dependabot @@ -121,7 +121,10 @@ updates: ## How can I help? -All kinds of contributions are welcome :raised_hands:! The most basic way to show your support is to star :star2: the project, or to raise issues :speech_balloon: You can also support this project by [**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max) :clap: or by making a [Paypal donation](https://www.paypal.me/crazyws) to ensure this journey continues indefinitely! :rocket: +All kinds of contributions are welcome :raised_hands:! The most basic way to show your support is to star :star2: the +project, or to raise issues :speech_balloon: You can also support this project by +[**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max) :clap: or by making a +[Paypal donation](https://www.paypal.me/crazyws) to ensure this journey continues indefinitely! :rocket: Thanks again for your support, it is much appreciated! :pray: diff --git a/__tests__/fixtures/data-status-2.json b/__tests__/fixtures/data-status-2.json new file mode 100644 index 0000000..cfd2380 --- /dev/null +++ b/__tests__/fixtures/data-status-2.json @@ -0,0 +1,13 @@ +{ + "page": { + "id": "kctbh9vrtdwd", + "name": "GitHub", + "url": "https://www.githubstatus.com", + "time_zone": "Etc/UTC", + "updated_at": "2020-12-17T00:54:37.709Z" + }, + "status": { + "indicator": "maintenance", + "description": "Service Under Maintenance" + } +} diff --git a/__tests__/data-status.json b/__tests__/fixtures/data-status.json similarity index 100% rename from __tests__/data-status.json rename to __tests__/fixtures/data-status.json diff --git a/__tests__/fixtures/data-summary-2.json b/__tests__/fixtures/data-summary-2.json new file mode 100644 index 0000000..697ea7b --- /dev/null +++ b/__tests__/fixtures/data-summary-2.json @@ -0,0 +1,240 @@ +{ + "page": { + "id": "kctbh9vrtdwd", + "name": "GitHub", + "url": "https://www.githubstatus.com", + "time_zone": "Etc/UTC", + "updated_at": "2020-12-17T00:54:37.709Z" + }, + "components": [ + { + "id": "8l4ygp009s5s", + "name": "Git Operations", + "status": "operational", + "created_at": "2017-01-31T20:05:05.370Z", + "updated_at": "2020-10-29T22:51:43.831Z", + "position": 1, + "description": "Performance of git clones, pulls, pushes, and associated operations", + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + }, + { + "id": "brv1bkgrwx7q", + "name": "API Requests", + "status": "operational", + "created_at": "2017-01-31T20:01:46.621Z", + "updated_at": "2020-12-17T00:54:20.946Z", + "position": 2, + "description": "Requests for GitHub APIs", + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + }, + { + "id": "4230lsnqdsld", + "name": "Webhooks", + "status": "operational", + "created_at": "2019-11-13T18:00:24.256Z", + "updated_at": "2020-11-18T23:38:14.467Z", + "position": 3, + "description": "Real time HTTP callbacks of user-generated and system events", + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + }, + { + "id": "0l2p9nhqnxpd", + "name": "Visit www.githubstatus.com for more information", + "status": "operational", + "created_at": "2018-12-05T19:39:40.838Z", + "updated_at": "2020-04-02T21:56:21.954Z", + "position": 4, + "description": null, + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + }, + { + "id": "kr09ddfgbfsf", + "name": "Issues", + "status": "operational", + "created_at": "2017-01-31T20:01:46.638Z", + "updated_at": "2020-12-17T00:54:24.999Z", + "position": 5, + "description": "Requests for Issues on GitHub.com", + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + }, + { + "id": "hhtssxt0f5v2", + "name": "Pull Requests", + "status": "operational", + "created_at": "2020-09-02T15:39:06.329Z", + "updated_at": "2020-12-17T00:54:27.674Z", + "position": 6, + "description": "Requests for Pull Requests on GitHub.com", + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + }, + { + "id": "br0l2tvcx85d", + "name": "GitHub Actions", + "status": "under_maintenance", + "created_at": "2019-11-13T18:02:19.432Z", + "updated_at": "2020-12-15T10:00:40.029Z", + "position": 7, + "description": "Workflows, Compute and Orchestration for GitHub Actions", + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + }, + { + "id": "st3j38cctv9l", + "name": "GitHub Packages", + "status": "operational", + "created_at": "2019-11-13T18:02:40.064Z", + "updated_at": "2020-12-17T00:54:37.707Z", + "position": 8, + "description": "API requests and webhook delivery for GitHub Packages", + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + }, + { + "id": "vg70hn9s2tyj", + "name": "GitHub Pages", + "status": "operational", + "created_at": "2017-01-31T20:04:33.923Z", + "updated_at": "2020-10-10T00:02:38.220Z", + "position": 9, + "description": "Frontend application and API servers for Pages builds", + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + } + ], + "incidents": [], + "scheduled_maintenances": [ + { + "id": "3jr0nb7zjpbm", + "name": "macOS virtual environment maintenance", + "status": "in_progress", + "created_at": "2020-12-14T16:37:35.904Z", + "updated_at": "2020-12-15T10:00:40.058Z", + "monitoring_at": null, + "resolved_at": null, + "impact": "maintenance", + "shortlink": "https://stspg.io/rm0t69d0btrr", + "started_at": "2020-12-14T16:37:35.898Z", + "page_id": "kctbh9vrtdwd", + "incident_updates": [ + { + "id": "f0421g6r1g8m", + "status": "in_progress", + "body": "Scheduled maintenance is currently in progress. We will provide updates as necessary.", + "incident_id": "3jr0nb7zjpbm", + "created_at": "2020-12-15T10:00:40.056Z", + "updated_at": "2020-12-15T10:00:40.056Z", + "display_at": "2020-12-15T10:00:40.056Z", + "affected_components": [ + { + "code": "br0l2tvcx85d", + "name": "GitHub Actions", + "old_status": "operational", + "new_status": "under_maintenance" + } + ], + "deliver_notifications": true, + "custom_tweet": null, + "tweet_id": null + }, + { + "id": "vrs2hgm4k8th", + "status": "scheduled", + "body": "Maintenance will begin as scheduled in 60 minutes.", + "incident_id": "3jr0nb7zjpbm", + "created_at": "2020-12-15T09:00:29.617Z", + "updated_at": "2020-12-15T09:00:29.617Z", + "display_at": "2020-12-15T09:00:29.617Z", + "affected_components": null, + "deliver_notifications": true, + "custom_tweet": null, + "tweet_id": null + }, + { + "id": "9byn0w0j9hyg", + "status": "scheduled", + "body": "During the week of December 14-18, GitHub will be performing scheduled maintenance on one of our datacenters that may result in longer than normal queue times for macOS workflows using macos-latest, macos-10.14, or macos-10.15. In some cases, it may be possible that jobs will time out or be cancelled, and will need to be restarted.\n\nWe apologize for the inconvenience and encourage you to be patient, and give your workflows extra time to run. Follow our progress in the virtual-environments repo here.", + "incident_id": "3jr0nb7zjpbm", + "created_at": "2020-12-14T16:37:35.959Z", + "updated_at": "2020-12-14T16:37:35.959Z", + "display_at": "2020-12-14T16:37:35.959Z", + "affected_components": [ + { + "code": "br0l2tvcx85d", + "name": "GitHub Actions", + "old_status": "operational", + "new_status": "operational" + } + ], + "deliver_notifications": true, + "custom_tweet": null, + "tweet_id": null + } + ], + "components": [ + { + "id": "br0l2tvcx85d", + "name": "GitHub Actions", + "status": "under_maintenance", + "created_at": "2019-11-13T18:02:19.432Z", + "updated_at": "2020-12-15T10:00:40.029Z", + "position": 7, + "description": "Workflows, Compute and Orchestration for GitHub Actions", + "showcase": false, + "start_date": null, + "group_id": null, + "page_id": "kctbh9vrtdwd", + "group": false, + "only_show_if_degraded": false + } + ], + "scheduled_for": "2020-12-15T10:00:00.000Z", + "scheduled_until": "2020-12-19T04:00:00.000Z" + } + ], + "status": { + "indicator": "maintenance", + "description": "Service Under Maintenance" + } +} diff --git a/__tests__/data-summary.json b/__tests__/fixtures/data-summary.json similarity index 100% rename from __tests__/data-summary.json rename to __tests__/fixtures/data-summary.json diff --git a/__tests__/githubstatus.test.ts b/__tests__/githubstatus.test.ts index c077669..d180568 100644 --- a/__tests__/githubstatus.test.ts +++ b/__tests__/githubstatus.test.ts @@ -1,4 +1,7 @@ +import * as path from 'path'; import * as githubstatus from '../src/githubstatus'; +import {Page, Status} from '../src/status'; +import {Summary} from '../src/summary'; describe('githubstatus', () => { it('returns GitHub Status (status)', async () => { @@ -14,3 +17,62 @@ describe('githubstatus', () => { expect(summary?.components?.length).toBeGreaterThan(0); }); }); + +describe('status', () => { + test.each([ + [ + 'data-status.json', + { + description: 'Minor Service Outage', + indicator: 'minor' + } as Status, + { + id: 'kctbh9vrtdwd', + name: 'GitHub', + url: 'https://www.githubstatus.com', + time_zone: 'Etc/UTC', + updated_at: '2020-05-22T20:50:20.457Z' + } as Page + ], + [ + 'data-status-2.json', + { + description: 'Service Under Maintenance', + indicator: 'maintenance' + } as Status, + { + id: 'kctbh9vrtdwd', + name: 'GitHub', + url: 'https://www.githubstatus.com', + time_zone: 'Etc/UTC', + updated_at: '2020-12-17T00:54:37.709Z' + } as Page + ] + ])('given %p', async (file, expStatus, expPage) => { + jest.spyOn(githubstatus, 'status').mockImplementation( + (): Promise => { + return >require(path.join(__dirname, 'fixtures', file)); + } + ); + + const status = await githubstatus.status(); + console.log(status); + expect(status?.status).toEqual(expStatus); + expect(status?.page).toEqual(expPage); + }); +}); + +describe('summary', () => { + test.each([['data-summary.json'], ['data-summary-2.json']])('given %p', async file => { + jest.spyOn(githubstatus, 'summary').mockImplementation( + (): Promise => { + return >require(path.join(__dirname, 'fixtures', file)); + } + ); + + const summary = await githubstatus.summary(); + console.log(summary); + expect(summary?.status.indicator).not.toEqual(''); + expect(summary?.components?.length).toBeGreaterThan(0); + }); +}); diff --git a/dist/index.js b/dist/index.js index b2bd271..e2f65dd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2,22 +2,6 @@ module.exports = /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 974: -/***/ ((module) => { - -"use strict"; -module.exports = JSON.parse("{\"page\":{\"id\":\"kctbh9vrtdwd\",\"name\":\"GitHub\",\"url\":\"https://www.githubstatus.com\",\"time_zone\":\"Etc/UTC\",\"updated_at\":\"2020-05-22T20:50:20.457Z\"},\"status\":{\"indicator\":\"minor\",\"description\":\"Minor Service Outage\"}}"); - -/***/ }), - -/***/ 675: -/***/ ((module) => { - -"use strict"; -module.exports = JSON.parse("{\"page\":{\"id\":\"kctbh9vrtdwd\",\"name\":\"GitHub\",\"url\":\"https://www.githubstatus.com\",\"time_zone\":\"Etc/UTC\",\"updated_at\":\"2020-05-22T20:50:20.457Z\"},\"components\":[{\"id\":\"8l4ygp009s5s\",\"name\":\"Git Operations\",\"status\":\"operational\",\"created_at\":\"2017-01-31T20:05:05.370Z\",\"updated_at\":\"2020-09-02T15:40:02.167Z\",\"position\":1,\"description\":\"Performance of git clones, pulls, pushes, and associated operations\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false},{\"id\":\"brv1bkgrwx7q\",\"name\":\"API Requests\",\"status\":\"operational\",\"created_at\":\"2017-01-31T20:01:46.621Z\",\"updated_at\":\"2020-09-08T17:16:59.324Z\",\"position\":2,\"description\":\"Requests for GitHub APIs\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false},{\"id\":\"4230lsnqdsld\",\"name\":\"Webhooks\",\"status\":\"operational\",\"created_at\":\"2019-11-13T18:00:24.256Z\",\"updated_at\":\"2020-09-07T01:36:09.887Z\",\"position\":3,\"description\":\"Real time HTTP callbacks of user-generated and system events\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false},{\"id\":\"0l2p9nhqnxpd\",\"name\":\"Visit www.githubstatus.com for more information\",\"status\":\"operational\",\"created_at\":\"2018-12-05T19:39:40.838Z\",\"updated_at\":\"2020-04-02T21:56:21.954Z\",\"position\":4,\"description\":null,\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false},{\"id\":\"kr09ddfgbfsf\",\"name\":\"Issues\",\"status\":\"operational\",\"created_at\":\"2017-01-31T20:01:46.638Z\",\"updated_at\":\"2020-09-08T16:14:03.625Z\",\"position\":5,\"description\":\"Requests for Issues on GitHub.com\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false},{\"id\":\"hhtssxt0f5v2\",\"name\":\"Pull Requests\",\"status\":\"operational\",\"created_at\":\"2020-09-02T15:39:06.329Z\",\"updated_at\":\"2020-09-08T16:14:05.407Z\",\"position\":6,\"description\":\"Requests for Pull Requests on GitHub.com\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false},{\"id\":\"br0l2tvcx85d\",\"name\":\"GitHub Actions\",\"status\":\"operational\",\"created_at\":\"2019-11-13T18:02:19.432Z\",\"updated_at\":\"2020-09-02T15:40:47.790Z\",\"position\":7,\"description\":\"Workflows, Compute and Orchestration for GitHub Actions\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false},{\"id\":\"st3j38cctv9l\",\"name\":\"GitHub Packages\",\"status\":\"operational\",\"created_at\":\"2019-11-13T18:02:40.064Z\",\"updated_at\":\"2020-09-08T15:50:32.845Z\",\"position\":8,\"description\":\"API requests and webhook delivery for GitHub Packages\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false},{\"id\":\"vg70hn9s2tyj\",\"name\":\"GitHub Pages\",\"status\":\"operational\",\"created_at\":\"2017-01-31T20:04:33.923Z\",\"updated_at\":\"2020-09-17T16:30:28.895Z\",\"position\":9,\"description\":\"Frontend application and API servers for Pages builds\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false}],\"incidents\":[{\"id\":\"6tcfpztf6j9m\",\"name\":\"Incident on 2020-05-22 16:41 UTC\",\"status\":\"investigating\",\"created_at\":\"2020-05-22T16:41:53.142Z\",\"updated_at\":\"2020-05-22T20:50:13.761Z\",\"monitoring_at\":null,\"resolved_at\":null,\"impact\":\"minor\",\"shortlink\":\"http://stspg.io/g1l6nqnlv29b\",\"started_at\":\"2020-05-22T16:41:53.133Z\",\"page_id\":\"kctbh9vrtdwd\",\"incident_updates\":[{\"id\":\"2hdg5g90ysg5\",\"status\":\"investigating\",\"body\":\"The last incident update was due to the ongoing remediation work. We have addressed that issue and continue to monitor the original issue.\",\"incident_id\":\"6tcfpztf6j9m\",\"created_at\":\"2020-05-22T20:50:13.759Z\",\"updated_at\":\"2020-05-22T20:50:13.759Z\",\"display_at\":\"2020-05-22T20:50:13.759Z\",\"affected_components\":null,\"deliver_notifications\":true,\"custom_tweet\":null,\"tweet_id\":null},{\"id\":\"jwx4zzg89qxk\",\"status\":\"investigating\",\"body\":\"We are also investigating elevated error rates for GitHub.com.\",\"incident_id\":\"6tcfpztf6j9m\",\"created_at\":\"2020-05-22T19:57:28.380Z\",\"updated_at\":\"2020-05-22T19:57:28.380Z\",\"display_at\":\"2020-05-22T19:57:28.380Z\",\"affected_components\":null,\"deliver_notifications\":true,\"custom_tweet\":null,\"tweet_id\":null},{\"id\":\"2v0t4679xdb0\",\"status\":\"investigating\",\"body\":\"We continue to monitor the remediation and will provide the next update in 1 hour.\",\"incident_id\":\"6tcfpztf6j9m\",\"created_at\":\"2020-05-22T19:17:05.205Z\",\"updated_at\":\"2020-05-22T19:17:05.205Z\",\"display_at\":\"2020-05-22T19:17:05.205Z\",\"affected_components\":null,\"deliver_notifications\":true,\"custom_tweet\":null,\"tweet_id\":null},{\"id\":\"2vsfbxp44rcy\",\"status\":\"investigating\",\"body\":\"We have identified the source causing elevated errors as well as occasional stale data on GitHub.com. We are working on remediation.\",\"incident_id\":\"6tcfpztf6j9m\",\"created_at\":\"2020-05-22T18:01:25.988Z\",\"updated_at\":\"2020-05-22T18:01:25.988Z\",\"display_at\":\"2020-05-22T18:01:25.988Z\",\"affected_components\":null,\"deliver_notifications\":true,\"custom_tweet\":null,\"tweet_id\":null},{\"id\":\"v2jscrdmsw38\",\"status\":\"investigating\",\"body\":\"We continue to investigate an increase in errors on GitHub.com.\",\"incident_id\":\"6tcfpztf6j9m\",\"created_at\":\"2020-05-22T17:16:39.703Z\",\"updated_at\":\"2020-05-22T17:16:39.703Z\",\"display_at\":\"2020-05-22T17:16:39.703Z\",\"affected_components\":null,\"deliver_notifications\":true,\"custom_tweet\":null,\"tweet_id\":null},{\"id\":\"3ry2b0s8174c\",\"status\":\"investigating\",\"body\":\"We are investigating an increase in errors on GitHub.com.\",\"incident_id\":\"6tcfpztf6j9m\",\"created_at\":\"2020-05-22T16:41:53.189Z\",\"updated_at\":\"2020-05-22T16:41:53.189Z\",\"display_at\":\"2020-05-22T16:41:53.189Z\",\"affected_components\":[{\"code\":\"0l2p9nhqnxpd\",\"name\":\"Visit www.githubstatus.com for more information\",\"old_status\":\"operational\",\"new_status\":\"operational\"}],\"deliver_notifications\":true,\"custom_tweet\":null,\"tweet_id\":null}],\"components\":[{\"id\":\"0l2p9nhqnxpd\",\"name\":\"Visit www.githubstatus.com for more information\",\"status\":\"operational\",\"created_at\":\"2018-12-05T19:39:40.838Z\",\"updated_at\":\"2020-04-02T21:56:21.954Z\",\"position\":4,\"description\":null,\"showcase\":false,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false}]}],\"scheduled_maintenances\":[{\"id\":\"skzhfwy9kf8q\",\"name\":\"Deprecating password authentication\",\"status\":\"scheduled\",\"created_at\":\"2020-09-14T09:33:28.071Z\",\"updated_at\":\"2020-09-14T09:36:29.610Z\",\"monitoring_at\":null,\"resolved_at\":null,\"impact\":\"maintenance\",\"shortlink\":\"http://stspg.io/z0gf9ffzy530\",\"started_at\":\"2020-09-14T09:33:28.065Z\",\"page_id\":\"kctbh9vrtdwd\",\"incident_updates\":[{\"id\":\"xwjsnptt3v4g\",\"status\":\"scheduled\",\"body\":\"As mentioned in our developer guide, GitHub no longer supports basic authentication using a username and password. Instead, we recommend using personal access tokens or the web application flow.\",\"incident_id\":\"skzhfwy9kf8q\",\"created_at\":\"2020-09-14T09:33:28.126Z\",\"updated_at\":\"2020-09-14T09:36:29.607Z\",\"display_at\":\"2020-09-14T09:33:28.126Z\",\"affected_components\":[{\"code\":\"brv1bkgrwx7q\",\"name\":\"API Requests\",\"old_status\":\"operational\",\"new_status\":\"operational\"}],\"deliver_notifications\":true,\"custom_tweet\":null,\"tweet_id\":null}],\"components\":[{\"id\":\"brv1bkgrwx7q\",\"name\":\"API Requests\",\"status\":\"operational\",\"created_at\":\"2017-01-31T20:01:46.621Z\",\"updated_at\":\"2020-09-08T17:16:59.324Z\",\"position\":2,\"description\":\"Requests for GitHub APIs\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false}],\"scheduled_for\":\"2020-09-30T07:00:00.000Z\",\"scheduled_until\":\"2020-09-30T10:00:00.000Z\"},{\"id\":\"ry5psbndh11j\",\"name\":\"Deprecating password authentication\",\"status\":\"scheduled\",\"created_at\":\"2020-09-14T09:34:09.320Z\",\"updated_at\":\"2020-09-14T09:35:34.843Z\",\"monitoring_at\":null,\"resolved_at\":null,\"impact\":\"maintenance\",\"shortlink\":\"http://stspg.io/r7b3cwdr1hll\",\"started_at\":\"2020-09-14T09:34:09.316Z\",\"page_id\":\"kctbh9vrtdwd\",\"incident_updates\":[{\"id\":\"9pyd05dq9dmh\",\"status\":\"scheduled\",\"body\":\"As mentioned in our developer guide, GitHub no longer supports basic authentication using a username and password. Instead, we recommend using personal access tokens or the web application flow.\",\"incident_id\":\"ry5psbndh11j\",\"created_at\":\"2020-09-14T09:34:09.369Z\",\"updated_at\":\"2020-09-14T09:35:34.841Z\",\"display_at\":\"2020-09-14T09:34:09.369Z\",\"affected_components\":[{\"code\":\"brv1bkgrwx7q\",\"name\":\"API Requests\",\"old_status\":\"operational\",\"new_status\":\"operational\"}],\"deliver_notifications\":true,\"custom_tweet\":null,\"tweet_id\":null}],\"components\":[{\"id\":\"brv1bkgrwx7q\",\"name\":\"API Requests\",\"status\":\"operational\",\"created_at\":\"2017-01-31T20:01:46.621Z\",\"updated_at\":\"2020-09-08T17:16:59.324Z\",\"position\":2,\"description\":\"Requests for GitHub APIs\",\"showcase\":false,\"start_date\":null,\"group_id\":null,\"page_id\":\"kctbh9vrtdwd\",\"group\":false,\"only_show_if_degraded\":false}],\"scheduled_for\":\"2020-09-30T16:00:00.000Z\",\"scheduled_until\":\"2020-09-30T19:00:00.000Z\"}],\"status\":{\"indicator\":\"minor\",\"description\":\"Minor Service Outage\"}}"); - -/***/ }), - /***/ 779: /***/ (function(__unused_webpack_module, exports, __webpack_require__) { @@ -47,6 +31,7 @@ var OverallStatus; OverallStatus[OverallStatus["Minor"] = 0] = "Minor"; OverallStatus[OverallStatus["Major"] = 1] = "Major"; OverallStatus[OverallStatus["Critical"] = 2] = "Critical"; + OverallStatus[OverallStatus["Maintenance"] = 3] = "Maintenance"; })(OverallStatus = exports.OverallStatus || (exports.OverallStatus = {})); var ComponentStatus; (function (ComponentStatus) { @@ -54,6 +39,7 @@ var ComponentStatus; ComponentStatus[ComponentStatus["DegradedPerformance"] = 1] = "DegradedPerformance"; ComponentStatus[ComponentStatus["PartialOutage"] = 2] = "PartialOutage"; ComponentStatus[ComponentStatus["MajorOutage"] = 3] = "MajorOutage"; + ComponentStatus[ComponentStatus["UnderMaintenance"] = 4] = "UnderMaintenance"; })(ComponentStatus = exports.ComponentStatus || (exports.ComponentStatus = {})); var Component; (function (Component) { @@ -70,13 +56,15 @@ var Component; exports.OverallStatusName = new Map([ ['minor', OverallStatus.Minor], ['major', OverallStatus.Major], - ['critical', OverallStatus.Critical] + ['critical', OverallStatus.Critical], + ['maintenance', OverallStatus.Maintenance] ]); exports.ComponentsStatusName = new Map([ ['operational', ComponentStatus.Operational], ['degraded_performance', ComponentStatus.DegradedPerformance], ['partial_outage', ComponentStatus.PartialOutage], - ['major_outage', ComponentStatus.MajorOutage] + ['major_outage', ComponentStatus.MajorOutage], + ['under_maintenance', ComponentStatus.UnderMaintenance] ]); exports.getOverallStatusName = (status) => __awaiter(void 0, void 0, void 0, function* () { var e_1, _a; @@ -113,19 +101,10 @@ exports.getComponentStatusName = (status) => __awaiter(void 0, void 0, void 0, f } }); exports.status = () => __awaiter(void 0, void 0, void 0, function* () { - yield console.log(process.env); - if (process.env.GHACTION_GITHUB_STATUS_MOCKIT) { - // @ts-ignore - return __webpack_require__(974); - } const http = new httpm.HttpClient('ghaction-github-status'); return (yield http.getJson(`https://www.githubstatus.com/api/v2/status.json`)).result; }); exports.summary = () => __awaiter(void 0, void 0, void 0, function* () { - if (process.env.GHACTION_GITHUB_STATUS_MOCKIT) { - // @ts-ignore - return __webpack_require__(675); - } const http = new httpm.HttpClient('ghaction-github-status'); return (yield http.getJson(`https://www.githubstatus.com/api/v2/summary.json`)).result; }); @@ -193,6 +172,10 @@ function run() { core.error(`GitHub Status: ${summary.status.description}`); break; } + case 'maintenance': { + core.warning(`GitHub Status: ${summary.status.description}`); + break; + } default: { core.info(`GitHub Status: ${summary.status.description}`); break; @@ -235,6 +218,10 @@ function run() { compStatusText = chalk.red('Major outage'); break; } + case 'under_maintenance': { + compStatusText = chalk.blue('Under maintenance'); + break; + } } core.info(` • ${compStatusText}${new Array(30 - compStatusText.length).join(' ')} ${component.name}`); })); diff --git a/src/githubstatus.ts b/src/githubstatus.ts index 5485d90..42e3dd8 100644 --- a/src/githubstatus.ts +++ b/src/githubstatus.ts @@ -5,14 +5,16 @@ import * as httpm from '@actions/http-client'; export enum OverallStatus { Minor, Major, - Critical + Critical, + Maintenance } export enum ComponentStatus { Operational, DegradedPerformance, PartialOutage, - MajorOutage + MajorOutage, + UnderMaintenance } export enum Component { @@ -30,14 +32,16 @@ export enum Component { export const OverallStatusName = new Map([ ['minor', OverallStatus.Minor], ['major', OverallStatus.Major], - ['critical', OverallStatus.Critical] + ['critical', OverallStatus.Critical], + ['maintenance', OverallStatus.Maintenance] ]); export const ComponentsStatusName = new Map([ ['operational', ComponentStatus.Operational], ['degraded_performance', ComponentStatus.DegradedPerformance], ['partial_outage', ComponentStatus.PartialOutage], - ['major_outage', ComponentStatus.MajorOutage] + ['major_outage', ComponentStatus.MajorOutage], + ['under_maintenance', ComponentStatus.UnderMaintenance] ]); export const getOverallStatusName = async (status: OverallStatus): Promise => { @@ -53,20 +57,11 @@ export const getComponentStatusName = async (status: ComponentStatus): Promise => { - await console.log(process.env); - if (process.env.GHACTION_GITHUB_STATUS_MOCKIT) { - // @ts-ignore - return require('../__tests__/data-status.json'); - } const http: httpm.HttpClient = new httpm.HttpClient('ghaction-github-status'); return (await http.getJson(`https://www.githubstatus.com/api/v2/status.json`)).result; }; export const summary = async (): Promise => { - if (process.env.GHACTION_GITHUB_STATUS_MOCKIT) { - // @ts-ignore - return require('../__tests__/data-summary.json'); - } const http: httpm.HttpClient = new httpm.HttpClient('ghaction-github-status'); return (await http.getJson(`https://www.githubstatus.com/api/v2/summary.json`)).result; }; diff --git a/src/main.ts b/src/main.ts index 7c3360d..26997eb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -47,6 +47,10 @@ async function run() { core.error(`GitHub Status: ${summary.status.description}`); break; } + case 'maintenance': { + core.warning(`GitHub Status: ${summary.status.description}`); + break; + } default: { core.info(`GitHub Status: ${summary.status.description}`); break; @@ -90,6 +94,10 @@ async function run() { compStatusText = chalk.red('Major outage'); break; } + case 'under_maintenance': { + compStatusText = chalk.blue('Under maintenance'); + break; + } } core.info(` • ${compStatusText}${new Array(30 - compStatusText.length).join(' ')} ${component.name}`); });