Skip to content

Commit 655bf65

Browse files
authored
Merge pull request #80 from datacarpentry/updates/styles/2023-04
updates/styles/2023 04
2 parents 4c1a1cf + 6ebfad9 commit 655bf65

40 files changed

+1114
-403
lines changed

.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/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: 76 additions & 23 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]
15-
os: [ubuntu-latest, macos-latest, windows-latest]
16+
os: [ubuntu-20.04, macos-latest, windows-latest]
17+
experimental: [false]
1618
include:
17-
- os: ubuntu-latest
18-
os-name: Ubuntu
19+
- os: ubuntu-20.04
20+
os-name: Linux
1921
- os: macos-latest
2022
os-name: macOS
2123
- os: windows-latest
@@ -26,16 +28,27 @@ 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
3244
env:
33-
RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/bionic/latest'
45+
RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest'
3446
steps:
3547
- name: Set up Ruby
36-
uses: actions/setup-ruby@v1
48+
uses: ruby/setup-ruby@v1
3749
with:
3850
ruby-version: '2.7'
51+
bundler-cache: true
3952

4053
- name: Set up Python
4154
uses: actions/setup-python@v2
@@ -44,7 +57,7 @@ jobs:
4457

4558
- name: Install GitHub Pages, Bundler, and kramdown gems
4659
run: |
47-
gem install github-pages bundler kramdown
60+
gem install github-pages bundler kramdown kramdown-parser-gfm
4861
4962
- name: Install Python modules
5063
run: |
@@ -61,25 +74,54 @@ jobs:
6174
path: lesson
6275
fetch-depth: 0
6376

64-
- name: Determine the proper reference to use
65-
id: styles-ref
77+
- name: Sync lesson with carpentries/styles
78+
working-directory: lesson
6679
run: |
67-
if [[ -n "${{ github.event.pull_request.number }}" ]]; then
68-
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"
6984
else
70-
echo "::set-output name=ref::gh-pages"
85+
ref="gh-pages"
7186
fi
7287
73-
- name: Sync lesson with carpentries/styles
74-
working-directory: lesson
75-
run: |
7688
git config --global user.email "team@carpentries.org"
7789
git config --global user.name "The Carpentries Bot"
90+
7891
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"
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::"
83125
84126
- name: Look for R-markdown files
85127
id: check-rmd
@@ -96,8 +138,10 @@ jobs:
96138

97139
- name: Install needed packages
98140
if: steps.check-rmd.outputs.count != 0
141+
working-directory: lesson
99142
run: |
100-
install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
143+
source('bin/dependencies.R')
144+
install_required_packages(.libPaths()[1])
101145
shell: Rscript {0}
102146

103147
- name: Query dependencies
@@ -107,26 +151,35 @@ jobs:
107151
source('bin/dependencies.R')
108152
deps <- identify_dependencies()
109153
create_description(deps)
154+
use_bioc_repos()
110155
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
111156
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
112157
shell: Rscript {0}
113158

114-
- name: Cache R packages
159+
- name: Restore Package Cache
115160
if: runner.os != 'Windows' && steps.check-rmd.outputs.count != 0
116-
uses: actions/cache@v1
161+
uses: actions/cache@v2
117162
with:
118163
path: ${{ env.R_LIBS_USER }}
119164
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
120165
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
121166

167+
- name: Install stringi from source
168+
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
169+
run: install.packages('stringi', repos='https://cloud.r-project.org')
170+
shell: Rscript {0}
171+
122172
- name: Install system dependencies for R packages
123173
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
124174
working-directory: lesson
125175
run: |
126176
while read -r cmd
127177
do
128-
eval sudo $cmd
129-
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
178+
eval sudo $cmd || echo "Nothing to update"
179+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
130180
131181
- run: make site
132182
working-directory: lesson
183+
184+
- run: make lesson-check-all
185+
working-directory: lesson

.github/workflows/website.yml

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
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-18.04
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@v1
20+
uses: ruby/setup-ruby@v1
1621
with:
1722
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: |
@@ -47,10 +53,19 @@ jobs:
4753
use-public-rspm: true
4854
install-r: false
4955

56+
- name: Restore R Cache
57+
if: steps.check-rmd.outputs.count != 0
58+
uses: actions/cache@v2
59+
with:
60+
path: ${{ env.R_LIBS_USER }}
61+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
62+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
63+
5064
- name: Install needed packages
5165
if: steps.check-rmd.outputs.count != 0
5266
run: |
53-
install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
67+
source('bin/dependencies.R')
68+
install_required_packages()
5469
shell: Rscript {0}
5570

5671
- name: Query dependencies
@@ -59,28 +74,50 @@ jobs:
5974
source('bin/dependencies.R')
6075
deps <- identify_dependencies()
6176
create_description(deps)
77+
use_bioc_repos()
6278
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
6379
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
6480
shell: Rscript {0}
6581

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

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.ipynb_checkpoints
55
.sass-cache
66
.jekyll-cache/
7+
.jekyll-metadata
78
__pycache__
89
_site
910
_config.yml

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 cannot find that page.
9+
{: style="text-align: center;"}
10+
11+
> ## Our apologies!
12+
>
13+
> We cannot seem to find the page you are 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%}

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

Gemfile

Lines changed: 5 additions & 1 deletion
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
88
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

0 commit comments

Comments
 (0)