File tree Expand file tree Collapse file tree 2 files changed +33
-13
lines changed Expand file tree Collapse file tree 2 files changed +33
-13
lines changed Original file line number Diff line number Diff line change 2
2
from git import Repo
3
3
4
4
5
- def main (repo_path ):
5
+ def main (repo_path , main_branch , ** kw ):
6
6
r = Repo (repo_path )
7
7
8
8
# NOTE: assumes the main branch is named "main"
9
9
files_changed = r .git .diff (
10
- f'{ str (r .head .object .hexsha )} ..origin/main ' ,
10
+ f'{ str (r .head .object .hexsha )} ..{ main_branch } ' ,
11
11
'--name-only' ).split ("\n " )
12
12
files_changed = [f for f in files_changed if f .endswith ('.ipynb' )]
13
13
if files_changed :
14
14
print (" " .join (files_changed ))
15
15
16
16
17
17
if __name__ == "__main__" :
18
- try :
19
- repo_path = sys .argv [1 ]
20
- except IndexError :
21
- print ("ERROR: did not receive a repo path.\n "
22
- "Usage: get_modified_tutorials.py <ROOT TUTORIALS REPO PATH>" )
23
- sys .exit (1 )
18
+ from argparse import ArgumentParser
24
19
25
- main (repo_path )
20
+ parser = ArgumentParser ()
21
+ parser .add_argument (
22
+ '-r' , '--repo-path' ,
23
+ dest = 'repo_path' ,
24
+ default = '.' ,
25
+ help = 'The path to the root of the astropy-tutorials repository folder.'
26
+ )
27
+ parser .add_argument (
28
+ '--main-branch' ,
29
+ dest = 'main_branch' ,
30
+ default = 'main' ,
31
+ help = ('The name of the main branch to compare against. Default is '
32
+ '"main" but on CI it should be origin/main.' )
33
+ )
34
+ args = parser .parse_args ()
35
+ main (** vars (args ))
Original file line number Diff line number Diff line change 1
- default : all
1
+ default : build
2
2
3
- all : envcheck execute convert
3
+ TUTORIALS_MAIN_BRANCH ?= main
4
+ MODIFIED := $(shell python .github/get_modified_tutorials.py --main-branch $(TUTORIALS_MAIN_BRANCH ) )
5
+
6
+ build : envcheck execute convert
7
+ buildall : envcheck executeall convertall
4
8
5
9
envcheck :
6
10
python -c " import pkg_resources; pkg_resources.require(open('pip-requirements.txt', mode='r')); print('Your environment is all set!')"
7
11
8
12
execute :
9
- nbcollection execute --timeout=600 --flatten --build-path=. -v tutorials
13
+ nbcollection execute --timeout=600 --flatten --build-path=. -v ${MODIFIED}
10
14
11
15
convert :
16
+ nbcollection convert --flatten --build-path=. -v --make-index --index-template=templates/index.tpl ${MODIFIED}
17
+
18
+ executeall :
19
+ nbcollection execute --timeout=600 --flatten --build-path=. -v tutorials
20
+
21
+ convertall :
12
22
nbcollection convert --flatten --build-path=. -v --make-index --index-template=templates/index.tpl tutorials
13
23
14
24
clean :
15
25
rm -rf _build
16
26
17
- .PHONY : all clean execute convert
27
+ .PHONY : all clean execute convert executeall convertall build buildall
You can’t perform that action at this time.
0 commit comments