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
21 uses: actions/setup-ruby@main
26 uses: actions/setup-python@v2
30 - name: Install GitHub Pages, Bundler, and kramdown gems
32 gem install github-pages bundler kramdown
34 - name: Install Python modules
36 if [[ $RUNNER_OS == macOS || $RUNNER_OS == Linux ]]; then
37 python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
38 elif [[ $RUNNER_OS == Windows ]]; then
39 python -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
42 - name: Checkout the ${{ matrix.lesson }} lesson
43 uses: actions/checkout@master
45 repository: ${{ matrix.lesson }}
49 - name: Look for R-markdown files
51 working-directory: lesson
53 echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})"
56 if: steps.check-rmd.outputs.count != 0
57 uses: r-lib/actions/setup-r@master
61 - name: Install needed packages
62 if: steps.check-rmd.outputs.count != 0
64 install.packages(c('remotes', 'rprojroot', 'renv', 'desc'))
67 - name: Query dependencies
68 if: steps.check-rmd.outputs.count != 0
69 working-directory: lesson
71 source('bin/dependencies.R')
72 deps <- identify_dependencies()
73 create_description(deps)
74 saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
75 writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
78 - name: Cache R packages
79 if: runner.os != 'Windows' && steps.check-rmd.outputs.count != 0
80 uses: actions/cache@v1
82 path: ${{ env.R_LIBS_USER }}
83 key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
84 restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
86 - name: Install system dependencies for R packages
87 if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
88 working-directory: lesson
93 done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
95 - name: Install R lessons package dependencies
96 if: steps.check-rmd.outputs.count != 0
97 working-directory: lesson
99 remotes::install_deps(dependencies = TRUE)
100 file.remove("DESCRIPTION")
103 - name: Determine the proper reference to use
106 if [[ -n "${{ github.event.pull_request.number }}" ]]; then
107 echo "::set-output name=ref::refs/pull/${{ github.event.pull_request.number }}/head"
109 echo "::set-output name=ref::gh-pages"
112 - name: Sync lesson with carpentries/styles
113 working-directory: lesson
115 git config --global user.email "team@carpentries.org"
116 git config --global user.name "The Carpentries Bot"
117 git remote add styles https://github.com/carpentries/styles.git
118 git config --local remote.styles.tagOpt --no-tags
119 git fetch styles ${{ steps.styles-ref.outputs.ref }}:styles-ref
120 git merge -s recursive -Xtheirs --no-commit styles-ref
121 git commit -m "Sync lesson with carpentries/styles"
124 working-directory: lesson