Skip to content

Commit 96b0e96

Browse files
authored
Fail if repo slug invalid, update readme
1 parent eea9980 commit 96b0e96

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

.github/workflows/website.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ jobs:
7979
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
8080
shell: Rscript {0}
8181

82-
8382
- name: Install system dependencies for R packages
8483
if: steps.check-rmd.outputs.count != 0
8584
run: |
@@ -98,6 +97,12 @@ jobs:
9897
ref: gh-pages
9998
path: gh-pages
10099

100+
- name: Validate workshop website
101+
# https://github.com/carpentries/styles/issues/551 is no longer relevant as styles shouldn't be used for
102+
# lessons but only workshop templates. So, always run the workshop checks now.
103+
run: make workshop-check
104+
if: always()
105+
101106
- name: Commit and Push
102107
if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
103108
run: |
@@ -118,8 +123,3 @@ jobs:
118123
git push origin gh-pages
119124
# return
120125
cd ..
121-
122-
# waiting for https://github.com/carpentries/styles/issues/551
123-
# to be addressed
124-
# - run: make lesson-check-all
125-
# if: always()

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ create a workshop website.
5050
3. Select the owner for your new repository.
5151
(This will probably be you, but may instead be an organization you belong to.)
5252

53-
4. Create a slug for your workshop website repository.
53+
4. Name your workshop website repository using the Carpentries slug format.
5454
The slug should have the form `YYYY-MM-DD-site`,
5555
e.g., `2016-12-01-oomza`,
5656
where `YYYY-MM-DD` is the start date of the workshop and 'oomza' is an example site name.
5757
If your workshop is held online, then the respository name should have `-online` in the end.
58-
e.g., `2016-12-01-oomza-online`
58+
e.g., `2016-12-01-oomza-online`. Your website build will fail if the name of your
59+
repository does not match the valid slug format!
5960

6061
5. Make sure the repository is public, leave "Include all branches" unchecked, and click
6162
on "Create repository from template".

bin/workshop_check.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -401,27 +401,28 @@ def check_config(reporter, filename):
401401
carpentry)
402402

403403

404-
def check_slug(reporter, repo_dir):
404+
def check_slug(reporter, filename, repo_dir):
405405
config = load_yaml(filename)
406406

407-
repo_name = os.path.basename(repo_dir)
407+
repo_name = os.path.basename(os.path.realpath(repo_dir))
408408

409409
carpentry = config.get('carpentry', None)
410-
kind = config.get('kind', None)
411-
412-
if carpentry == "cp":
413-
slugfmt = "YYYY-MM-DD-ttt-format"
414-
else:
415-
slugfmt = "YYYY-MM-DD-site-format"
416-
417-
fail_msg = f'Workshop website slug does not match the required `{slugfmt}`'
418410

419411
if carpentry in ('swc', 'dc', 'lc', 'cp'):
420-
reporter.check(
421-
bool(re.match(SLUG_PATTERN, repo_name)),
422-
fail_msg
412+
if carpentry == "cp":
413+
slugfmt = "YYYY-MM-DD-ttt[-online]"
414+
else:
415+
slugfmt = "YYYY-MM-DD-site[-online]"
416+
417+
fail_msg = (
418+
'Website repository name `{0}` does not match the required slug format: `{1}`. '
419+
'Please rename your repository to a valid slug using the rename option in the "Settings" menu.'
423420
)
424421

422+
if not bool(re.match(SLUG_PATTERN, repo_name)):
423+
print(fail_msg.format(repo_name, slugfmt))
424+
sys.exit(1)
425+
425426

426427
def main():
427428
'''Run as the main program.'''
@@ -436,7 +437,9 @@ def main():
436437

437438
reporter = Reporter()
438439
check_config(reporter, config_file)
439-
check_slug(reporter, root_dir)
440+
441+
check_slug(reporter, config_file, root_dir)
442+
440443
check_unwanted_files(root_dir, reporter)
441444
with open(index_file, encoding='utf-8') as reader:
442445
data = reader.read()

0 commit comments

Comments
 (0)