Skip to content

Commit 785db79

Browse files
committed
Merge branch gh-pages of carpentries/styles
2 parents 43f5ca8 + a8eee52 commit 785db79

15 files changed

Lines changed: 398 additions & 90 deletions

File tree

.github/workflows/template.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Test template
2+
on:
3+
push:
4+
branches: gh-pages
5+
pull_request:
6+
jobs:
7+
check-template:
8+
name: ${{ matrix.lesson-name }} (${{ matrix.os-name }})
9+
if: github.repository == 'carpentries/styles'
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
lesson: [swcarpentry/shell-novice, datacarpentry/r-intro-geospatial, librarycarpentry/lc-git]
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
include:
17+
- os: ubuntu-latest
18+
os-name: Ubuntu
19+
- os: macos-latest
20+
os-name: macOS
21+
- os: windows-latest
22+
os-name: Windows
23+
- lesson: swcarpentry/shell-novice
24+
lesson-name: (SWC) Shell novice
25+
- lesson: datacarpentry/r-intro-geospatial
26+
lesson-name: (DC) R Intro Geospatial
27+
- lesson: librarycarpentry/lc-git
28+
lesson-name: (LC) Intro to Git
29+
defaults:
30+
run:
31+
shell: bash # forces 'Git for Windows' on Windows
32+
env:
33+
RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/bionic/latest'
34+
steps:
35+
- name: Set up Ruby
36+
uses: actions/setup-ruby@main
37+
with:
38+
ruby-version: '2.7.1'
39+
40+
- name: Set up Python
41+
uses: actions/setup-python@v2
42+
with:
43+
python-version: '3.x'
44+
45+
- name: Install GitHub Pages, Bundler, and kramdown gems
46+
run: |
47+
gem install github-pages bundler kramdown
48+
49+
- name: Install Python modules
50+
run: |
51+
if [[ $RUNNER_OS == macOS || $RUNNER_OS == Linux ]]; then
52+
python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
53+
elif [[ $RUNNER_OS == Windows ]]; then
54+
python -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
55+
fi
56+
57+
- name: Checkout the ${{ matrix.lesson }} lesson
58+
uses: actions/checkout@master
59+
with:
60+
repository: ${{ matrix.lesson }}
61+
path: lesson
62+
fetch-depth: 0
63+
64+
- name: Determine the proper reference to use
65+
id: styles-ref
66+
run: |
67+
if [[ -n "${{ github.event.pull_request.number }}" ]]; then
68+
echo "::set-output name=ref::refs/pull/${{ github.event.pull_request.number }}/head"
69+
else
70+
echo "::set-output name=ref::gh-pages"
71+
fi
72+
73+
- name: Sync lesson with carpentries/styles
74+
working-directory: lesson
75+
run: |
76+
git config --global user.email "[email protected]"
77+
git config --global user.name "The Carpentries Bot"
78+
git remote add styles https://github.com/carpentries/styles.git
79+
git config --local remote.styles.tagOpt --no-tags
80+
git fetch styles ${{ steps.styles-ref.outputs.ref }}:styles-ref
81+
git merge -s recursive -Xtheirs --no-commit styles-ref
82+
git commit -m "Sync lesson with carpentries/styles"
83+
84+
- name: Look for R-markdown files
85+
id: check-rmd
86+
working-directory: lesson
87+
run: |
88+
echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})"
89+
90+
- name: Set up R
91+
if: steps.check-rmd.outputs.count != 0
92+
uses: r-lib/actions/setup-r@master
93+
with:
94+
r-version: 'release'
95+
96+
- name: Install needed packages
97+
if: steps.check-rmd.outputs.count != 0
98+
run: |
99+
install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
100+
shell: Rscript {0}
101+
102+
- name: Query dependencies
103+
if: steps.check-rmd.outputs.count != 0
104+
working-directory: lesson
105+
run: |
106+
source('bin/dependencies.R')
107+
deps <- identify_dependencies()
108+
create_description(deps)
109+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
110+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
111+
shell: Rscript {0}
112+
113+
- name: Cache R packages
114+
if: runner.os != 'Windows' && steps.check-rmd.outputs.count != 0
115+
uses: actions/cache@v1
116+
with:
117+
path: ${{ env.R_LIBS_USER }}
118+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
119+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
120+
121+
- name: Install system dependencies for R packages
122+
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
123+
working-directory: lesson
124+
run: |
125+
while read -r cmd
126+
do
127+
eval sudo $cmd
128+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
129+
130+
- run: make site
131+
working-directory: lesson

