Skip to content

Commit c82969f

Browse files
authored
Merge pull request #102 from LibraryCarpentry/update-styles-final
Update to final version of styles lesson template
2 parents 9b688fe + a900378 commit c82969f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3063
-1234
lines changed

.editorconfig

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
8+
[*.md]
9+
indent_size = 2
10+
indent_style = space
11+
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/>)
13+
14+
[*.r]
15+
max_line_length = 80
16+
17+
[*.py]
18+
indent_size = 4
19+
indent_style = space
20+
max_line_length = 79
21+
22+
[*.sh]
23+
end_of_line = lf
24+
25+
[Makefile]
26+
indent_style = tab

.github/ISSUE_TEMPLATE.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
Please delete the text below before submitting your contribution.
1+
<details>
2+
<summary><strong>Instructions</strong></summary>
23

3-
---
4+
Thanks for contributing! :heart:
45

5-
Thanks for contributing! If this contribution is for instructor training, please send an email to [email protected] with a link to this contribution so we can record your progress. You’ve completed your contribution step for instructor checkout just by submitting this contribution.
6+
If this contribution is for instructor training, please email the link to this contribution to
7+
[email protected] so we can record your progress. You've completed your contribution
8+
step for instructor checkout by submitting this contribution!
69

7-
Please keep in mind that lesson maintainers are volunteers and it may be some time before they can respond to your contribution. Although not all contributions can be incorporated into the lesson materials, we appreciate your time and effort to improve the curriculum. If you have any questions about the lesson maintenance process or would like to volunteer your time as a contribution reviewer, please contact Kate Hertweck ([email protected]).
10+
If this issue is about a specific episode within a lesson, please provide its link or filename.
811

9-
---
12+
Keep in mind that **lesson maintainers are volunteers** and it may take them some time to
13+
respond to your contribution. Although not all contributions can be incorporated into the lesson
14+
materials, we appreciate your time and effort to improve the curriculum. If you have any questions
15+
about the lesson maintenance process or would like to volunteer your time as a contribution
16+
reviewer, please contact The Carpentries Team at [email protected].
17+
18+
You may delete these instructions from your comment.
19+
20+
\- The Carpentries
21+
</details>

.github/PULL_REQUEST_TEMPLATE.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
Please delete the text below before submitting your contribution.
1+
<details>
2+
<summary><strong>Instructions</strong></summary>
23

3-
---
4+
Thanks for contributing! :heart:
45

5-
Thanks for contributing! If this contribution is for instructor training, please send an email to [email protected] with a link to this contribution so we can record your progress. You’ve completed your contribution step for instructor checkout just by submitting this contribution.
6+
If this contribution is for instructor training, please email the link to this contribution to
7+
[email protected] so we can record your progress. You've completed your contribution
8+
step for instructor checkout by submitting this contribution!
69

7-
Please keep in mind that lesson maintainers are volunteers and it may be some time before they can respond to your contribution. Although not all contributions can be incorporated into the lesson materials, we appreciate your time and effort to improve the curriculum. If you have any questions about the lesson maintenance process or would like to volunteer your time as a contribution reviewer, please contact Kate Hertweck ([email protected]).
10+
Keep in mind that **lesson maintainers are volunteers** and it may take them some time to
11+
respond to your contribution. Although not all contributions can be incorporated into the lesson
12+
materials, we appreciate your time and effort to improve the curriculum. If you have any questions
13+
about the lesson maintenance process or would like to volunteer your time as a contribution
14+
reviewer, please contact The Carpentries Team at [email protected].
815

9-
---
16+
You may delete these instructions from your comment.
17+
18+
\- The Carpentries
19+
</details>

