Skip to content

Commit 35b1876

Browse files
committed
Merge branch gh-pages of carpentries/styles
2 parents 7a2319f + 2abba21 commit 35b1876

8 files changed

Lines changed: 142 additions & 58 deletions

File tree

.github/workflows/template.yml

Lines changed: 57 additions & 13 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 "[email protected]"
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
@@ -136,3 +177,6 @@ jobs:
136177
137178
- run: make site
138179
working-directory: lesson
180+
181+
- run: make lesson-check-all
182+
working-directory: lesson

CODE_OF_CONDUCT.md

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

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

_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.url + 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.url | append: 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 %}

_includes/links.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[cran-stringr]: https://cran.r-project.org/package=stringr
1313
[dc-lessons]: http://www.datacarpentry.org/lessons/
1414
[email]: mailto:[email protected]
15-
[github-importer]: https://import.github.com/
15+
[github-importer]: https://import2.github.com/
1616
[importer]: https://github.com/new/import
1717
[jekyll-collection]: https://jekyllrb.com/docs/collections/
1818
[jekyll-install]: https://jekyllrb.com/docs/installation/

assets/css/lesson.scss

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,32 @@ div.error::before { background-color: #ffebe6; content: "Error"; }
6464
div.warning:before { background-color: #f8f4e8; content:" Warning"; }
6565
div.output::before { background-color: #efefef; content: "Output"; }
6666

67-
div.language-bash::before { content: "Bash"; }
68-
div.language-c::before { content: "C"; }
69-
div.language-cmake::before { content: "CMake"; }
70-
div.language-cpp::before { content: "C++"; }
71-
div.language-html::before { content: "HTML"; }
72-
div.language-make::before { content: "Make"; }
73-
div.language-matlab::before { content: "MATLAB"; }
74-
div.language-python::before { content: "Python"; }
75-
div.language-r::before { content: "R"; }
76-
div.language-sql::before { content: "SQL"; }
67+
div.language-basic::before { content: "Basic"; }
68+
div.language-bash::before { content: "Bash"; }
69+
div.language-c::before { content: "C"; }
70+
div.language-chapel::before { content: "Chapel"; }
71+
div.language-cmake::before { content: "CMake"; }
72+
div.language-cpp::before { content: "C++"; }
73+
div.language-cuda::before { content: "Cuda"; }
74+
div.language-d::before { content: "D"; }
75+
div.language-fortran::before { content: "Fortran"; }
76+
div.language-go::before { content: "Go"; }
77+
div.language-html::before { content: "HTML"; }
78+
div.language-java::before { content: "Java"; }
79+
div.language-julia::before { content: "Julia"; }
80+
div.language-kotlin::before { content: "Kotlin"; }
81+
div.language-lua::before { content: "Lua"; }
82+
div.language-make::before { content: "Make"; }
83+
div.language-matlab::before { content: "MATLAB"; }
84+
div.language-opencl::before { content: "OpenCL"; }
85+
div.language-perl::before { content: "Perl"; }
86+
div.language-python::before { content: "Python"; }
87+
div.language-r::before { content: "R"; }
88+
div.language-ruby::before { content: "Ruby"; }
89+
div.language-rust::before { content: "Rust"; }
90+
div.language-scala::before { content: "Scala"; }
91+
div.language-sql::before { content: "SQL"; }
92+
div.language-vulkan::before { content: "Vulkan"; }
7793

7894
// Tab panels are used on Setup pages to show instructions for different Operating Systems
7995
.tab-pane {

bin/boilerplate/CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ There are many ways to contribute,
7070
from writing new exercises and improving existing ones
7171
to updating or filling in the documentation
7272
and submitting [bug reports][issues]
73-
about things that do not work, aren not clear, or are missing.
73+
about things that do not work, are not clear, or are missing.
7474
If you are looking for ideas, please see the 'Issues' tab for
7575
a list of issues associated with this repository,
7676
or you may also look at the issues for [Data Carpentry][dc-issues],
@@ -94,7 +94,7 @@ and (b) explain what you would take out to make room for it.
9494
The first encourages contributors to be honest about requirements;
9595
the second, to think hard about priorities.
9696

97-
We are also not looking for exercises or other material that only run on one platform.
97+
We are also not looking for exercises or other material that will only run on one platform.
9898
Our workshops typically contain a mixture of Windows, macOS, and Linux users;
9999
in order to be usable,
100100
our lessons must run equally well on all three.
@@ -104,7 +104,7 @@ our lessons must run equally well on all three.
104104
If you choose to contribute via GitHub, you may want to look at
105105
[How to Contribute to an Open Source Project on GitHub][how-contribute].
106106
To manage changes, we follow [GitHub flow][github-flow].
107-
Each lesson has two maintainers who review issues and pull requests or encourage others to do so.
107+
Each lesson has at least two maintainers who review issues and pull requests or encourage others to do so.
108108
The maintainers are community volunteers and have final say over what gets merged into the lesson.
109109
To use the web interface for contributing to a lesson:
110110

@@ -128,12 +128,12 @@ repository for reference while revising.
128128

129129
## Other Resources
130130

131-
General discussion of [Software Carpentry][swc-site] and [Data Carpentry][dc-site]
131+
General discussion of [Software Carpentry][swc-site], [Data Carpentry][dc-site], and [Library Carpentry][lc-site]
132132
happens on the [discussion mailing list][discuss-list],
133133
which everyone is welcome to join.
134134
You can also [reach us by email][email].
135135

136-
[email]: mailto:admin@software-carpentry.org
136+
[email]: mailto:team@carpentries.org
137137
[dc-issues]: https://github.com/issues?q=user%3Adatacarpentry
138138
[dc-lessons]: http://datacarpentry.org/lessons/
139139
[dc-site]: http://datacarpentry.org/

bin/dependencies.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ install_required_packages <- function(lib = NULL, repos = getOption("repos", def
55
}
66

77
message("lib paths: ", paste(lib, collapse = ", "))
8-
missing_pkgs <- setdiff(
9-
c("rprojroot", "desc", "remotes", "renv"),
10-
rownames(installed.packages(lib.loc = lib))
11-
)
8+
required_pkgs <- c("rprojroot", "desc", "remotes", "renv")
9+
installed_pkgs <- rownames(installed.packages(lib.loc = lib))
10+
missing_pkgs <- setdiff(required_pkgs, installed_pkgs)
11+
1212
# The default installation of R will have "@CRAN@" as the default repository, which directs contrib.url() to either
1313
# force the user to choose a mirror if interactive or fail if not. Since we are not interactve, we need to force the
1414
# mirror here.
1515
if ("@CRAN@" %in% repos) {
1616
repos <- c(CRAN = "https://cran.rstudio.com/")
1717
}
1818

19-
install.packages(missing_pkgs, lib = lib, repos = repos)
20-
19+
if (length(missing_pkgs) != 0) {
20+
install.packages(missing_pkgs, lib = lib, repos = repos)
21+
}
2122
}
2223

2324
find_root <- function() {

bin/lesson_check.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ def main():
113113
if life_cycle == "pre-alpha":
114114
args.permissive = True
115115
check_source_rmd(args.reporter, args.source_dir, args.parser)
116-
args.references = read_references(args.reporter, args.reference_path)
116+
117+
args.references = {}
118+
if not using_remote_theme(args.source_dir):
119+
args.references = read_references(args.reporter, args.reference_path)
117120

118121
docs = read_all_markdown(args.source_dir, args.parser)
119122
check_fileset(args.source_dir, args.reporter, list(docs.keys()))
@@ -167,6 +170,10 @@ def parse_args():
167170

168171
return args
169172

173+
def using_remote_theme(source_dir):
174+
config_file = os.path.join(source_dir, '_config.yml')
175+
config = load_yaml(config_file)
176+
return 'remote_theme' in config
170177

171178
def check_config(reporter, source_dir):
172179
"""Check configuration file."""
@@ -493,7 +500,8 @@ def check(self):
493500
"""Run extra tests."""
494501

495502
super().check()
496-
self.check_reference_inclusion()
503+
if not using_remote_theme(args.source_dir):
504+
self.check_reference_inclusion()
497505

498506
def check_metadata(self):
499507
super().check_metadata()

0 commit comments

Comments
 (0)