Skip to content

Commit f2cc818

Browse files
authored
Merge pull request #186 from datacarpentry/update-styles-final
Update to final version of styles lesson template
2 parents 47606e1 + 8abcbff commit f2cc818

35 files changed

+941
-337
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Thanks for contributing! :heart:
55

66
If this contribution is for instructor training, please email the link to this contribution to
7-
checkout@carpentries.org so we can record your progress. You've completed your contribution
7+
instructor.training@carpentries.org so we can record your progress. You've completed your contribution
88
step for instructor checkout by submitting this contribution!
99

1010
Keep in mind that **lesson maintainers are volunteers** and it may take them some time to

.github/workflows/template.yml

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ jobs:
88
name: ${{ matrix.lesson-name }} (${{ matrix.os-name }})
99
if: github.repository == 'carpentries/styles'
1010
runs-on: ${{ matrix.os }}
11+
continue-on-error: ${{ matrix.experimental }}
1112
strategy:
1213
fail-fast: false
1314
matrix:
1415
lesson: [swcarpentry/shell-novice, datacarpentry/r-intro-geospatial, librarycarpentry/lc-git]
1516
os: [ubuntu-20.04, macos-latest, windows-latest]
17+
experimental: [false]
1618
include:
1719
- os: ubuntu-20.04
18-
os-name: Ubuntu
20+
os-name: Linux
1921
- os: macos-latest
2022
os-name: macOS
2123
- os: windows-latest
@@ -26,6 +28,16 @@ jobs:
2628
lesson-name: (DC) R Intro Geospatial
2729
- lesson: librarycarpentry/lc-git
2830
lesson-name: (LC) Intro to Git
31+
- lesson: datacarpentry/astronomy-python
32+
lesson-name: (DC) Foundations of Astronomical Data Science
33+
experimental: true
34+
os: ubuntu-20.04
35+
os-name: Linux
36+
- lesson: carpentries/lesson-example
37+
lesson-name: (CP) Lesson Example
38+
experimental: false
39+
os: ubuntu-20.04
40+
os-name: Linux
2941
defaults:
3042
run:
3143
shell: bash # forces 'Git for Windows' on Windows
@@ -62,25 +74,54 @@ jobs:
6274
path: lesson
6375
fetch-depth: 0
6476

65-
- name: Determine the proper reference to use
66-
id: styles-ref
77+
- name: Sync lesson with carpentries/styles
78+
working-directory: lesson
6779
run: |
68-
if [[ -n "${{ github.event.pull_request.number }}" ]]; then
69-
echo "::set-output name=ref::refs/pull/${{ github.event.pull_request.number }}/head"
80+
echo "::group::Fetch Styles"
81+
if [[ -n "${{ github.event.pull_request.number }}" ]]
82+
then
83+
ref="refs/pull/${{ github.event.pull_request.number }}/head"
7084
else
71-
echo "::set-output name=ref::gh-pages"
85+
ref="gh-pages"
7286
fi
7387
74-
- name: Sync lesson with carpentries/styles
75-
working-directory: lesson
76-
run: |
7788
git config --global user.email "team@carpentries.org"
7889
git config --global user.name "The Carpentries Bot"
90+
7991
git remote add styles https://github.com/carpentries/styles.git
80-
git config --local remote.styles.tagOpt --no-tags
81-
git fetch styles ${{ steps.styles-ref.outputs.ref }}:styles-ref
82-
git merge -s recursive -Xtheirs --no-commit styles-ref
83-
git commit -m "Sync lesson with carpentries/styles"
92+
git fetch styles $ref:styles-ref
93+
echo "::endgroup::"
94+
echo "::group::Synchronize Styles"
95+
# Sync up only if necessary
96+
if [[ $(git rev-list --count HEAD..styles-ref) != 0 ]]
97+
then
98+
99+
# The merge command below might fail for lessons that use remote theme
100+
# https://github.com/carpentries/carpentries-theme
101+
echo "Testing merge using recursive strategy, accepting upstream changes without committing"
102+
if ! git merge -s recursive -Xtheirs --no-commit styles-ref
103+
then
104+
105+
# Remove "deleted by us, unmerged" files from the staging area.
106+
# these are the files that were removed from the lesson
107+
# but are still present in the carpentries/styles repo
108+
echo "Removing previously deleted files"
109+
git rm $(git diff --name-only --diff-filter=DU)
110+
111+
# If there are still "unmerged" files,
112+
# let's raise an error and look into this more closely
113+
if [[ -n $(git diff --name-only --diff-filter=U) ]]
114+
then
115+
echo "There were unmerged files in ${{ matrix.lesson-name }}:"
116+
echo "$(git diff --compact-summary --diff-filter=U)"
117+
exit 1
118+
fi
119+
fi
120+
121+
echo "Committing changes"
122+
git commit -m "Sync lesson with carpentries/styles"
123+
fi
124+
echo "::endgroup::"
84125
85126
- name: Look for R-markdown files
86127
id: check-rmd
@@ -94,13 +135,13 @@ jobs:
94135
with:
95136
use-public-rspm: true
96137
install-r: false
97-
r-version: 'release'
98138

