Skip to content

Commit 7a2319f

Browse files
committed
Merge branch gh-pages of carpentries/styles
2 parents 1e22960 + 50fd61f commit 7a2319f

16 files changed

Lines changed: 207 additions & 95 deletions

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ trim_trailing_whitespace = true
99
indent_size = 2
1010
indent_style = space
1111
max_line_length = 100 # Please keep this in sync with bin/lesson_check.py!
12+
trim_trailing_whitespace = false # keep trailing spaces in markdown - 2+ spaces are translated to a hard break (<br/>)
1213

1314
[*.r]
1415
max_line_length = 80

.github/workflows/template.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
lesson: [swcarpentry/shell-novice, datacarpentry/r-intro-geospatial, librarycarpentry/lc-git]
15-
os: [ubuntu-latest, macos-latest, windows-latest]
15+
os: [ubuntu-20.04, macos-latest, windows-latest]
1616
include:
17-
- os: ubuntu-latest
17+
- os: ubuntu-20.04
1818
os-name: Ubuntu
1919
- os: macos-latest
2020
os-name: macOS
@@ -30,12 +30,13 @@ jobs:
3030
run:
3131
shell: bash # forces 'Git for Windows' on Windows
3232
env:
33-
RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/bionic/latest'
33+
RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest'
3434
steps:
3535
- name: Set up Ruby
36-
uses: actions/setup-ruby@main
36+
uses: ruby/setup-ruby@v1
3737
with:
38-
ruby-version: '2.7.1'
38+
ruby-version: '2.7'
39+
bundler-cache: true
3940

4041
- name: Set up Python
4142
uses: actions/setup-python@v2
@@ -44,7 +45,7 @@ jobs:
4445

4546
- name: Install GitHub Pages, Bundler, and kramdown gems
4647
run: |
47-
gem install github-pages bundler kramdown
48+
gem install github-pages bundler kramdown kramdown-parser-gfm
4849
4950
- name: Install Python modules
5051
run: |
@@ -96,7 +97,8 @@ jobs:
9697
- name: Install needed packages
9798
if: steps.check-rmd.outputs.count != 0
9899
run: |
99-
install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
100+
packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))
101+
install.packages(packages, repo="https://cran.rstudio.com/")
100102
shell: Rscript {0}
101103

102104
- name: Query dependencies
@@ -118,14 +120,19 @@ jobs:
118120
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
119121
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
120122

123+
- name: Install stringi from source
124+
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
125+
run: install.packages('stringi', repos='https://cloud.r-project.org')
126+
shell: Rscript {0}
127+
121128
- name: Install system dependencies for R packages
122129
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
123130
working-directory: lesson
124131
run: |
125132
while read -r cmd
126133
do
127134
eval sudo $cmd
128-
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
135+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
129136
130137
- run: make site
131138
working-directory: lesson

.github/workflows/website.yml

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
name: Build website
1+
name: Website
22
on:
33
push:
4-
branches: gh-pages
4+
branches:
5+
- gh-pages
6+
- main
57
pull_request: []
68
jobs:
79
build-website:
8-
if: github.repository != 'carpentries/styles' && (github.repository_owner == 'swcarpentry' || github.repository_owner == 'datacarpentry' || github.repository_owner == 'librarycarpentry' || github.repository_owner == 'carpentries')
9-
runs-on: ubuntu-latest
10+
if: ${{ !endsWith(github.repository, '/styles') }}
11+
runs-on: ubuntu-20.04
12+
env:
13+
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
14+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1015
defaults:
1116
run:
1217
shell: bash
1318
steps:
1419
- name: Set up Ruby
15-
uses: actions/setup-ruby@main
20+
uses: ruby/setup-ruby@v1
1621
with:
17-
ruby-version: '2.7.1'
22+
ruby-version: '2.7'
23+
bundler-cache: true
1824

1925
- name: Set up Python
2026
uses: actions/setup-python@v2
@@ -23,7 +29,7 @@ jobs:
2329

2430
- name: Install GitHub Pages, Bundler, and kramdown gems
2531
run: |
26-
gem install github-pages bundler kramdown
32+
gem install github-pages bundler kramdown kramdown-parser-gfm
2733
2834
- name: Install Python modules
2935
run: |
@@ -46,10 +52,19 @@ jobs:
4652
with:
4753
r-version: 'release'
4854

