diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 636c286..308d733 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,24 +1,31 @@ name: Python Lint -on: [push] +on: + pull_request: + push: + branches: + - master jobs: build: - - runs-on: ubuntu-latest + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v1 - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: Install flake8 dependencies - run: | - python -m pip install --upgrade pip - - name: Lint with flake8 - run: | - pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - uses: actions/checkout@v5 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install flake8 dependencies + run: | + python -m pip install --upgrade pip + # TODO: check black formatting (once we reformat the repo) + - name: Lint with flake8 + run: | + pip install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics diff --git a/.github/workflows/markdown_lint.yml b/.github/workflows/markdown_lint.yml index 30957b7..9125693 100644 --- a/.github/workflows/markdown_lint.yml +++ b/.github/workflows/markdown_lint.yml @@ -1,6 +1,10 @@ name: Markdown Lint -on: [push] +on: + pull_request: + push: + branches: + - master jobs: build: @@ -8,11 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Set up Ruby 2.6 - uses: actions/setup-ruby@v1 + - uses: actions/checkout@v5 + - name: Set up Ruby 3.4 + uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6.x + ruby-version: '3.4' - name: Lint Markdown run: | gem install mdl diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index ee7c4b0..b419c62 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -8,9 +8,9 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index da5bc39..7b6afdc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,20 +1,25 @@ name: Tests -on: [push] +on: + pull_request: + push: + branches: + - master jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v1 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install Dependencies - run: pip install -r requirements.txt - - name: Test with pytest - run: | - pip install pytest - pytest tests/test.py + - uses: actions/checkout@v5 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install Dependencies + run: pip install -r requirements.txt + - name: Test + run: | + make test diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 19c458d..5c305f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 25.1.0 hooks: - id: black types: [python] - language_version: python3.7 \ No newline at end of file + language_version: python3.13 \ No newline at end of file diff --git a/Makefile b/Makefile index 6f428ec..821a305 100644 --- a/Makefile +++ b/Makefile @@ -11,5 +11,8 @@ disttest: package distprod: package python3 -m twine upload dist/* +test: + python3 -m unittest discover -s tests + clean: rm -rf .pytest_cache/ dist/ *.egg-info/ \ No newline at end of file diff --git a/github_status_checker/__main__.py b/github_status_checker/__main__.py index d1f0644..fe3ca04 100644 --- a/github_status_checker/__main__.py +++ b/github_status_checker/__main__.py @@ -17,8 +17,7 @@ def main(): "issues_prs_projects", "actions", "packages", - "pages", - "other"], + "pages"], action="store", type=str) diff --git a/github_status_checker/controllers/commands.py b/github_status_checker/controllers/commands.py index 2d9f0d5..f3284ea 100644 --- a/github_status_checker/controllers/commands.py +++ b/github_status_checker/controllers/commands.py @@ -13,7 +13,6 @@ class Commands(object): "actions": "br0l2tvcx85d", "packages": "st3j38cctv9l", "pages": "vg70hn9s2tyj", - "other": "5l5rlzqm4yzy" } @staticmethod diff --git a/github_status_checker/models/component.py b/github_status_checker/models/component.py index b4ef761..e25b8d5 100644 --- a/github_status_checker/models/component.py +++ b/github_status_checker/models/component.py @@ -13,6 +13,7 @@ def __init__(self, page_id: str, position: int, status: ComponentStatus, + start_date: str, updated_at: str, showcase: bool, group_id: Any, @@ -26,6 +27,7 @@ def __init__(self, self.page_id = page_id self.position = position self.status = status + self.start_date = start_date self.updated_at = updated_at self.showcase = showcase self.group_id = group_id diff --git a/requirements.txt b/requirements.txt index 2608b48..727711c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -urllib3==1.25.7 -requests~=2.0 \ No newline at end of file +requests==2.32.5 diff --git a/tests/test_component.py b/tests/test_component.py new file mode 100644 index 0000000..23a51b2 --- /dev/null +++ b/tests/test_component.py @@ -0,0 +1,19 @@ +import unittest +from github_status_checker.controllers.commands import Commands + +COMPONENT_TARGETS = [ + "git", + "api", + "webhooks", + "issues_prs_projects", + "actions", + "packages", + "pages" +] + +class TestComponentCheck(unittest.TestCase): + def test_check_runs_for_all_components(self): + for component in COMPONENT_TARGETS: + with self.subTest(component=component): + # Should not raise for valid components, will reach out to the real API + Commands.check(component_arg=component) diff --git a/tests/test.py b/tests/test_serialize.py similarity index 68% rename from tests/test.py rename to tests/test_serialize.py index 7321f5b..083bf71 100644 --- a/tests/test.py +++ b/tests/test_serialize.py @@ -19,12 +19,9 @@ def setUp(self) -> None: pass def test_deserialize_good(self): - good_json = """{"page":{"id":"kctbh9vrtdwd","name":"GitHub","url":"https://www.githubstatus.com","time_zone":"Etc/UTC","updated_at":"2019-12-30T08:15:33.297Z"},"components":[{"id":"8l4ygp009s5s","name":"Git Operations","status":"operational","created_at":"2017-01-31T20:05:05.370Z","updated_at":"2019-12-13T18:46:03.911Z","position":1,"description":"Performance of git clones, pulls, pushes, and associated operations","showcase":true,"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":"2019-12-13T18:46:02.799Z","position":2,"description":"Requests for GitHub APIs","showcase":true,"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":"2019-12-19T23:13:07.086Z","position":3,"description":"Real time HTTP callbacks of user-generated and system events","showcase":true,"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":"2019-11-13T18:02:47.782Z","position":4,"description":null,"showcase":false,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"kr09ddfgbfsf","name":"Issues, PRs, Projects","status":"operational","created_at":"2017-01-31T20:01:46.638Z","updated_at":"2019-12-13T18:46:06.900Z","position":5,"description":"Web requests for github.com UI and services","showcase":true,"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":"2019-12-13T18:46:01.547Z","position":6,"description":"Workflows, Compute and Orchestration for GitHub Actions","showcase":true,"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":"2019-12-10T11:40:31.724Z","position":7,"description":"API requests and webhook delivery for GitHub Packages","showcase":true,"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":"2019-12-13T18:46:06.226Z","position":8,"description":"Frontend application and API servers for Pages builds","showcase":true,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false},{"id":"5l5rlzqm4yzy","name":"Other","status":"operational","created_at":"2019-11-13T18:03:05.012Z","updated_at":"2019-12-19T23:13:02.972Z","position":9,"description":"Other","showcase":false,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false}],"incidents":[],"scheduled_maintenances":[],"status":{"indicator":"none","description":"All Systems Operational"}}""" + good_json = """{"page":{"id":"kctbh9vrtdwd","name":"GitHub","url":"https://www.githubstatus.com","time_zone":"Etc/UTC","updated_at":"2019-12-30T08:15:33.297Z"},"components":[{"id":"8l4ygp009s5s","name":"Git Operations","status":"operational","created_at":"2017-01-31T20:05:05.370Z","updated_at":"2019-12-13T18:46:03.911Z","position":1,"description":"Performance of git clones, pulls, pushes, and associated operations","showcase":true,"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":"2019-12-13T18:46:02.799Z","position":2,"description":"Requests for GitHub APIs","showcase":true,"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":"2019-12-19T23:13:07.086Z","position":3,"description":"Real time HTTP callbacks of user-generated and system events","showcase":true,"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":"2019-11-13T18:02:47.782Z","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, PRs, Projects","status":"operational","created_at":"2017-01-31T20:01:46.638Z","updated_at":"2019-12-13T18:46:06.900Z","position":5,"description":"Web requests for github.com UI and services","showcase":true,"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":"2019-12-13T18:46:01.547Z","position":6,"description":"Workflows, Compute and Orchestration for GitHub Actions","showcase":true,"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":"2019-12-10T11:40:31.724Z","position":7,"description":"API requests and webhook delivery for GitHub Packages","showcase":true,"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":"2019-12-13T18:46:06.226Z","position":8,"description":"Frontend application and API servers for Pages builds","showcase":true,"start_date":null,"group_id":null,"page_id":"kctbh9vrtdwd","group":false,"only_show_if_degraded":false}],"incidents":[],"scheduled_maintenances":[],"status":{"indicator":"none","description":"All Systems Operational"}}""" - try: - Summary.from_json(json_=json.loads(good_json)) - except TypeError: - self.fail() + Summary.from_json(json_=json.loads(good_json)) class TestOutagePayload(TestCase): @@ -47,6 +44,7 @@ def setUp(self) -> None: "position": 1, "description": "Performance of git clones, pulls, pushes, and associated operations", "showcase": true, + "start_date": null, "group_id": null, "page_id": "kctbh9vrtdwd", "group": false, @@ -61,6 +59,7 @@ def setUp(self) -> None: "position": 2, "description": "Requests for GitHub APIs", "showcase": true, + "start_date": null, "group_id": null, "page_id": "kctbh9vrtdwd", "group": false, @@ -75,6 +74,7 @@ def setUp(self) -> None: "position": 3, "description": "Real time HTTP callbacks of user-generated and system events", "showcase": true, + "start_date": null, "group_id": null, "page_id": "kctbh9vrtdwd", "group": false, @@ -89,6 +89,7 @@ def setUp(self) -> None: "position": 4, "description": null, "showcase": false, + "start_date": null, "group_id": null, "page_id": "kctbh9vrtdwd", "group": false, @@ -103,6 +104,7 @@ def setUp(self) -> None: "position": 5, "description": "Web requests for github.com UI and services", "showcase": true, + "start_date": null, "group_id": null, "page_id": "kctbh9vrtdwd", "group": false, @@ -117,6 +119,7 @@ def setUp(self) -> None: "position": 6, "description": "Workflows, Compute and Orchestration for GitHub Actions", "showcase": true, + "start_date": null, "group_id": null, "page_id": "kctbh9vrtdwd", "group": false, @@ -131,6 +134,7 @@ def setUp(self) -> None: "position": 7, "description": "API requests and webhook delivery for GitHub Packages", "showcase": true, + "start_date": null, "group_id": null, "page_id": "kctbh9vrtdwd", "group": false, @@ -145,20 +149,7 @@ def setUp(self) -> None: "position": 8, "description": "Frontend application and API servers for Pages builds", "showcase": true, - "group_id": null, - "page_id": "kctbh9vrtdwd", - "group": false, - "only_show_if_degraded": false - }, - { - "id": "5l5rlzqm4yzy", - "name": "Other", - "status": "operational", - "created_at": "2019-11-13T18:03:05.012Z", - "updated_at": "2020-03-06T00:22:12.900Z", - "position": 9, - "description": "Other", - "showcase": false, + "start_date": null, "group_id": null, "page_id": "kctbh9vrtdwd", "group": false, @@ -223,6 +214,7 @@ def setUp(self) -> None: "position": 4, "description": null, "showcase": false, + "start_date": null, "group_id": null, "page_id": "kctbh9vrtdwd", "group": false,