Skip to content

Commit 4915838

Browse files
authored
Initial commit
0 parents  commit 4915838

File tree

256 files changed

+18161
-0
lines changed

Some content is hidden

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

256 files changed

+18161
-0
lines changed

.editorconfig

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
12+
# Please keep this in sync with bin/lesson_check.py!
13+
max_line_length = 100
14+
15+
# keep trailing spaces in markdown - 2+ spaces are translated to a hard break (<br/>)
16+
trim_trailing_whitespace = false
17+
18+
[*.r]
19+
max_line_length = 80
20+
21+
[*.py]
22+
indent_size = 4
23+
indent_style = space
24+
max_line_length = 79
25+
26+
[*.sh]
27+
end_of_line = lf
28+
29+
[Makefile]
30+
indent_style = tab

.github/ISSUE_TEMPLATE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<details>
2+
<summary><strong>Instructions</strong></summary>
3+
4+
Thanks for contributing! :heart:
5+
6+
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
8+
step for instructor checkout by submitting this contribution!
9+
10+
If this issue is about a specific episode within a lesson, please provide its link or filename.
11+
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 team@carpentries.org.
17+
18+
You may delete these instructions from your comment.
19+
20+
\- The Carpentries
21+
</details>

.github/PULL_REQUEST_TEMPLATE.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<details>
2+
<summary><strong>Instructions</strong></summary>
3+
4+
Thanks for contributing! :heart:
5+
6+
If this contribution is for instructor training, please email the link to this contribution to
7+
instructor.training@carpentries.org so we can record your progress. You've completed your contribution
8+
step for instructor checkout by submitting this contribution!
9+
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 team@carpentries.org.
15+
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: '3.0'
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 "team@carpentries.org"
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

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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: '3.0'
23+
bundler-cache: true
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5.1.0
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@v4
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+
- name: Install system dependencies for R packages
83+
if: steps.check-rmd.outputs.count != 0
84+
run: |
85+
while read -r cmd
86+
do
87+
eval sudo $cmd || echo "Nothing to update"
88+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
89+
90+
- name: Render the markdown and confirm that the site can be built
91+
run: make site
92+
93+
- name: Checkout github pages
94+
if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
95+
uses: actions/checkout@master
96+
with:
97+
ref: gh-pages
98+
path: gh-pages
99+
100+
- name: Validate workshop website
101+
# https://github.com/carpentries/styles/issues/551 is no longer relevant as styles shouldn't be used for
102+
# lessons but only workshop templates. So, always run the workshop checks now.
103+
run: make workshop-check
104+
if: always()
105+
106+
- name: Commit and Push
107+
if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
108+
run: |
109+
# clean up gh-pages
110+
cd gh-pages
111+
git rm -rf . # remove all previous files
112+
git restore --staged . # remove things from the stage
113+
cd ..
114+
# copy everything into gh-pages site
115+
cp -r `ls -A | grep -v 'gh-pages' | grep -v '.git' | grep -v '.bundle/' | grep -v '_site'` gh-pages
116+
# move into gh-pages, add, commit, and push
117+
cd gh-pages
118+
# setup git
119+
git config --local user.email "actions@github.com"
120+
git config --local user.name "GitHub Actions"
121+
git add -A .
122+
git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }})"
123+
git push origin gh-pages
124+
# return
125+
cd ..

0 commit comments

Comments
 (0)