55+
- name: Cache R packages
56+
if: steps.check-rmd.outputs.count != 0
57+
uses: actions/cache@v1
58+
with:
59+
path: ${{ env.R_LIBS_USER }}
60+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
61+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
62+
4963
- name: Install needed packages
5064
if: steps.check-rmd.outputs.count != 0
5165
run: |
52-
install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
66+
packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))
67+
install.packages(packages, repo="https://cran.rstudio.com/")
5368
shell: Rscript {0}
5469

5570
- name: Query dependencies
@@ -62,24 +77,45 @@ jobs:
6277
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
6378
shell: Rscript {0}
6479

65-
- name: Cache R packages
66-
if: steps.check-rmd.outputs.count != 0
67-
uses: actions/cache@v1
68-
with:
69-
path: ${{ env.R_LIBS_USER }}
70-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
71-
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
7280

7381
- name: Install system dependencies for R packages
7482
if: steps.check-rmd.outputs.count != 0
7583
run: |
7684
while read -r cmd
7785
do
7886
eval sudo $cmd
79-
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
87+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
88+
89+
- name: Render the markdown and confirm that the site can be built
90+
run: make site
91+
92+
- name: Checkout github pages
93+
if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
94+
uses: actions/checkout@master
95+
with:
96+
ref: gh-pages
97+
path: gh-pages
98+
99+
- name: Commit and Push
100+
if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
101+
run: |
102+
# clean up gh-pages
103+
cd gh-pages
104+
git rm -rf . # remove all previous files
105+
git restore --staged . # remove things from the stage
106+
cd ..
107+
# copy everything into gh-pages site
108+
cp -r `ls -A | grep -v 'gh-pages' | grep -v '.git' | grep -v '.bundle/' | grep -v '_site'` gh-pages
109+
# move into gh-pages, add, commit, and push
110+
cd gh-pages
111+
# setup git
112+
git config --local user.email "[email protected]"
113+
git config --local user.name "GitHub Actions"
114+
git add -A .
115+
git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }})"
116+
git push origin gh-pages
117+
# return
118+
cd ..
80119
81-
- run: make site
82-
- run: make lesson-check
83-
if: always()
84120
- run: make lesson-check-all
85121
if: always()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
.ipynb_checkpoints
66
.sass-cache
77
.jekyll-cache/
8+
.jekyll-metadata
89
__pycache__
910
_site
1011
.Rproj.user

404.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
layout: base
3+
root: .
4+
permalink: 404.html
5+
title: "Page not found"
6+
---
7+
8+
# Oops! We can't find that page.
9+
{: style="text-align: center;"}
10+
11+
> ## Our apologies!
12+
>
13+
> We can't seem to find the page you're looking for.
14+
> Try going back to the <a href="javascript:history.back()">previous page</a> or
15+
> navigate to any other page using the navigation bar above
16+
> {%- if site.kind == "lesson" -%} or the schedule below {%- endif -%}.
17+
> If you got here by clicking on a link in the
18+
> {%- if site.kind == "lesson" -%} lesson {%- else -%} workshop {%- endif -%},
19+
> please report this link to the
20+
> {%- if site.kind == "lesson" -%} lesson developers {%- else -%} workshop organizers {%- endif -%}.
21+
{: .caution}
22+
23+
{% if site.kind == "lesson" %}
24+
{% include syllabus.html %}
25+
{% endif%}

Gemfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
source 'https://rubygems.org'
44

5-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
66

77
# Synchronize with https://pages.github.com/versions
8-
ruby '>=2.5.8'
8+
ruby '>=2.7.1'
99

1010
gem 'github-pages', group: :jekyll_plugins
11+
12+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
13+
gem 'webrick', '>= 1.6.1'
14+
end

Makefile

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Settings
55
MAKEFILES=Makefile $(wildcard *.mk)
6-
JEKYLL=bundle config --local set path .vendor/bundle && bundle install && bundle update && bundle exec jekyll
6+
JEKYLL=bundle config set --local path .vendor/bundle && bundle install && bundle update && bundle exec jekyll
77
PARSER=bin/markdown_ast.rb
88
DST=_site
99

@@ -12,7 +12,7 @@ DST=_site
1212
PYTHON3_EXE := $(shell which python3 2>/dev/null)
1313
ifneq (, $(PYTHON3_EXE))
1414
ifeq (,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE))))
15-
PYTHON := python3
15+
PYTHON := $(PYTHON3_EXE)
1616
endif
1717
endif
1818

