diff --git a/README.md b/README.md index cebcdd23..1d37fa17 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,10 @@ create a workshop website. 3. Select the owner for your new repository. (This will probably be you, but may instead be an organization you belong to.) -4. Choose a name for your workshop website repository. - This name should have the form `YYYY-MM-DD-site`, +4. Create a slug for your workshop website repository. + The slug should have the form `YYYY-MM-DD-site`, e.g., `2016-12-01-oomza`, - where `YYYY-MM-DD` is the start date of the workshop. + where `YYYY-MM-DD` is the start date of the workshop and 'oomza' is an example site name. If your workshop is held online, then the respository name should have `-online` in the end. e.g., `2016-12-01-oomza-online` diff --git a/bin/workshop_check.py b/bin/workshop_check.py index d97eb7c2..9f8fe61a 100644 --- a/bin/workshop_check.py +++ b/bin/workshop_check.py @@ -15,6 +15,7 @@ HUMANTIME_PATTERN = r'((0?[1-9]|1[0-2]):[0-5]\d(am|pm)(-|to)(0?[1-9]|1[0-2]):[0-5]\d(am|pm))|((0?\d|1\d|2[0-3]):[0-5]\d(-|to)(0?\d|1\d|2[0-3]):[0-5]\d)' EVENTBRITE_PATTERN = r'\d{9,10}' URL_PATTERN = r'https?://.+' +SLUG_PATTERN = r'\d{4}-\d{2}-\d{2}-[A-z0-9\-\_]+' # Defaults. CARPENTRIES = ("dc", "swc", "lc", "cp") @@ -400,6 +401,28 @@ def check_config(reporter, filename): carpentry) +def check_slug(reporter, repo_dir): + config = load_yaml(filename) + + repo_name = os.path.basename(repo_dir) + + carpentry = config.get('carpentry', None) + kind = config.get('kind', None) + + if carpentry == "cp": + slugfmt = "YYYY-MM-DD-ttt-format" + else: + slugfmt = "YYYY-MM-DD-site-format" + + fail_msg = f'Workshop website slug does not match the required `{slugfmt}`' + + if carpentry in ('swc', 'dc', 'lc', 'cp'): + reporter.check( + bool(re.match(SLUG_PATTERN, repo_name)), + fail_msg + ) + + def main(): '''Run as the main program.''' @@ -413,6 +436,7 @@ def main(): reporter = Reporter() check_config(reporter, config_file) + check_slug(reporter, root_dir) check_unwanted_files(root_dir, reporter) with open(index_file, encoding='utf-8') as reader: data = reader.read()