Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 9 additions & 5 deletions .github/workflows/markdown_lint.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: Markdown Lint

on: [push]
on:
pull_request:
push:
branches:
- master

jobs:
build:

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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 18 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
language_version: python3.13
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
3 changes: 1 addition & 2 deletions github_status_checker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def main():
"issues_prs_projects",
"actions",
"packages",
"pages",
"other"],
"pages"],
action="store",
type=str)

Expand Down
1 change: 0 additions & 1 deletion github_status_checker/controllers/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Commands(object):
"actions": "br0l2tvcx85d",
"packages": "st3j38cctv9l",
"pages": "vg70hn9s2tyj",
"other": "5l5rlzqm4yzy"
}

@staticmethod
Expand Down
2 changes: 2 additions & 0 deletions github_status_checker/models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
urllib3==1.25.7
requests~=2.0
requests==2.32.5
19 changes: 19 additions & 0 deletions tests/test_component.py
Original file line number Diff line number Diff line change
@@ -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)
30 changes: 11 additions & 19 deletions tests/test.py → tests/test_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down