Skip to content

Commit b2bd651

Browse files
authored
Revamp (#56)
- Port to using Click instead of arg_parser. - Expose options for external users to allow for more customization. - Increase coverage for paths by including paths that start with `/` or nothing. - Add retires for URLs before flagging them as broken. - Preform head request on URL which falls back to get if both not working flag as broken after retries count finishes. - Analyze all web URLs except the ones in skip_domains list. - Change Syntax of terminal comments to improve readability. - Add Spinner to indicate that the tool is working (Not compatible with all terminals) Signed-off-by: John Aziz <[email protected]>
1 parent 52036a4 commit b2bd651

29 files changed

+1056
-459
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Run Tests on Repositories
2+
3+
on:
4+
workflow_dispatch:
5+
6+
pull_request:
7+
branches: [ main ]
8+
paths:
9+
- '**.py'
10+
- ".github/workflows/python-tests.yaml"
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
tests-genai-repo:
17+
name: Python Tests on generative-ai-for-beginners
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Python 3.9
22+
id: python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: 3.9
26+
- name: Install dependencies
27+
run: |
28+
python3 -m pip install --upgrade pip
29+
python3 -m pip install -e .
30+
31+
- name: Clone Repo
32+
run: git clone https://github.com/microsoft/generative-ai-for-beginners
33+
34+
- name: Test Check Broken Paths in generative-ai-for-beginners
35+
if: always()
36+
run: |
37+
cd generative-ai-for-beginners
38+
markdown-checker -d . -f check_broken_paths -gu ''
39+
- name: Test Check URLs Country locale in generative-ai-for-beginners
40+
if: always()
41+
run: |
42+
cd generative-ai-for-beginners
43+
markdown-checker -d . -f check_urls_locale -gu ''
44+
- name: Test Check Broken URLs in generative-ai-for-beginners
45+
if: always()
46+
run: |
47+
cd generative-ai-for-beginners
48+
markdown-checker -d . -f check_broken_urls -gu ''
49+
50+
tests-openai-repo:
51+
name: Python Tests on azure-search-openai-demo
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Set up Python 3.9
56+
id: python
57+
uses: actions/setup-python@v5
58+
with:
59+
python-version: 3.9
60+
- name: Install dependencies
61+
run: |
62+
python3 -m pip install --upgrade pip
63+
python3 -m pip install -e .
64+
65+
- name: Clone Repo
66+
run: git clone https://github.com/Azure-Samples/azure-search-openai-demo
67+
68+
- name: Test Check Broken Paths in azure-search-openai-demo
69+
if: always()
70+
run: |
71+
cd azure-search-openai-demo
72+
markdown-checker -d . -f check_broken_paths -gu ''
73+
- name: Test Check URLs Country locale in azure-search-openai-demo
74+
if: always()
75+
run: |
76+
cd azure-search-openai-demo
77+
markdown-checker -d . -f check_urls_locale -gu ''
78+
79+
- name: Test Check Broken URLs in azure-search-openai-demo
80+
if: always()
81+
run: |
82+
cd azure-search-openai-demo
83+
markdown-checker -d . -f check_broken_urls -gu ''
84+
85+
tests-phicookbook-repo:
86+
name: Python Tests on Phi-3CookBook
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v4
90+
- name: Set up Python 3.9
91+
id: python
92+
uses: actions/setup-python@v5
93+
with:
94+
python-version: 3.9
95+
- name: Install dependencies
96+
run: |
97+
python3 -m pip install --upgrade pip
98+
python3 -m pip install -e .
99+
100+
- name: Clone Repo
101+
run: git clone https://github.com/microsoft/Phi-3CookBook
102+
103+
- name: Test Check Broken Paths in Phi-3CookBook
104+
if: always()
105+
run: |
106+
cd Phi-3CookBook
107+
markdown-checker -d . -f check_broken_paths -gu ''
108+
- name: Test Check URLs Country locale in Phi-3CookBook
109+
if: always()
110+
run: |
111+
cd Phi-3CookBook
112+
markdown-checker -d . -f check_urls_locale -gu ''
113+
- name: Test Check Broken URLs in Phi-3CookBook
114+
if: always()
115+
run: |
116+
cd Phi-3CookBook
117+
markdown-checker -d . -f check_broken_urls -gu ''
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Run Python Matrix Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main ]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
python-matrix-tests:
13+
if: ${{ always() }} # Always run even if a matrix candidate fails
14+
name: Python ${{ matrix.python_version }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest]
19+
python_version: ["3.9", "3.10", "3.11", "3.12"]
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python_version }}
25+
architecture: x64
26+
- name: Install dependencies
27+
run: |
28+
python3 -m pip install --upgrade pip
29+
python3 -m pip install -e .
30+
31+
- name: Clone Testing Repositories
32+
run: |
33+
git clone https://github.com/Azure-Samples/azure-search-openai-demo
34+
git clone https://github.com/microsoft/generative-ai-for-beginners
35+
git clone https://github.com/microsoft/Phi-3CookBook
36+
37+
- name: Test Check Broken Paths in azure-search-openai-demo
38+
if: always()
39+
run: |
40+
cd azure-search-openai-demo
41+
markdown-checker -d . -f check_broken_paths -gu ''
42+
- name: Test Check Broken Paths in generative-ai-for-beginners
43+
if: always()
44+
run: |
45+
cd generative-ai-for-beginners
46+
markdown-checker -d . -f check_broken_paths -gu ''
47+
- name: Test Check Broken Paths in Phi-3CookBook
48+
if: always()
49+
run: |
50+
cd Phi-3CookBook
51+
markdown-checker -d . -f check_broken_paths -gu ''
52+
53+
- name: Test Check URLs Country locale in azure-search-openai-demo
54+
if: always()
55+
run: |
56+
cd azure-search-openai-demo
57+
markdown-checker -d . -f check_urls_locale -gu ''
58+
- name: Test Check URLs Country locale in generative-ai-for-beginners
59+
if: always()
60+
run: |
61+
cd generative-ai-for-beginners
62+
markdown-checker -d . -f check_urls_locale -gu ''
63+
- name: Test Check URLs Country locale in Phi-3CookBook
64+
if: always()
65+
run: |
66+
cd Phi-3CookBook
67+
markdown-checker -d . -f check_urls_locale -gu ''
68+
69+
- name: Test Check Broken URLs in azure-search-openai-demo
70+
if: always()
71+
run: |
72+
cd azure-search-openai-demo
73+
markdown-checker -d . -f check_broken_urls -gu ''
74+
- name: Test Check Broken URLs in generative-ai-for-beginners
75+
if: always()
76+
run: |
77+
cd generative-ai-for-beginners
78+
markdown-checker -d . -f check_broken_urls -gu ''
79+
- name: Test Check Broken URLs in Phi-3CookBook
80+
if: always()
81+
run: |
82+
cd Phi-3CookBook
83+
markdown-checker -d . -f check_broken_urls -gu ''

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions/checkout@v4
1919
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
2020
id: python
21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: ${{ env.DEFAULT_PYTHON }}
2424
- name: Install requirements

