Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit 26f4ddb

Browse files
author
Trevor Keller
committed
updates for Travis-CI integration
1 parent ac65690 commit 26f4ddb

File tree

2 files changed

+121
-45
lines changed

2 files changed

+121
-45
lines changed

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Travis-CI config for https://github.com/hpc-carpentry/hpc-intro
2+
# Results at https://travis-ci.org/github/hpc-carpentry/hpc-intro
3+
4+
dist: xenial
5+
language: python
6+
python: 3.7
7+
8+
branches:
9+
only:
10+
- gh-pages
11+
- /.*/
12+
13+
before_install:
14+
install:
15+
script:
16+
17+
jobs:
18+
include:
19+
- stage: "Check for typos and spelling mistakes"
20+
before_install: # Don't need everything to build the site
21+
install:
22+
pip install codespell
23+
script:
24+
codespell --skip="assets,*.svg,bin" --quiet-level=2 -L "rouge,dropse,namd,hist"
25+
- stage: "Build the site"
26+
before_install:
27+
- sudo apt-get update -y
28+
- rvm default
29+
- gem install bundler jekyll json kramdown
30+
- bundle config build.nokogiri --use-system-libraries
31+
- bundle install
32+
install:
33+
pip install pyyaml
34+
script:
35+
- make lesson-check-all
36+
- make --always-make site
37+

Makefile

Lines changed: 84 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,72 @@
1+
# Use /bin/bash instead of /bin/sh
2+
export SHELL = /bin/bash
3+
14
## ========================================
25
## Commands for both workshop and lesson websites.
36

47
# Settings
58
MAKEFILES=Makefile $(wildcard *.mk)
6-
JEKYLL=jekyll
9+
JEKYLL=bundle config set path '.vendor/bundle' && bundle install && bundle update && bundle exec jekyll
710
PARSER=bin/markdown_ast.rb
811
DST=_site
912

13+
# Check Python 3 is installed and determine if it's called via python3 or python
14+
# (https://stackoverflow.com/a/4933395)
15+
PYTHON3_EXE := $(shell which python3 2>/dev/null)
16+
ifneq (, $(PYTHON3_EXE))
17+
ifeq (,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE))))
18+
PYTHON := python3
19+
endif
20+
endif
21+
22+
ifeq (,$(PYTHON))
23+
PYTHON_EXE := $(shell which python 2>/dev/null)
24+
ifneq (, $(PYTHON_EXE))
25+
PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
26+
PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
27+
ifneq (3, ${PYTHON_VERSION_MAJOR})
28+
$(error "Your system does not appear to have Python 3 installed.")
29+
endif
30+
PYTHON := python
31+
else
32+
$(error "Your system does not appear to have any Python installed.")
33+
endif
34+
endif
35+
36+
1037
# Controls
1138
.PHONY : commands clean files
12-
.NOTPARALLEL:
13-
all : commands
1439

15-
## commands : show all commands.
16-
commands :
17-
@grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g'
40+
# Default target
41+
.DEFAULT_GOAL := commands
42+
43+
## I. Commands for both workshop and lesson websites
44+
## =================================================
1845

19-
## serve : run a local server.
46+
## * serve : render website and run a local server
2047
serve : lesson-md
2148
${JEKYLL} serve
2249

23-
## site : build files but do not run a server.
50+
## * site : build website but do not run a server
2451
site : lesson-md
2552
${JEKYLL} build
2653

27-
# repo-check : check repository settings.
54+
## * docker-serve : use Docker to serve the site
55+
docker-serve :
56+
docker pull carpentries/lesson-docker:latest
57+
docker run --rm -it \
58+
-v $${PWD}:/home/rstudio \
59+
-p 4000:4000 \
60+
-p 8787:8787 \
61+
-e USERID=$$(id -u) \
62+
-e GROUPID=$$(id -g) \
63+
carpentries/lesson-docker:latest
64+
65+
## * repo-check : check repository settings
2866
repo-check :
29-
@bin/repo_check.py -s .
67+
@${PYTHON} bin/repo_check.py -s .
3068

31-
## clean : clean up junk files.
69+
## * clean : clean up junk files
3270
clean :
3371
@rm -rf ${DST}
3472
@rm -rf .sass-cache
@@ -37,22 +75,26 @@ clean :
3775
@find . -name '*~' -exec rm {} \;
3876
@find . -name '*.pyc' -exec rm {} \;
3977

40-
## clean-rmd : clean intermediate R files (that need to be committed to the repo).
41-
clear-rmd :
78+
## * clean-rmd : clean intermediate R files (that need to be committed to the repo)
79+
clean-rmd :
4280
@rm -rf ${RMD_DST}
4381
@rm -rf fig/rmd-*
4482