.github/workflows/template.yml

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
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+
continue-on-error: ${{ matrix.experimental }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
lesson: [swcarpentry/shell-novice, datacarpentry/r-intro-geospatial, librarycarpentry/lc-git]
16+
os: [ubuntu-20.04, macos-latest, windows-latest]
17+
experimental: [false]
18+
include:
19+
- os: ubuntu-20.04
20+
os-name: Linux
21+
- os: macos-latest
22+
os-name: macOS
23+
- os: windows-latest
24+
os-name: Windows
25+
- lesson: swcarpentry/shell-novice
26+
lesson-name: (SWC) Shell novice
27+
- lesson: datacarpentry/r-intro-geospatial
28+
lesson-name: (DC) R Intro Geospatial
29+
- lesson: librarycarpentry/lc-git
30+
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
41+
defaults:
42+
run:
43+
shell: bash # forces 'Git for Windows' on Windows
44+
env:
45+
RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest'
46+
steps:
47+
- name: Set up Ruby
48+
uses: ruby/setup-ruby@v1
49+
with:
50+
ruby-version: '2.7'
51+
bundler-cache: true
52+
53+
- name: Set up Python
54+
uses: actions/setup-python@v2
55+
with:
56+
python-version: '3.x'
57+
58+
- name: Install GitHub Pages, Bundler, and kramdown gems
59+
run: |
60+
gem install github-pages bundler kramdown kramdown-parser-gfm
61+
62+
- name: Install Python modules
63+
run: |
64+
if [[ $RUNNER_OS == macOS || $RUNNER_OS == Linux ]]; then
65+
python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
66+
elif [[ $RUNNER_OS == Windows ]]; then
67+
python -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
68+
fi
69+
70+
- name: Checkout the ${{ matrix.lesson }} lesson
71+
uses: actions/checkout@master
72+
with:
73+
repository: ${{ matrix.lesson }}
74+
path: lesson
75+
fetch-depth: 0
76+
77+
- name: Sync lesson with carpentries/styles
78+
working-directory: lesson
79+
run: |
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"
84+
else
85+
ref="gh-pages"
86+
fi
87+
88+
git config --global user.email "[email protected]"
89+
git config --global user.name "The Carpentries Bot"
90+
91+
git remote add styles https://github.com/carpentries/styles.git
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::"
125+
126+
- name: Look for R-markdown files
127+
id: check-rmd
128+
working-directory: lesson
129+
run: |
130+
echo "count=$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})" >> $GITHUB_OUTPUT
131+
132+
- name: Set up R
133+
if: steps.check-rmd.outputs.count != 0
134+
uses: r-lib/actions/setup-r@v2
135+
with:
136+
use-public-rspm: true
137+
install-r: false
138+
139+
- name: Install needed packages
140+
if: steps.check-rmd.outputs.count != 0
141+
working-directory: lesson
142+
run: |
143+
source('bin/dependencies.R')
144+
install_required_packages(.libPaths()[1])
145+
shell: Rscript {0}
146+
147+
- name: Query dependencies
148+
if: steps.check-rmd.outputs.count != 0
149+
working-directory: lesson
150+
run: |
151+
source('bin/dependencies.R')
152+
deps <- identify_dependencies()
153+
create_description(deps)
154+
use_bioc_repos()
155+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
156+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
157+
shell: Rscript {0}
158+
159+
- name: Restore Package Cache
160+
if: runner.os != 'Windows' && steps.check-rmd.outputs.count != 0
161+
uses: actions/cache@v2
162+
with:
163+
path: ${{ env.R_LIBS_USER }}
164+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
165+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
166+
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+
172+
- name: Install system dependencies for R packages
173+
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
174+
working-directory: lesson
175+
run: |
176+
while read -r cmd
177+
do
178+
eval sudo $cmd || echo "Nothing to update"
179+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
180+
181+
- run: make site
182+
working-directory: lesson
183+
184+
- run: make lesson-check-all
185+
working-directory: lesson

.github/workflows/website.yml

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Website
2+
on:
3+
push:
4+
branches:
5+
- gh-pages
6+
- main
7+
pull_request: []
8+
jobs:
9+
build-website:
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 }}
15+
defaults:
16+
run:
17+
shell: bash
18+
steps:
19+
- name: Set up Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: '2.7'
23+
bundler-cache: true
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v2
27+
with:
28+
python-version: '3.x'
29+
30+
- name: Install GitHub Pages, Bundler, and kramdown gems
31+
run: |
32+
gem install github-pages bundler kramdown kramdown-parser-gfm
33+
34+
- name: Install Python modules
35+
run: |
36+
python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
37+
38+
- name: Checkout the lesson
39+
uses: actions/checkout@master
40+
with:
41+
fetch-depth: 0
42+
ref: ${{ github.event.pull_request.head.sha }}
43+
44+
- name: Look for R-markdown files
45+
id: check-rmd
46+
run: |
47+
echo "count=$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})" >> $GITHUB_OUTPUT
48+
49+
- name: Set up R
50+
if: steps.check-rmd.outputs.count != 0
51+
uses: r-lib/actions/setup-r@v2
52+
with:
53+
use-public-rspm: true
54+
install-r: false
55+
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+
64+
- name: Install needed packages
65+
if: steps.check-rmd.outputs.count != 0
66+
run: |
67+
source('bin/dependencies.R')
68+
install_required_packages()
69+
shell: Rscript {0}
70+
71+
- name: Query dependencies
72+
if: steps.check-rmd.outputs.count != 0
73+
run: |
74+
source('bin/dependencies.R')
75+
deps <- identify_dependencies()
76+
create_description(deps)
77+
use_bioc_repos()
78+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
79+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
80+
shell: Rscript {0}
81+
82+
83+
- name: Install system dependencies for R packages
84+
if: steps.check-rmd.outputs.count != 0
85+
run: |
86+
while read -r cmd
87+
do
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 "[email protected]"
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 ..
121+
122+
- run: make lesson-check-all
123+
if: always()

0 commit comments

Comments
 (0)