99139
- name: Install needed packages
100140
if: steps.check-rmd.outputs.count != 0
141+
working-directory: lesson
101142
run: |
102-
packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))
103-
install.packages(packages, repo="https://cran.rstudio.com/")
143+
source('bin/dependencies.R')
144+
install_required_packages(.libPaths()[1])
104145
shell: Rscript {0}
105146

106147
- name: Query dependencies
@@ -110,13 +151,14 @@ jobs:
110151
source('bin/dependencies.R')
111152
deps <- identify_dependencies()
112153
create_description(deps)
154+
use_bioc_repos()
113155
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
114156
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
115157
shell: Rscript {0}
116158

117-
- name: Cache R packages
159+
- name: Restore Package Cache
118160
if: runner.os != 'Windows' && steps.check-rmd.outputs.count != 0
119-
uses: actions/cache@v1
161+
uses: actions/cache@v2
120162
with:
121163
path: ${{ env.R_LIBS_USER }}
122164
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
@@ -133,8 +175,11 @@ jobs:
133175
run: |
134176
while read -r cmd
135177
do
136-
eval sudo $cmd
178+
eval sudo $cmd || echo "Nothing to update"
137179
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
138180
139181
- run: make site
140182
working-directory: lesson
183+
184+
- run: make lesson-check-all
185+
working-directory: lesson

.github/workflows/website.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ jobs:
5252
with:
5353
use-public-rspm: true
5454
install-r: false
55-
r-version: 'release'
5655

57-
- name: Cache R packages
56+
- name: Restore R Cache
5857
if: steps.check-rmd.outputs.count != 0
59-
uses: actions/cache@v1
58+
uses: actions/cache@v2
6059
with:
6160
path: ${{ env.R_LIBS_USER }}
6261
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
@@ -65,8 +64,8 @@ jobs:
6564
- name: Install needed packages
6665
if: steps.check-rmd.outputs.count != 0
6766
run: |
68-
packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))
69-
install.packages(packages, repo="https://cran.rstudio.com/")
67+
source('bin/dependencies.R')
68+
install_required_packages()
7069
shell: Rscript {0}
7170

7271
- name: Query dependencies
@@ -75,6 +74,7 @@ jobs:
7574
source('bin/dependencies.R')
7675
deps <- identify_dependencies()
7776
create_description(deps)
77+
use_bioc_repos()
7878
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
7979
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
8080
shell: Rscript {0}
@@ -85,7 +85,7 @@ jobs:
8585
run: |
8686
while read -r cmd
8787
do
88-
eval sudo $cmd
88+
eval sudo $cmd || echo "Nothing to update"
8989
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
9090
9191
- name: Render the markdown and confirm that the site can be built

404.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ permalink: 404.html
55
title: "Page not found"
66
---
77

8-
# Oops! We can't find that page.
8+
# Oops! We cannot find that page.
99
{: style="text-align: center;"}
1010

