Skip to content

Commit 35633b7

Browse files
committed
Merge branch gh-pages of carpentries/styles
2 parents 73471fa + 9448b99 commit 35633b7

24 files changed

+388
-155
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/workflows/template.yml

Lines changed: 71 additions & 20 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 "[email protected]"
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,7 +138,8 @@ jobs:
96138
- name: Install needed packages
97139
if: steps.check-rmd.outputs.count != 0
98140
run: |
99-
install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
141+
packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))
142+
install.packages(packages, repo="https://cran.rstudio.com/")
100143
shell: Rscript {0}
101144

102145
- name: Query dependencies
@@ -118,14 +161,22 @@ jobs:
118161
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
119162
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
120163

164+
- name: Install stringi from source
165+
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
166+
run: install.packages('stringi', repos='https://cloud.r-project.org')
167+
shell: Rscript {0}
168+
121169
- name: Install system dependencies for R packages
122170
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
123171
working-directory: lesson
124172
run: |
125173
while read -r cmd
126174
do
127175
eval sudo $cmd
128-
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
176+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
129177
130178
- run: make site
131179
working-directory: lesson
180+
181+
- run: make lesson-check-all
182+
working-directory: lesson

.github/workflows/website.yml

Lines changed: 53 additions & 17 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-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@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: |
@@ -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
@@ -4,6 +4,7 @@
44
.ipynb_checkpoints
55
.sass-cache
66
.jekyll-cache/
7+
.jekyll-metadata
78
__pycache__
89
_site
910
.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%}

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)