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
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
@@ -94,13 +135,13 @@ jobs:
94135 with :
95136 use-public-rspm : true
96137 install-r : false
97- r-version : ' release'
98138
99139 - name : Install needed packages
100140 if : steps.check-rmd.outputs.count != 0
141+ working-directory : lesson
101142 run : |
102- packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()) )
103- install.packages(packages, repo="https://cran.rstudio.com/" )
143+ source('bin/dependencies.R' )
144+ install_required_packages(.libPaths()[1] )
104145 shell : Rscript {0}
105146
106147 - name : Query dependencies
@@ -110,13 +151,14 @@ jobs:
110151 source('bin/dependencies.R')
111152 deps <- identify_dependencies()
112153 create_description(deps)
154+ use_bioc_repos()
113155 saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
114156 writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
115157 shell : Rscript {0}
116158
117- - name : Cache R packages
159+ - name : Restore Package Cache
118160 if : runner.os != 'Windows' && steps.check-rmd.outputs.count != 0
119- uses : actions/cache@v1
161+ uses : actions/cache@v2
120162 with :
121163 path : ${{ env.R_LIBS_USER }}
122164 key : ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
@@ -133,8 +175,11 @@ jobs:
133175 run : |
134176 while read -r cmd
135177 do
136- eval sudo $cmd
178+ eval sudo $cmd || echo "Nothing to update"
137179 done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
138180
139181 - run : make site
140182 working-directory : lesson
183+
184+ - run : make lesson-check-all
185+ working-directory : lesson
0 commit comments