pyproject.toml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[build-system]
2-
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta"
4-
51
[project]
62
name = "markdown-checker"
73
description= "A markdown link validation reporting tool"
@@ -13,19 +9,23 @@ readme = "README.md"
139

1410
requires-python = ">=3.9"
1511
dependencies = [
12+
"click",
1613
"requests",
17-
"types-requests",
18-
]
14+
]
1915
classifiers = [
2016
"Development Status :: 5 - Production/Stable",
17+
"Environment :: Console",
2118
"License :: OSI Approved :: MIT License",
2219
"Operating System :: OS Independent",
23-
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python",
21+
"Programming Language :: Python :: 3 :: Only",
2422
"Programming Language :: Python :: 3.9",
2523
"Programming Language :: Python :: 3.10",
2624
"Programming Language :: Python :: 3.11",
2725
"Programming Language :: Python :: 3.12",
28-
]
26+
"Topic :: Software Development :: Libraries :: Python Modules",
27+
"Topic :: Software Development :: Quality Assurance",
28+
]
2929

3030
[project.urls]
3131
Homepage = "https://github.com/john0isaac/markdown-checker"
@@ -40,7 +40,8 @@ Releases = "https://github.com/john0isaac/markdown-checker/releases"
4040
[project.optional-dependencies]
4141
dev = [
4242
"pre-commit",
43-
"mypy"
43+
"mypy",
44+
"types-requests",
4445
]
4546
lint = [
4647
"ruff"
@@ -61,7 +62,17 @@ lint.select = ["E", "F", "I", "UP"]
6162
line-length = 120
6263
target-version = "py39"
6364
src = ["src"]
65+
lint.isort.known-first-party = ["markdown_checker"]
6466
output-format = "full"
6567

68+
[tool.mypy]
69+
check_untyped_defs = true
70+
python_version = 3.9
71+
exclude = [".venv/*"]
72+
6673
[project.scripts]
67-
markdown-checker = "markdown_checker.validate_markdown:main"
74+
markdown-checker = "markdown_checker:main_with_spinner"
75+
76+
[build-system]
77+
requires = ["setuptools", "wheel"]
78+
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)