Skip to content

Commit

Permalink
Attempt to update to latest styles (#9)
Browse files Browse the repository at this point in the history
* translate CONDUCT.md

* translate LICENSE.md

* translate files

* translate files

* translate files

* translate files

* translate files

* translate files

* don't translate organization names

* Update CONDUCT.md

* updated license

following this https://creativecommons.org/licenses/by/4.0/deed.es insead of usted tu

* fix link referrence

* r reproducible

* r reproducible

* r reproducible

* translate overview and teaching

* change finish for Final

* Update schedule.html

Traducido

* translate 'finish' to 'final

as per swcarpentry/r-novice-gapminder-es#53

* translate 'cite' to 'cita'

as per swcarpentry/r-novice-gapminder-es#54

* Update navbar.html

fix typo, as suggested in swcarpentry/r-novice-gapminder-es#92

* mejore -> mejora

* assets/css/lesson.scss: add proper padding to the top of paragraphs in blockquotes (#425)

* restore lost CSS settings

* Manual ordering of episodes and extras

Co-authored-by: stamper <tbyhdgs@gmail.com>

* [fix carpentries/workshop-template#513] remove site.title outside

lessons

* update survey links

* Switch to Liquid comments

HTML comments end up in the generated HTML pages: they're not displayed by the browsers but they're still present there. Liquid comments do not end up in the generated HTML pages

* bin/boilerplate/README.md: fix typo

carpentries/styles#441

* Use Jekyll to generate the 'all-in-one' page (carpentries/styles#438)

* manual_episode_order.html: fix typo in a comment

* Enable 'Sponsor' button on GitHub repos

* remove Jekyll command markers from comment block

fix carpentries/lesson-example#281

* Forced re-encoding of text to UTF-8, to avoid issues on Windows

* Refactored paths to make use of OS agnostic methods

* Modified shebang to use python, not python3.

* Reverted change of permissiveness on lesson_check

* Cleaned leftover debug code and old implementations.

* Added PYTHON variable to define executable to run python scripts

* Reverted variable names

* Removed shebang lines from Python scripts to avoid cross-OS problems

* Fixes encoding problem on Windows systems, with minimal changes to existing code.

* Silenced output of PYTHON calls

* Makefile: detect Python 3

* util.py: remove empty line

* Undo optimizations to read_all_markdown

These will be submitted in a separate PR

* Remove executable bits from Python scripts

We can't use a single shebang:
* on some platforms `python` may mean Python 2, on others - Python 3
* on some platforms `python3` does not exist at all

Therefore, we're removing the shebangs altogether.

* lesson_initialize: windows compatibility

* lesson_check.py: Windows-compatible regular expression pattern

* repo_check.py: enforce utf-8 encoding

... for compatibility with Windows

* clarify comment on python check block

* Makefile: Windows does not like single quotes

* test_lesson_check.py: skip unnecessary steps

* Makefile: suppress error message on Windows

* fix typo in lesson_initialize.py

* Makefile: suppress another error message on Windows

These '2>/dev/null' are important on Windows because without them
a mere `make` stalls.

* Makefile: handle MS Store's Python 3

* Makefile: fix syntax in conditional

* Makefile: fix two more syntax errors in conditionals

* fix urls in _config.yml

* use bundler to render lessons

* install gems locally

* refactor use of docker

Co-authored-by: Allen Lee <allen.lee@asu.edu>

* add @maxim-belkin suggestions

* add .bundle to .gitignore

* Makefile: Specify shell. Don't include commands.mk

* Makefile: use Python to execute repo_check.py

* Makefile: improve commands target and commands categories (#450)

* Makefile: improve commands target and commands categories

* replace 'files' with 'website'

* Update R install in .travis.yml (#430)

* Update R install in .travis.yml

See https://cran.r-project.org/bin/linux/ubuntu/README.html

* update .travis.yml

* specify YAML loader

Co-authored-by: Daniel McCloy <dan.mccloy@gmail.com>c

* add warning hook + CSS class for Rmd-based lessons (#455)

* Update PyPI link

* Use carpentries/lesson-docker for docker-serve make rule (#461)

* Use renv (#462)

* Improve issue template (#463)

Co-authored-by: Sarah Brown <sarah_m_brown@brown.edu>

* lesson.scss: style tab panels on setup pages (#464)

* Improve pull request template (#465)

* OS stripe color (#468)

* bump ruby version

* Upgrade jQuery to 3.5.1 (#469)

```
cd assets/js
wget https://code.jquery.com/jquery-3.5.1.min.js
wget https://code.jquery.com/jquery-3.5.1.min.map
mv -f jquery-3.5.1.min.js jquery.min.js
mv -f jquery-3.5.1.min.map jquery.min.map
```

Fixes carpentries/styles#460

* assets/js/lesson.js: use .length instead of .size()

.size() was deprecated in jQuery 3.0 in favor of .length attribute.
https://jquery.com/upgrade-guide/3.0/#breaking-change-deprecated-size-removed

Co-Authored-By: Thomas Green <tomgreen66@hotmail.com>

* License is not a copyright. License info ID (#472)

* fix AMY's URL

* Deprecated use of --path when installing bundle (#473)

* add warning blockquote style, carpentries/styles#49 (#475)

* Make links in code tags distinguishable (#478)

* _config.yml: link to Lesson Life Cycle chapter of CDH

To help users of the lesson template understand how to choose/when to update the value of life_cycle

* repo_check.py: allow URLs not ending with .git (#482)

* Makefile: fix comment in front of `lesson-check` (#481)

Comments prepended with `##` appear in the output of `make commands`.
This commit changes `#` to `##` in front of `lesson-check` so that it
appears in the output of `make commands`.

* repo_check.py: match https repositories (#483)

* Makefile: don't use /bin/bash shell (#484)

* [fix carpentries/styles#477] rewrite travis script

* add vendor folder to gitignore and _config.yml

* OS stripe: adjust line height (#490)

* Makefile: fix 'lesson-fixme' target for Windows (#486)

Git for Windows doesn't provide fgrep, which is a shortcut
to call `grep -F` on Mac and Linux. Instead, we have to use
full arguments.

* Fix Python scripts for Windows: UTF-8 encoding (#485)

To avoid problems with various symbols, we have to specify the encoding
when we read files.
The actual codec name is `utf_8` but aliases like `utf8`, `utf-8`, etc
are accepted. Here, I'm using `utf-8` alias.
https://docs.python.org/3.8/library/codecs.html#standard-encodings

This fixes `make lesson-check` when running under 'Git for Windows' for
lessons that have non-cp1252 characters.

* only display Episodes drop-down if we have episodes to show (#491)

* fix variable name

* GitHub Actions: check lesson template (#489)

Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
Co-authored-by: François Michonneau <francois.michonneau@gmail.com>

* fix: tighten definitions of highlighter (#496)

* add three more common languages (#497)

* remove unused code highlight classes (#498)

* Sync styles first (#494)

Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>

* GitHub Actions: website (#488)

* GitHub Actions: better workflow and job names (#500)

* GitHub Action: website.yml: don't run in forks (#501)

* GH Website action: rename + don't use lesson directory (#504)

When 'Website' action tests a lesson, it checks out repositories into the current working directory: 'lesson' directory doesn't exist.
As a result, steps that use "lesson" as the working directory fail.

* lesson.scss: styling for DIVs for embedding Youtube videos (#503)

* update link to discuss mailing list (#507)

* add default repository to install_required_packages() (#509)

* add warning blockquote

* Revert "Merge branch 'gh-pages' of github.com:carpentries/styles into gh-pages"

This reverts commit 2c6b97e, reversing
changes made to 53e9913.

* add warning code block

* update expected reference filename (#508)

* lesson.scss: no borders around unrecognized code (#510)

* bump ruby version (as specified in github-pages v209)

* drop patch version, fix at v1

* removing contractions from CONTRIBUTING (#512)

* add image-with-shadow class

* _config.yml: mention Carpentries Incubator

* Matlab -> MATLAB

* set CRAN url if default is "@cran@"

This will fix #526

* Fix Ruby style

* accept any base filename for Rmd episodes

* run R-based lessons in forks

This is a modification for #501

* add control structure

* 404 page for better learner experience

* lesson.scss: wildcard selectors for code blocks

* Ignore .jekyll-metatada

* Speed up builds of R-based lessons

R-based lessons might take a while to build because packages need to be compiled from source. RStudio Package Manager has compiled versions of packages for ubuntu distros starting with 16.04: https://packagemanager.rstudio.com/client/#/repos/1/overview

I've added the necessary magic in the actions yaml to make it work.

* No need for User Agent string

* permissive checks for pre-alpha lessons

This will fix #533

* bin/lesson_check.py: allow 'language-*' code blocks (#532)

* bin/lesson_check.py: allow 'caution' blockquote

* avoid ansi color characters from being printed

* deploy from "website" action

* deploy R-based lessons without using another action

* also delete _site

* include @zkamvar suggestions

Co-authored-by: Zhian N. Kamvar <zkamvar@gmail.com>

* pin ubuntu version to 20.04 (#540)

Co-authored-by: Zhian N. Kamvar <zkamvar@gmail.com>

* GitHub Actions: cache required R packages (#534)

* add missing parenthesis

* Add incubator option for carpentry field. (#542)

Closes #541

* .editorconfig: don't trim trailing spaces in markdown

* lesson.scss: HTML block

carpentries/styles#519

* add patch to clean gh-pages before committing (#545)

This will address #544

* Fix Kramdown parser crash

... by using GFM (GitHub-flavored Markdown) parser (`kramdown-parser-gfm`)
instead of the default one (`kramdown`).

The default one fails to produce an AST (Abstract Syntax Tree) when
there is no blank line before the line with the opening code fence.

Related:
 - gettalong/kramdown#530
 - Python-Markdown/markdown#807

Fixes: carpentries/styles#543

* bin/util.py: Change ruby executable to "bundle exec ruby"

Closes: carpentries/styles#547

* Change link colours (#549)

...to make them distinguishable from regular text. And for accessibility!

* bin/workshop_check.py: update default contact email address

* Gemfile: add 'webrick' dependency for Ruby 3.0.0 and above

Fixes carpentries/styles#552

* lesson_check.py allow for missing life_cycle

This will fix carpentries/styles#556

* update with Maxim's suggestion

* Add catch for None type code block in lesson_check

There are times when the AST is malformed and does not emit a class for
the code element. We do not want the parser to crash when this happens,
but we also want to notify ourselves that the AST is malformed.

This should not result in an error because as we saw in
carpentries/styles#543, the parser itself can
cause these malformations when the lesson itself renders well. Even
though we fixed the previous issue with an updated parser, problems
still persist:
swcarpentry/r-novice-gapminder#696 (comment)

I fully admit that this is a kludge.

* fix syntax

I've removed the print condition, because it will just result in an error no matter what (sigh)

* Makefile: fix 'bundle config' command flags

* Makefile: clean target: remove .vendor, .bundle, Gemfile.lock

Clean up:
1. `.vendor` directory where Bundler installs all the gems.
2. `.bundle` directory where Bundler stores its settings.
3. `Gemfile.lock` file generated by the Bundler.

* Makefile: silence Docker commands

* use Ruby's official GH Actions

* Makefile: use SHELL to call bin/knit_lesson.sh

* Makefile: fix up PHONY targets

* Fix GitHub actions for lessons in Rmarkdown

Specifically, set CRAN repository to https://cran.rstudio.com

* apply single shadow to image class

* use grey shadow instead of transparent black

* expand image-with-shadow selection

* Makefile: don't fail when Python isn't found

* bin/dependencies.R: handle 'no packages were specified' error

Fixes the following issue:

```
$ make site
lib paths: /Library/Frameworks/R.framework/Versions/3.5/Resources/library
Error in install.packages(missing_pkgs, lib = lib, repos = repos) :
  no packages were specified
Calls: install_required_packages -> install.packages
Execution halted
make: *** [install-rmd-deps] Error 1
```

* Don't check links.md in lessons that use remote theme

Fixes carpentries/styles#570

* add link references to code_of_conduct.md (#572)

* Update links.md

* add source_dir argument

This will fix carpentries/styles#576

* Improved relative_root_path

* update contributing guide

* add further languages for box titles (#580)

Will be useful for HPC-Carpentry lessons, GPU programming lesson as well as Julia lessons which are currently in the incubator.

* bin/lesson_check.py: one more fix for using_remote_theme()

* Template workflow: add two more lessons

* add make lesson-check-all step

* Set working directory for the 'make site' step

* Template workflow: smarter syncing with the styles repo

Current syncing procedure that used in the Template workflow fails for:

1. Lessons that are, in fact, nsync with the styles repo.
2. For lessons that use The Carpentries' remote theme and have deleted
   some of the files.

This PR makes this step a little bit more intelligent and takes into
account the above two scenarios.

* Apply Zhian's suggestions

Co-authored-by: Zhian N. Kamvar <zkamvar@gmail.com>

* add math support with katex (#573)

* bin/util.py: remove unused 'IMAGE_FILE_SUFFIX' var (#590)

It should've been removed in 7e835fd.

Co-authored-by: Erin Becker <erinstellabecker@gmail.com>
Co-authored-by: Paula Andrea <orchid00@users.noreply.github.com>
Co-authored-by: François Michonneau <francois.michonneau@gmail.com>
Co-authored-by: raynamharris <rayna.harris@utexas.edu>
Co-authored-by: Paola Prieto <31372246+PaoPrieto@users.noreply.github.com>
Co-authored-by: Rayna M Harris <raynamharris@users.noreply.github.com>
Co-authored-by: Raniere Silva <raniere@rgaiacs.com>
Co-authored-by: K.E. Koziar <katherine.koziar@ucr.edu>
Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
Co-authored-by: stamper <tbyhdgs@gmail.com>
Co-authored-by: Michael Joseph <josephmje.22@gmail.com>
Co-authored-by: Joao Rodrigues <j.p.g.l.m.rodrigues@gmail.com>
Co-authored-by: Sarah Brown <sarah_m_brown@brown.edu>
Co-authored-by: Allen Lee <allen.lee@asu.edu>
Co-authored-by: Anthony Gitter <agitter@users.noreply.github.com>
Co-authored-by: Katrin Leinweber <9948149+katrinleinweber@users.noreply.github.com>
Co-authored-by: Zhian N. Kamvar <zkamvar@gmail.com>
Co-authored-by: Thomas Green <tomgreen66@hotmail.com>
Co-authored-by: ocaisa <a.ocais@fz-juelich.de>
Co-authored-by: Joseph Stachelek <jsta@users.noreply.github.com>
Co-authored-by: Renato Alves <alves.rjc@gmail.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-authored-by: Christina K <christinakconnect@gmail.com>
Co-authored-by: Kilian <kilian.lieret@posteo.de>
Co-authored-by: Trevor Keller <trevor.keller@gmail.com>
Co-authored-by: Andrew Reid <andrew.reid@nist.gov>
Co-authored-by: Bailey Harrington <baileythegreen@gmail.com>
Co-authored-by: Alan O'Callaghan <alan.ocallaghan@outlook.com>
Co-authored-by: Benson Muite <bkmgit@users.noreply.github.com>
  • Loading branch information
1 parent 5e958ef commit 3455c4f
Show file tree
Hide file tree
Showing 50 changed files with 1,199 additions and 336 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ trim_trailing_whitespace = true
indent_size = 2
indent_style = space
max_line_length = 100 # Please keep this in sync with bin/lesson_check.py!
trim_trailing_whitespace = false # keep trailing spaces in markdown - 2+ spaces are translated to a hard break (<br/>)

[*.r]
max_line_length = 80
Expand Down
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [carpentries, swcarpentry, datacarpentry, librarycarpentry]
custom: ["https://carpentries.wedid.it"]
20 changes: 15 additions & 5 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
Please delete this line and the text below before submitting your contribution.
<details>
<summary><strong>Instructions</strong></summary>

---
Thanks for contributing! :heart:

Thanks for contributing! If this contribution is for instructor training, please send an email to checkout@carpentries.org 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.
If this contribution is for instructor training, please email the link to this contribution to
checkout@carpentries.org so we can record your progress. You've completed your contribution
step for instructor checkout by submitting this contribution!

If this issue is about a specific episode within a lesson, please provide its link or filename.

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 The Carpentries Team at team@carpentries.org.
Keep in mind that **lesson maintainers are volunteers** and it may take them some time to
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 The Carpentries Team at team@carpentries.org.

---
You may delete these instructions from your comment.

\- The Carpentries
</details>
20 changes: 15 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
Please delete this line and the text below before submitting your contribution.
<details>
<summary><strong>Instructions</strong></summary>

---
Thanks for contributing! :heart:

Thanks for contributing! If this contribution is for instructor training, please send an email to checkout@carpentries.org 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.
If this contribution is for instructor training, please email the link to this contribution to
checkout@carpentries.org so we can record your progress. You've completed your contribution
step for instructor checkout by submitting this contribution!

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 The Carpentries Team at team@carpentries.org.
Keep in mind that **lesson maintainers are volunteers** and it may take them some time to
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 The Carpentries Team at team@carpentries.org.

---
You may delete these instructions from your comment.

\- The Carpentries
</details>
182 changes: 182 additions & 0 deletions .github/workflows/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: Test template
on:
push:
branches: gh-pages
pull_request:
jobs:
check-template:
name: ${{ matrix.lesson-name }} (${{ matrix.os-name }})
if: github.repository == 'carpentries/styles'
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
lesson: [swcarpentry/shell-novice, datacarpentry/r-intro-geospatial, librarycarpentry/lc-git]
os: [ubuntu-20.04, macos-latest, windows-latest]
experimental: [false]
include:
- os: ubuntu-20.04
os-name: Linux
- os: macos-latest
os-name: macOS
- os: windows-latest
os-name: Windows
- lesson: swcarpentry/shell-novice
lesson-name: (SWC) Shell novice
- lesson: datacarpentry/r-intro-geospatial
lesson-name: (DC) R Intro Geospatial
- lesson: librarycarpentry/lc-git
lesson-name: (LC) Intro to Git
- lesson: datacarpentry/astronomy-python
lesson-name: (DC) Foundations of Astronomical Data Science
experimental: true
os: ubuntu-20.04
os-name: Linux
- lesson: carpentries/lesson-example
lesson-name: (CP) Lesson Example
experimental: false
os: ubuntu-20.04
os-name: Linux
defaults:
run:
shell: bash # forces 'Git for Windows' on Windows
env:
RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest'
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install GitHub Pages, Bundler, and kramdown gems
run: |
gem install github-pages bundler kramdown kramdown-parser-gfm
- name: Install Python modules
run: |
if [[ $RUNNER_OS == macOS || $RUNNER_OS == Linux ]]; then
python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
elif [[ $RUNNER_OS == Windows ]]; then
python -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
fi
- name: Checkout the ${{ matrix.lesson }} lesson
uses: actions/checkout@master
with:
repository: ${{ matrix.lesson }}
path: lesson
fetch-depth: 0

- name: Sync lesson with carpentries/styles
working-directory: lesson
run: |
echo "::group::Fetch Styles"
if [[ -n "${{ github.event.pull_request.number }}" ]]
then
ref="refs/pull/${{ github.event.pull_request.number }}/head"
else
ref="gh-pages"
fi
git config --global user.email "team@carpentries.org"
git config --global user.name "The Carpentries Bot"
git remote add styles https://github.com/carpentries/styles.git
git fetch styles $ref:styles-ref
echo "::endgroup::"
echo "::group::Synchronize Styles"
# Sync up only if necessary
if [[ $(git rev-list --count HEAD..styles-ref) != 0 ]]
then
# The merge command below might fail for lessons that use remote theme
# https://github.com/carpentries/carpentries-theme
echo "Testing merge using recursive strategy, accepting upstream changes without committing"
if ! git merge -s recursive -Xtheirs --no-commit styles-ref
then
# Remove "deleted by us, unmerged" files from the staging area.
# these are the files that were removed from the lesson
# but are still present in the carpentries/styles repo
echo "Removing previously deleted files"
git rm $(git diff --name-only --diff-filter=DU)
# If there are still "unmerged" files,
# let's raise an error and look into this more closely
if [[ -n $(git diff --name-only --diff-filter=U) ]]
then
echo "There were unmerged files in ${{ matrix.lesson-name }}:"
echo "$(git diff --compact-summary --diff-filter=U)"
exit 1
fi
fi
echo "Committing changes"
git commit -m "Sync lesson with carpentries/styles"
fi
echo "::endgroup::"
- name: Look for R-markdown files
id: check-rmd
working-directory: lesson
run: |
echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})"
- name: Set up R
if: steps.check-rmd.outputs.count != 0
uses: r-lib/actions/setup-r@master
with:
r-version: 'release'

- name: Install needed packages
if: steps.check-rmd.outputs.count != 0
run: |
packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))
install.packages(packages, repo="https://cran.rstudio.com/")
shell: Rscript {0}

- name: Query dependencies
if: steps.check-rmd.outputs.count != 0
working-directory: lesson
run: |
source('bin/dependencies.R')
deps <- identify_dependencies()
create_description(deps)
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

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

- name: Install stringi from source
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
run: install.packages('stringi', repos='https://cloud.r-project.org')
shell: Rscript {0}

- name: Install system dependencies for R packages
if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
working-directory: lesson
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
- run: make site
working-directory: lesson

- run: make lesson-check-all
working-directory: lesson
121 changes: 121 additions & 0 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Website
on:
push:
branches:
- gh-pages
- main
pull_request: []
jobs:
build-website:
if: ${{ !endsWith(github.repository, '/styles') }}
runs-on: ubuntu-20.04
env:
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
defaults:
run:
shell: bash
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install GitHub Pages, Bundler, and kramdown gems
run: |
gem install github-pages bundler kramdown kramdown-parser-gfm
- name: Install Python modules
run: |
python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
- name: Checkout the lesson
uses: actions/checkout@master
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Look for R-markdown files
id: check-rmd
run: |
echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})"
- name: Set up R
if: steps.check-rmd.outputs.count != 0
uses: r-lib/actions/setup-r@master
with:
r-version: 'release'

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

- name: Install needed packages
if: steps.check-rmd.outputs.count != 0
run: |
packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))
install.packages(packages, repo="https://cran.rstudio.com/")
shell: Rscript {0}

- name: Query dependencies
if: steps.check-rmd.outputs.count != 0
run: |
source('bin/dependencies.R')
deps <- identify_dependencies()
create_description(deps)
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}


- name: Install system dependencies for R packages
if: steps.check-rmd.outputs.count != 0
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
- name: Render the markdown and confirm that the site can be built
run: make site

- name: Checkout github pages
if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
uses: actions/checkout@master
with:
ref: gh-pages
path: gh-pages

- name: Commit and Push
if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
run: |
# clean up gh-pages
cd gh-pages
git rm -rf . # remove all previous files
git restore --staged . # remove things from the stage
cd ..
# copy everything into gh-pages site
cp -r `ls -A | grep -v 'gh-pages' | grep -v '.git' | grep -v '.bundle/' | grep -v '_site'` gh-pages
# move into gh-pages, add, commit, and push
cd gh-pages
# setup git
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add -A .
git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }})"
git push origin gh-pages
# return
cd ..
- run: make lesson-check-all
if: always()
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
.ipynb_checkpoints
.sass-cache
.jekyll-cache/
.jekyll-metadata
__pycache__
_site
.Rproj.user
.Rhistory
.RData
.bundle/
.vendor/
vendor/
.docker-vendor/
Gemfile.lock
.*history
*.Rproj
Loading

0 comments on commit 3455c4f

Please sign in to comment.