8 name: Test lesson template
9 if: github.repository == 'carpentries/styles'
10 runs-on: ${{ matrix.os }}
14 lesson: [swcarpentry/shell-novice, datacarpentry/r-intro-geospatial, librarycarpentry/lc-git]
15 os: [ubuntu-latest, macos-latest, windows-latest]
18 shell: bash # forces 'Git for Windows' on Windows
20 RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/bionic/latest'
23 uses: actions/setup-ruby@main
28 uses: actions/setup-python@v2
32 - name: Install GitHub Pages, Bundler, and kramdown gems
34 gem install github-pages bundler kramdown
36 - name: Install Python modules
38 if [[ $RUNNER_OS == macOS || $RUNNER_OS == Linux ]]; then
39 python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
40 elif [[ $RUNNER_OS == Windows ]]; then
41 python -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
44 - name: Checkout the ${{ matrix.lesson }} lesson
45 uses: actions/checkout@master
47 repository: ${{ matrix.lesson }}
51 - name: Determine the proper reference to use
54 if [[ -n "${{ github.event.pull_request.number }}" ]]; then
55 echo "::set-output name=ref::refs/pull/${{ github.event.pull_request.number }}/head"
57 echo "::set-output name=ref::gh-pages"
60 - name: Sync lesson with carpentries/styles
61 working-directory: lesson
63 git config --global user.email "team@carpentries.org"
64 git config --global user.name "The Carpentries Bot"
65 git remote add styles https://github.com/carpentries/styles.git
66 git config --local remote.styles.tagOpt --no-tags
67 git fetch styles ${{ steps.styles-ref.outputs.ref }}:styles-ref
68 git merge -s recursive -Xtheirs --no-commit styles-ref
69 git commit -m "Sync lesson with carpentries/styles"
71 - name: Look for R-markdown files
73 working-directory: lesson
75 echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})"
78 if: steps.check-rmd.outputs.count != 0
79 uses: r-lib/actions/setup-r@master
83 - name: Install needed packages
84 if: steps.check-rmd.outputs.count != 0
86 install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
89 - name: Query dependencies
90 if: steps.check-rmd.outputs.count != 0
91 working-directory: lesson
93 source('bin/dependencies.R')
94 deps <- identify_dependencies()
95 create_description(deps)
96 saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
97 writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
100 - name: Cache R packages
101 if: runner.os != 'Windows' && steps.check-rmd.outputs.count != 0
102 uses: actions/cache@v1
104 path: ${{ env.R_LIBS_USER }}
105 key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
106 restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
108 - name: Install system dependencies for R packages
109 if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
110 working-directory: lesson
115 done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
118 working-directory: lesson