|
| 1 | +## this workflow is primarily meant |
| 2 | +## for testing against CRAN-systems and |
| 3 | +## not for aligning against r-universe. |
| 4 | +name: Test R-universe |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [devel] |
| 9 | + pull_request: |
| 10 | + branches: [devel] |
| 11 | + |
| 12 | +## the permission has to be |
| 13 | +## set to write so we are allowed |
| 14 | +## to create a new branch |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +## this section is important |
| 19 | +## for this workflow - the |
| 20 | +## branch it works off of is |
| 21 | +## fixed, so if there is multiple pushes |
| 22 | +## it will cancel the old ones |
| 23 | +concurrency: |
| 24 | + group: r-universe-check |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + ## r-universe builds directly from |
| 29 | + ## the repository its being run from |
| 30 | + ## without modifictions to the actual runs. |
| 31 | + ## this means that untracked .Rd files never |
| 32 | + ## enters the build/check - to mitigate this |
| 33 | + ## we create a temporary branch where the .Rd |
| 34 | + ## files are pushed, and let r-universe build |
| 35 | + ## and test from there |
| 36 | + create-branch: |
| 37 | + name: Temporary branch creation |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + persist-credentials: true |
| 43 | + |
| 44 | + - name: Create and push r-universe/check-pkg |
| 45 | + run: | |
| 46 | + set -euo pipefail |
| 47 | + git config user.name "github-actions[bot]" |
| 48 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 49 | + git checkout -B r-universe/check-pkg |
| 50 | + git push --force origin r-universe/check-pkg |
| 51 | +
|
| 52 | + ## this step builds and pushes |
| 53 | + ## the documentation to the temporary branch |
| 54 | + render-documentation: |
| 55 | + needs: create-branch |
| 56 | + name: Render documentation and NAMESPACE |
| 57 | + runs-on: ubuntu-latest |
| 58 | + |
| 59 | + env: |
| 60 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + |
| 62 | + outputs: |
| 63 | + sha: ${{ steps.push.outputs.sha }} |
| 64 | + |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + ref: r-universe/check-pkg |
| 69 | + submodules: recursive |
| 70 | + persist-credentials: true |
| 71 | + |
| 72 | + - uses: r-lib/actions/setup-r@v2 |
| 73 | + with: |
| 74 | + r-version: release |
| 75 | + use-public-rspm: true |
| 76 | + |
| 77 | + - uses: r-lib/actions/setup-r-dependencies@v2 |
| 78 | + with: |
| 79 | + extra-packages: any::devtools any::roxygen2 |
| 80 | + needs: check |
| 81 | + |
| 82 | + - name: Render documentation and NAMESPACE |
| 83 | + run: devtools::document() |
| 84 | + shell: Rscript {0} |
| 85 | + |
| 86 | + - name: Commit rendered docs and push |
| 87 | + id: push |
| 88 | + run: | |
| 89 | + set -euo pipefail |
| 90 | + git config user.name "github-actions[bot]" |
| 91 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 92 | + git add -f man/ NAMESPACE |
| 93 | + git commit --allow-empty -m "CI/CD: render documentation for r-universe build" |
| 94 | + git push origin r-universe/check-pkg |
| 95 | + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 96 | +
|
| 97 | + build: |
| 98 | + needs: render-documentation |
| 99 | + name: R-universe testing |
| 100 | + uses: r-universe-org/workflows/.github/workflows/build.yml@v3 |
| 101 | + with: |
| 102 | + universe: ${{ github.repository_owner }} |
| 103 | + ref: ${{ needs.render-documentation.outputs.sha }} |
| 104 | + |
| 105 | + cleanup: |
| 106 | + needs: [render-documentation, build] |
| 107 | + if: always() |
| 108 | + runs-on: ubuntu-latest |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v4 |
| 111 | + - name: Delete temporary branch |
| 112 | + run: git push origin --delete r-universe/check-pkg || true |
0 commit comments