45-
## ----------------------------------------
46-
## Commands specific to workshop websites.
83+
84+
##
85+
## II. Commands specific to workshop websites
86+
## =================================================
4787

4888
.PHONY : workshop-check
4989

50-
## workshop-check : check workshop homepage.
90+
## * workshop-check : check workshop homepage
5191
workshop-check :
52-
@bin/workshop_check.py .
92+
@${PYTHON} bin/workshop_check.py .
93+
5394

54-
## ----------------------------------------
55-
## Commands specific to lesson websites.
95+
##
96+
## III. Commands specific to lesson websites
97+
## =================================================
5698

5799
.PHONY : lesson-check lesson-md lesson-files lesson-fixme
58100

@@ -63,59 +105,56 @@ RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC))
63105
# Lesson source files in the order they appear in the navigation menu.
64106
MARKDOWN_SRC = \
65107
index.md \
66-
CONDUCT.md \
108+
CODE_OF_CONDUCT.md \
67109
setup.md \
68-
$(wildcard _episodes/*.md) \
110+
$(sort $(wildcard _episodes/*.md)) \
69111
reference.md \
70-
$(wildcard _extras/*.md) \
112+
$(sort $(wildcard _extras/*.md)) \
71113
LICENSE.md
72114

73115
# Generated lesson files in the order they appear in the navigation menu.
74116
HTML_DST = \
75117
${DST}/index.html \
76118
${DST}/conduct/index.html \
77119
${DST}/setup/index.html \
78-
$(patsubst _episodes/%.md,${DST}/%/index.html,$(wildcard _episodes/*.md)) \
120+
$(patsubst _episodes/%.md,${DST}/%/index.html,$(sort $(wildcard _episodes/*.md))) \
79121
${DST}/reference/index.html \
80-
$(patsubst _extras/%.md,${DST}/%/index.html,$(wildcard _extras/*.md)) \
122+
$(patsubst _extras/%.md,${DST}/%/index.html,$(sort $(wildcard _extras/*.md))) \
81123
${DST}/license/index.html
82124

83-
## lesson-md : convert Rmarkdown files to markdown
125+
## * lesson-md : convert Rmarkdown files to markdown
84126
lesson-md : ${RMD_DST}
85127

86-
# Use of .NOTPARALLEL makes rule execute only once
87-
${RMD_DST} : ${RMD_SRC}
88-
@bin/knit_lessons.sh ${RMD_SRC}
128+
_episodes/%.md: _episodes_rmd/%.Rmd
129+
@bin/knit_lessons.sh $< $@
89130

90-
## lesson-check : validate lesson Markdown.
91-
lesson-check :
92-
@bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
131+
# * lesson-check : validate lesson Markdown
132+
lesson-check : lesson-fixme
133+
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
93134

94-
## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace.
135+
## * lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace
95136
lesson-check-all :
96-
@bin/lesson_check.py -s . -p ${PARSER} -l -w
137+
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive
97138

98-
## lesson-figures : re-generate inclusion displaying all figures.
99-
lesson-figures :
100-
@bin/extract_figures.py -p ${PARSER} ${MARKDOWN_SRC} > _includes/all_figures.html
101-
102-
## unittest : run unit tests on checking tools.
139+
## * unittest : run unit tests on checking tools
103140
unittest :
104-
python bin/test_lesson_check.py
141+
@${PYTHON} bin/test_lesson_check.py
105142

106-
## lesson-files : show expected names of generated files for debugging.
143+
## * lesson-files : show expected names of generated files for debugging
107144
lesson-files :
108145
@echo 'RMD_SRC:' ${RMD_SRC}
109146
@echo 'RMD_DST:' ${RMD_DST}
110147
@echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC}
111148
@echo 'HTML_DST:' ${HTML_DST}
112149

113-
## lesson-fixme : show FIXME markers embedded in source files.
150+
## * lesson-fixme : show FIXME markers embedded in source files
114151
lesson-fixme :
115152
@fgrep -i -n FIXME ${MARKDOWN_SRC} || true
116153

117-
#-------------------------------------------------------------------------------
118-
# Include extra commands if available.
119-
#-------------------------------------------------------------------------------
154+
##
155+
## IV. Auxililary (plumbing) commands
156+
## =================================================
120157

121-
-include commands.mk
158+
## * commands : show all commands.
159+
commands :
160+
@sed -n -e '/^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST)

0 commit comments

Comments
 (0)