Skip to content

Commit eaa6702

Browse files
webknjazhugovk
andauthored
Use CSV-separated outputs @ get-changed-files @ CI (#105151)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 9c44656 commit eaa6702

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,9 @@ jobs:
8787
with:
8888
filter: |
8989
Doc/**
90-
# Temporarily skip paths with spaces
91-
# (i.e. "C API", "Core and Builtins")
92-
# to avoid "Error: One of your files includes a space".
93-
# Pending https://github.com/python/core-workflow/issues/186
94-
# Misc/**
95-
Misc/NEWS.d/next/Build/**
96-
Misc/NEWS.d/next/Documentation/**
97-
Misc/NEWS.d/next/IDLE/**
98-
Misc/NEWS.d/next/Library/**
99-
Misc/NEWS.d/next/Security/**
100-
Misc/NEWS.d/next/Tests/**
101-
Misc/NEWS.d/next/Tools-Demos/**
102-
Misc/NEWS.d/next/Windows/**
103-
Misc/NEWS.d/next/macOS/**
90+
Misc/**
10491
.github/workflows/reusable-docs.yml
92+
format: csv # works for paths with spaces
10593
- name: Check for docs changes
10694
if: >-
10795
github.event_name == 'pull_request'

.github/workflows/reusable-docs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ jobs:
3838
uses: Ana06/[email protected]
3939
with:
4040
filter: "Doc/**"
41+
format: csv # works for paths with spaces
4142
- name: 'Build changed files in nit-picky mode'
4243
if: github.event_name == 'pull_request'
4344
continue-on-error: true
4445
run: |
46+
set -Eeuo pipefail
4547
# Mark files the pull request modified
46-
touch ${{ steps.changed_files.outputs.added_modified }}
48+
python Doc/tools/touch-clean-files.py --clean '${{ steps.changed_files.outputs.added_modified }}'
4749
# Build docs with the '-n' (nit-picky) option; convert warnings to annotations
4850
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n --keep-going" html 2>&1 |
4951
python Doc/tools/warnings-to-gh-actions.py

Doc/tools/touch-clean-files.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
Touch files that must pass Sphinx nit-picky mode
44
so they are rebuilt and we can catch regressions.
55
"""
6-
6+
import argparse
7+
import csv
8+
import sys
79
from pathlib import Path
810

911
wrong_directory_msg = "Must run this script from the repo root"
@@ -28,14 +30,33 @@
2830
rst for rst in Path("Doc/").rglob("*.rst") if rst.parts[1] not in EXCLUDE_SUBDIRS
2931
}
3032

31-
with Path("Doc/tools/.nitignore").open() as clean_files:
32-
DIRTY = {
33+
34+
parser = argparse.ArgumentParser(
35+
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
36+
)
37+
parser.add_argument("-c", "--clean", help="Comma-separated list of clean files")
38+
args = parser.parse_args()
39+
40+
if args.clean:
41+
clean_files = next(csv.reader([args.clean]))
42+
CLEAN = {
3343
Path(filename.strip())
3444
for filename in clean_files
35-
if filename.strip() and not filename.startswith("#")
45+
if Path(filename.strip()).is_file()
3646
}
37-
38-
CLEAN = ALL_RST - DIRTY - EXCLUDE_FILES
47+
elif args.clean is not None:
48+
print(
49+
"Not touching any files: an empty string `--clean` arg value passed.",
50+
)
51+
sys.exit(0)
52+
else:
53+
with Path("Doc/tools/.nitignore").open() as ignored_files:
54+
IGNORED = {
55+
Path(filename.strip())
56+
for filename in ignored_files
57+
if filename.strip() and not filename.startswith("#")
58+
}
59+
CLEAN = ALL_RST - IGNORED - EXCLUDE_FILES
3960

4061
print("Touching:")
4162
for filename in sorted(CLEAN):

0 commit comments

Comments
 (0)