1111
> ## Our apologies!
1212
>
13-
> We can't seem to find the page you're looking for.
13+
> We cannot seem to find the page you are looking for.
1414
> Try going back to the <a href="javascript:history.back()">previous page</a> or
1515
> navigate to any other page using the navigation bar above
1616
> {%- if site.kind == "lesson" -%} or the schedule below {%- endif -%}.

CODE_OF_CONDUCT.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ we pledge to follow the [Carpentry Code of Conduct][coc].
88
Instances of abusive, harassing, or otherwise unacceptable behavior
99
may be reported by following our [reporting guidelines][coc-reporting].
1010

11-
{% include links.md %}
11+
[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html
12+
[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html

LICENSE.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ license terms.
2323

2424
Under the following terms:
2525

26-
* **Attribution**---You must give appropriate credit (mentioning that
27-
your work is derived from work that is Copyright © Software
28-
Carpentry and, where practical, linking to
29-
http://software-carpentry.org/), provide a [link to the
30-
license][cc-by-human], and indicate if changes were made. You may do
31-
so in any reasonable manner, but not in any way that suggests the
32-
licensor endorses you or your use.
26+
* **Attribution**---You must give appropriate credit by:
27+
- mentioning that your work is derived from work that is
28+
Copyright © Software Carpentry, Data Carpentry, Library Carpentry,
29+
or The Carpentries.
30+
- where practical, linking to the respective lesson program website
31+
(https://software-carpentry.org/, https://datacarpentry.org, https://librarycarpentry.org, or
32+
https://carpentries.org), provide a [link to the license][cc-by-human]
33+
- and indicate if changes were made. You may do so in any reasonable manner, but not in any way
34+
that suggests the licensor endorses you or your use.
3335

3436
**No additional restrictions**---You may not apply legal terms or
3537
technological measures that legally restrict others from doing
@@ -73,8 +75,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7375

7476
## Trademark
7577

76-
"Software Carpentry" and "Data Carpentry" and their respective logos
77-
are registered trademarks of [Community Initiatives][CI].
78+
"The Carpentries", "Software Carpentry" and "Data Carpentry" and their respective logos are
79+
registered trademarks of [Community Initiatives][CI].
7880

7981
[cc-by-human]: https://creativecommons.org/licenses/by/4.0/
8082
[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode

Makefile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ JEKYLL=bundle config set --local path .vendor/bundle && bundle install && bundle
77
PARSER=bin/markdown_ast.rb
88
DST=_site
99

10+
# Find Docker
11+
DOCKER := $(shell which docker 2>/dev/null)
12+
1013
# Check Python 3 is installed and determine if it's called via python3 or python
1114
# (https://stackoverflow.com/a/4933395)
1215
PYTHON3_EXE := $(shell which python3 2>/dev/null)
@@ -41,23 +44,27 @@ endif
4144
.PHONY: site docker-serve repo-check clean clean-rmd
4245

4346
## * serve : render website and run a local server
44-
serve : lesson-md
47+
serve : lesson-md index.md
4548
${JEKYLL} serve
4649

4750
## * site : build website but do not run a server
48-
site : lesson-md
51+
site : lesson-md index.md
4952
${JEKYLL} build
5053

5154
## * docker-serve : use Docker to serve the site
5255
docker-serve :
53-
@docker pull carpentries/lesson-docker:latest
54-
@docker run --rm -it \
56+
ifeq (, $(DOCKER))
57+
$(error Your system does not appear to have Docker installed)
58+
else
59+
@$(DOCKER) pull carpentries/lesson-docker:latest
60+
@$(DOCKER) run --rm -it \
5561
-v $${PWD}:/home/rstudio \
5662
-p 4000:4000 \
5763
-p 8787:8787 \
5864
-e USERID=$$(id -u) \
5965
-e GROUPID=$$(id -g) \
6066
carpentries/lesson-docker:latest
67+
endif
6168

6269
## * repo-check : check repository settings
6370
repo-check : python
@@ -172,3 +179,10 @@ ifeq (, $(PYTHON))
172179
else
173180
@:
174181
endif
182+
183+
index.md :
184+
ifeq (, $(wildcard index.md))
185+
$(error index.md not found)
186+
else
187+
@:
188+
endif

_includes/base_path.html

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
1-
{% comment %}
2-
This is adapted from: https://ricostacruz.com/til/relative-paths-in-jekyll
1+
{%- comment -%}
2+
When the website is built by GitHub Pages,
3+
'site.url' is set to 'https://username.github.io'
4+
'site.baseurl' is set to '/lesson-name'
35

4-
`page.url` gives the URL of the current page with a leading /:
6+
When we start a local server using `jekyll serve`,
7+
'site.url' is set to 'http://localhost:4000' and
8+
'site.baseurl' is empty.
59

6-
- when the URL ends with the extension (e.g., /foo/bar.html) then we can get
7-
the depth by counting the number of / and remove - 1
8-
- when the URL ends with a / (e.g. /foo/bar/) then the number / gives the depth
9-
directly
10-
{% endcomment %}
10+
In both of the above cases we set 'relative_root_path' to 'site.baseurl'.
1111

12-
{% assign relative_root_path = '' %}
12+
When we build a website locally with `jekyll build`,
13+
both 'site.url' and 'site.baseurl' are empty.
14+
This case is handled by the last 'else' in the code below.
15+
The logic there follows the (adapted) instructions found at:
16+
https://ricostacruz.com/til/relative-paths-in-jekyll
1317

14-
{% assign last_char = page.url | slice: -1 %}
18+
`page.url` gives the URL of the current page with a leading /:
1519

16-
{% if last_char == "/"}
17-
{% assign offset = 0 %}
18-
{% else %}
19-
{% assign offset = 1 %}
20-
{% endif %}
20+
- when the URL ends with an extension (e.g., /foo/bar.html),
21+
we can get the 'depth' of the page by counting the number of
22+
forward slashes ('/') and subtracting 1
23+
- when the URL ends with a forward slash (e.g. /foo/bar/),
24+
we can get the depth of the page by counting the number of /
25+
{%- endcomment -%}
2126

22-
{% assign depth = page.url | split: '/' | size | minus: offset %}
23-
{% if depth <= 1 %}{% assign relative_root_path = '.' %}
24-
{% elsif depth == 2 %}{% assign relative_root_path = '..' %}
25-
{% elsif depth == 3 %}{% assign relative_root_path = '../..' %}
26-
{% elsif depth == 4 %}{% assign relative_root_path = '../../..' %}
27+
{% if site.url %}
28+
{% assign relative_root_path = site.baseurl %}
29+
{% else %}
30+
{% assign last_char = page.url | slice: -1 %}
31+
{% if last_char == "/" %}
32+
{% assign offset = 0 %}
33+
{% else %}
34+
{% assign offset = 1 %}
35+
{% endif %}
36+
{% assign depth = page.url | split: '/' | size | minus: offset %}
37+
{% if depth <= 1 %}{% assign relative_root_path = '.' %}
38+
{% elsif depth == 2 %}{% assign relative_root_path = '..' %}
39+
{% else %}{% capture relative_root_path %}..{% for i in (3..depth) %}/..{% endfor %}{% endcapture %}
40+
{% endif %}
2741
{% endif %}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{% assign date = include.need_transition_date %}
2+
3+
{% if date == "true" %}
4+
{% unless site.transition_date_prebeta %}
5+
<div class="alert alert-danger">
6+
you need to specify the variable <code>transition_date_prebeta</code>
7+
in <code>_config.yml</code>.
8+
</div>
9+
{% endunless %}
10+
{% unless site.transition_date_beta %}
11+
<div class="alert alert-danger">
12+
you need to specify the variable <code>transition_date_beta</code>
13+
in <code>_config.yml</code>.
14+
</div>
15+
{% endunless %}
16+
{% unless site.transition_date_prerelease %}
17+
<div class="alert alert-danger">
18+
you need to specify the variable <code>transition_date_prerelease</code>
19+
in <code>_config.yml</code>.
20+
</div>
21+
{% endunless %}
22+
{% endif %}

0 commit comments

Comments
 (0)