Skip to content

Commit 2ef6f3a

Browse files
authored
Merge branch 'master' into code-block
2 parents b2c03c5 + d1852a5 commit 2ef6f3a

File tree

8 files changed

+61
-10
lines changed

8 files changed

+61
-10
lines changed

.github/workflows/benchmark.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313

1414
- name: Set up Python 3.8
1515
uses: actions/setup-python@v4

.github/workflows/fuzz.yml

+2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ name: fuzzing
66
# to guard against code introducing crashes in the Markdown parsing,
77
# which should in principle always run against any text input.
88
# See: https://google.github.io/oss-fuzz/getting-started/continuous-integration/#how-it-works
9+
# Note, to reproduce a crash locally, copy to `testcase` file` and run: `tox -e fuzz`
910

1011
on:
1112
pull_request:
13+
paths-ignore: ['docs/**', 'tests/**']
1214

1315
jobs:
1416
Fuzzing:

.github/workflows/tests.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2323
- name: Set up Python 3.8
2424
uses: actions/setup-python@v4
2525
with:
@@ -34,7 +34,7 @@ jobs:
3434
python-version: ['pypy-3.7', '3.7', '3.8', '3.9', '3.10', '3.11']
3535

3636
steps:
37-
- uses: actions/checkout@v2
37+
- uses: actions/checkout@v3
3838
- name: Set up Python ${{ matrix.python-version }}
3939
uses: actions/setup-python@v4
4040
with:
@@ -63,7 +63,7 @@ jobs:
6363
matrix:
6464
python-version: ['3.8']
6565
steps:
66-
- uses: actions/checkout@v2
66+
- uses: actions/checkout@v3
6767
- name: Set up Python ${{ matrix.python-version }}
6868
uses: actions/setup-python@v4
6969
with:
@@ -83,7 +83,7 @@ jobs:
8383

8484
runs-on: ubuntu-latest
8585
steps:
86-
- uses: actions/checkout@v2
86+
- uses: actions/checkout@v3
8787

8888
- name: Set up Python 3.8
8989
uses: actions/setup-python@v4
@@ -113,7 +113,7 @@ jobs:
113113
runs-on: ubuntu-latest
114114
steps:
115115
- name: Checkout source
116-
uses: actions/checkout@v2
116+
uses: actions/checkout@v3
117117
- name: Set up Python 3.8
118118
uses: actions/setup-python@v4
119119
with:

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repos:
2929
- id: isort
3030

3131
- repo: https://github.com/psf/black
32-
rev: 23.1.0
32+
rev: 23.3.0
3333
hooks:
3434
- id: black
3535

@@ -40,7 +40,7 @@ repos:
4040
additional_dependencies: [flake8-bugbear~=22.7]
4141

4242
- repo: https://github.com/pre-commit/mirrors-mypy
43-
rev: v1.0.1
43+
rev: v1.2.0
4444
hooks:
4545
- id: mypy
4646
additional_dependencies: [mdurl]

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def run_apidoc(app):
102102
this_folder = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
103103
api_folder = os.path.join(this_folder, "api")
104104
module_path = os.path.normpath(os.path.join(this_folder, "../"))
105-
ignore_paths = ["../profiler.py", "../conftest.py", "../tests", "../benchmarking"]
105+
ignore_paths = ["../scripts", "../conftest.py", "../tests", "../benchmarking"]
106106
ignore_paths = [
107107
os.path.normpath(os.path.join(this_folder, p)) for p in ignore_paths
108108
]

scripts/build_fuzzers.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""Build fuzzers idempotently in a given folder."""
2+
import argparse
3+
from pathlib import Path
4+
import subprocess
5+
6+
7+
def main():
8+
"""Build fuzzers idempotently in a given folder."""
9+
parser = argparse.ArgumentParser()
10+
parser.add_argument("folder")
11+
args = parser.parse_args()
12+
folder = Path(args.folder)
13+
if not folder.exists():
14+
print(f"Cloning google/oss-fuzz into: {folder}")
15+
folder.mkdir(parents=True)
16+
subprocess.check_call(
17+
[
18+
"git",
19+
"clone",
20+
"--single-branch",
21+
"https://github.com/google/oss-fuzz",
22+
str(folder),
23+
]
24+
)
25+
else:
26+
print(f"Using google/oss-fuzz in: {folder}")
27+
if not (folder / "build").exists():
28+
print(f"Building fuzzers in: {folder / 'build'}")
29+
subprocess.check_call(
30+
[
31+
"python",
32+
str(folder / "infra" / "helper.py"),
33+
"build_fuzzers",
34+
"markdown-it-py",
35+
]
36+
)
37+
else:
38+
print(f"Using existing fuzzers in: {folder / 'build'}")
39+
40+
41+
if __name__ == "__main__":
42+
main()
File renamed without changes.

tox.ini

+8-1
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,18 @@ allowlist_externals =
5555
dot
5656
commands =
5757
mkdir -p "{toxworkdir}/prof"
58-
python -m cProfile -o "{toxworkdir}/prof/output.pstats" profiler.py
58+
python -m cProfile -o "{toxworkdir}/prof/output.pstats" scripts/profiler.py
5959
gprof2dot -f pstats -o "{toxworkdir}/prof/output.dot" "{toxworkdir}/prof/output.pstats"
6060
dot -Tsvg -o "{toxworkdir}/prof/output.svg" "{toxworkdir}/prof/output.dot"
6161
python -c 'import pathlib; print("profiler svg output under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "prof" / "output.svg"))'
6262

63+
[testenv:fuzz]
64+
description = run fuzzer on testcase file
65+
; See: https://google.github.io/oss-fuzz/
66+
deps = atheris
67+
commands_pre = python scripts/build_fuzzers.py {envdir}/oss-fuzz
68+
commands = python {envdir}/oss-fuzz/infra/helper.py reproduce markdown-it-py fuzz_markdown {posargs:testcase}
69+
6370
[flake8]
6471
max-line-length = 100
6572
extend-ignore = E203

0 commit comments

Comments
 (0)