.github/workflows/website.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build website
2+
on:
3+
push:
4+
branches: gh-pages
5+
pull_request: []
6+
jobs:
7+
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+
defaults:
11+
run:
12+
shell: bash
13+
steps:
14+
- name: Set up Ruby
15+
uses: actions/setup-ruby@main
16+
with:
17+
ruby-version: '2.7.1'
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: '3.x'
23+
24+
- name: Install GitHub Pages, Bundler, and kramdown gems
25+
run: |
26+
gem install github-pages bundler kramdown
27+
28+
- name: Install Python modules
29+
run: |
30+
python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
31+
32+
- name: Checkout the lesson
33+
uses: actions/checkout@master
34+
with:
35+
fetch-depth: 0
36+
ref: ${{ github.event.pull_request.head.sha }}
37+
38+
- name: Look for R-markdown files
39+
id: check-rmd
40+
working-directory: lesson
41+
run: |
42+
echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})"
43+
44+
- name: Set up R
45+
if: steps.check-rmd.outputs.count != 0
46+
uses: r-lib/actions/setup-r@master
47+
with:
48+
r-version: 'release'
49+
50+
- name: Install needed packages
51+
if: steps.check-rmd.outputs.count != 0
52+
run: |
53+
install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
54+
shell: Rscript {0}
55+
56+
- name: Query dependencies
57+
if: steps.check-rmd.outputs.count != 0
58+
working-directory: lesson
59+
run: |
60+
source('bin/dependencies.R')
61+
deps <- identify_dependencies()
62+
create_description(deps)
63+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
64+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
65+
shell: Rscript {0}
66+
67+
- name: Cache R packages
68+
if: steps.check-rmd.outputs.count != 0
69+
uses: actions/cache@v1
70+
with:
71+
path: ${{ env.R_LIBS_USER }}
72+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
73+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
74+
75+
- name: Install system dependencies for R packages
76+
if: steps.check-rmd.outputs.count != 0
77+
working-directory: lesson
78+
run: |
79+
while read -r cmd
80+
do
81+
eval sudo $cmd
82+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
83+
84+
- run: make site
85+
- run: make lesson-check
86+
if: always()
87+
- run: make lesson-check-all
88+
if: always()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _site
1212
.RData
1313
.bundle/
1414
.vendor/
15+
vendor/
1516
.docker-vendor/
1617
Gemfile.lock
1718
.*history

Makefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Use /bin/bash instead of /bin/sh
2-
export SHELL = /bin/bash
3-
41
## ========================================
52
## Commands for both workshop and lesson websites.
63

@@ -96,7 +93,7 @@ workshop-check :
9693
## III. Commands specific to lesson websites
9794
## =================================================
9895

99-
.PHONY : lesson-check lesson-md lesson-files lesson-fixme
96+
.PHONY : lesson-check lesson-md lesson-files lesson-fixme install-rmd-deps
10097

10198
# RMarkdown files
10299
RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd)
@@ -122,13 +119,18 @@ HTML_DST = \
122119
$(patsubst _extras/%.md,${DST}/%/index.html,$(sort $(wildcard _extras/*.md))) \
123120
${DST}/license/index.html
124121

122+
## * install-rmd-deps : Install R packages dependencies to build the RMarkdown lesson
123+
install-rmd-deps:
124+
@${SHELL} bin/install_r_deps.sh
125+
125126
## * lesson-md : convert Rmarkdown files to markdown
126127
lesson-md : ${RMD_DST}
127128

128-
_episodes/%.md: _episodes_rmd/%.Rmd
129+
_episodes/%.md: _episodes_rmd/%.Rmd install-rmd-deps
130+
@mkdir -p _episodes
129131
@bin/knit_lessons.sh $< $@
130132

131-
# * lesson-check : validate lesson Markdown
133+
## * lesson-check : validate lesson Markdown
132134
lesson-check : lesson-fixme
133135
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
134136

@@ -149,7 +151,7 @@ lesson-files :
149151

150152
## * lesson-fixme : show FIXME markers embedded in source files
151153
lesson-fixme :
152-
@fgrep -i -n FIXME ${MARKDOWN_SRC} || true
154+
@grep --fixed-strings --word-regexp --line-number --no-messages FIXME ${MARKDOWN_SRC} || true
153155

154156
##
155157
## IV. Auxililary (plumbing) commands

_includes/navbar.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<li><a href="{{ relative_root_path }}{% link setup.md %}">Setup</a></li>
5050

5151
{% comment %} Show lesson episodes for lessons. {% endcomment %}
52+
{% if lesson_episodes.size > 0 %}
5253
<li class="dropdown">
5354
<a href="{{ relative_root_path }}/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Episodes <span class="caret"></span></a>
5455
<ul class="dropdown-menu">
@@ -64,6 +65,7 @@
6465
<li><a href="{{ relative_root_path }}{% link aio.md %}">All in one page (Beta)</a></li>
6566
</ul>
6667
</li>
68+
{% endif %}
6769
{% endif %}
6870

6971
{% comment %} Show extras for lessons or if this is the main workshop-template repo (where they contain documentation). {% endcomment %}

0 commit comments

Comments
 (0)