@@ -21,25 +21,25 @@ ifeq (,$(PYTHON))
2121
ifneq (, $(PYTHON_EXE))
2222
PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
2323
PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
24-
ifneq (3, ${PYTHON_VERSION_MAJOR})
25-
$(error "Your system does not appear to have Python 3 installed.")
24+
ifeq (3, ${PYTHON_VERSION_MAJOR})
25+
PYTHON := $(PYTHON_EXE)
26+
else
27+
PYTHON_NOTE = "Your system does not appear to have Python 3 installed."
2628
endif
27-
PYTHON := python
2829
else
29-
$(error "Your system does not appear to have any Python installed.")
30+
PYTHON_NOTE = "Your system does not appear to have any Python installed."
3031
endif
3132
endif
3233

3334

34-
# Controls
35-
.PHONY : commands clean files
36-
3735
# Default target
3836
.DEFAULT_GOAL := commands
3937

4038
## I. Commands for both workshop and lesson websites
4139
## =================================================
4240

41+
.PHONY: site docker-serve repo-check clean clean-rmd
42+
4343
## * serve : render website and run a local server
4444
serve : lesson-md
4545
${JEKYLL} serve
@@ -50,8 +50,8 @@ site : lesson-md
5050

5151
## * docker-serve : use Docker to serve the site
5252
docker-serve :
53-
docker pull carpentries/lesson-docker:latest
54-
docker run --rm -it \
53+
@docker pull carpentries/lesson-docker:latest
54+
@docker run --rm -it \
5555
-v $${PWD}:/home/rstudio \
5656
-p 4000:4000 \
5757
-p 8787:8787 \
@@ -60,14 +60,17 @@ docker-serve :
6060
carpentries/lesson-docker:latest
6161

6262
## * repo-check : check repository settings
63-
repo-check :
63+
repo-check : python
6464
@${PYTHON} bin/repo_check.py -s .
6565

6666
## * clean : clean up junk files
6767
clean :
6868
@rm -rf ${DST}
6969
@rm -rf .sass-cache
7070
@rm -rf bin/__pycache__
71+
@rm -rf .vendor
72+
@rm -rf .bundle
73+
@rm -f Gemfile.lock
7174
@find . -name .DS_Store -exec rm {} \;
7275
@find . -name '*~' -exec rm {} \;
7376
@find . -name '*.pyc' -exec rm {} \;
@@ -85,7 +88,7 @@ clean-rmd :
8588
.PHONY : workshop-check
8689

8790
## * workshop-check : check workshop homepage
88-
workshop-check :
91+
workshop-check : python
8992
@${PYTHON} bin/workshop_check.py .
9093

9194

@@ -96,7 +99,7 @@ workshop-check :
9699
.PHONY : lesson-check lesson-md lesson-files lesson-fixme install-rmd-deps
97100

98101
# RMarkdown files
99-
RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd)
102+
RMD_SRC = $(wildcard _episodes_rmd/*.Rmd)
100103
RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC))
101104

102105
# Lesson source files in the order they appear in the navigation menu.
@@ -115,7 +118,7 @@ HTML_DST = \
115118
${DST}/conduct/index.html \
116119
${DST}/setup/index.html \
117120
$(patsubst _episodes/%.md,${DST}/%/index.html,$(sort $(wildcard _episodes/*.md))) \
118-
${DST}/reference/index.html \
121+
${DST}/reference.html \
119122
$(patsubst _extras/%.md,${DST}/%/index.html,$(sort $(wildcard _extras/*.md))) \
120123
${DST}/license/index.html
121124

@@ -128,18 +131,18 @@ lesson-md : ${RMD_DST}
128131

129132
_episodes/%.md: _episodes_rmd/%.Rmd install-rmd-deps
130133
@mkdir -p _episodes
131-
@bin/knit_lessons.sh $< $@
134+
@$(SHELL) bin/knit_lessons.sh $< $@
132135

133136
## * lesson-check : validate lesson Markdown
134-
lesson-check : lesson-fixme
137+
lesson-check : python lesson-fixme
135138
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
136139

137140
## * lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace
138-
lesson-check-all :
141+
lesson-check-all : python
139142
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive
140143

141144
## * unittest : run unit tests on checking tools
142-
unittest :
145+
unittest : python
143146
@${PYTHON} bin/test_lesson_check.py
144147

145148
## * lesson-files : show expected names of generated files for debugging
@@ -157,6 +160,15 @@ lesson-fixme :
157160
## IV. Auxililary (plumbing) commands
158161
## =================================================
159162

163+
.PHONY : commands python
164+
160165
## * commands : show all commands.
161166
commands :
162167
@sed -n -e '/^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST)
168+
169+
python :
170+
ifeq (, $(PYTHON))
171+
$(error $(PYTHON_NOTE))
172+
else
173+
@:
174+
endif

0 commit comments

Comments
 (0)